This discussion is archived
9 Replies Latest reply: Jul 18, 2012 1:54 AM by 944271 RSS

Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]

944271 Newbie
Currently Being Moderated
Hi,
I am getting exception when i change the below entry from Stateful to Stateless for Transaction Type "Container"..


----------------------------------------------------------------Working Fine for single and multi users----------------------------------------------------
<session>
          <description>Entity Bean Employee Example</description>
          <ejb-name>Stlg</ejb-name>
          <local-home>com..ejb.session.ejbeans.StlgHome</local-home>
          <local>com.ejb.session.ejbeans.Stlg</local>
          <ejb-class>com.ejb.session.ejbeans.StlgBean</ejb-class>
          <session-type>Stateful</session-type>
          <transaction-type>Container</transaction-type>
</session>
----------------------------------------------------------------Working Fine for single and multi users----------------------------------------------------







----------------------------------------------------------------Working Fine for single user and exception for multi users----------------------------------------------------
<session>
          <description>Entity Bean Employee Example</description>
          <ejb-name>Stlg</ejb-name>
          <local-home>com..ejb.session.ejbeans.StlgHome</local-home>
          <local>com.ejb.session.ejbeans.Stlg</local>
          <ejb-class>com.ejb.session.ejbeans.StlgBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
</session>
----------------------------------------------------------------Working Fine for single and exception for multi users------------------------------------------------------------

2012-06-27 12:27:15,531 DEBUG com.ds.ApplSessListener 16 - vattributeAdded : errorencountered,java.lang.ClassCastException: java.lang.String cannot be cast to com.packg.class

Strange that its working for single user and cracking for multiuser when tested via jmeter
  • 1. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    gimbal2 Guru
    Currently Being Moderated
    So you did something wrong. In stead of assuming that dark forces are conspiring against you and running to a forum why don't you take 5 more seconds to look at it.
    com..ejb.session.ejbeans.StlgHome
    See something wrong there?
  • 2. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    944271 Newbie
    Currently Being Moderated
    Code of Home interface

    -----------------------------------------------------------------------------
    package com.ejb.session.ejbeans;

    import java.rmi.RemoteException;

    import javax.ejb.CreateException;
    import javax.ejb.EJBLocalHome;


    public interface StlgHome extends EJBLocalHome {
    Stlg create() throws CreateException, RemoteException;
    }
    -----------------------------------------------------------------------------------
  • 3. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    r035198x Pro
    Currently Being Moderated
    There is no need to post the code.
    Read the first reply again, you have an error in your xml definition where you put <local-home>com..ejb.session.ejbeans.StlgHome</local-home> instead of <local-home>com.ejb.session.ejbeans.StlgHome</local-home>
  • 4. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    944271 Newbie
    Currently Being Moderated
    That was a typo in forum,It was written as com.ejb.session.ejbeans.StlgHome only
  • 5. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    gimbal2 Guru
    Currently Being Moderated
    You're not making a lot of sense here. How can you make a typo when you're dumping XML configuration stuff? Surely you copy/pasted the entire thing in stead of typing it over. If you did type it over then whatever is there cannot be trusted. Repost everything and this time exactly as you have it, including the error message you got in the logs. Your comment about "single user" and "multi user" is also quite vague. What do you mean by that exactly?

    And for the future: post code (which also includes XML config stuff) inside \
     tags to make it more readable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  • 6. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    944271 Newbie
    Currently Being Moderated
    12/06/28 12:21:42 java.lang.IndexOutOfBoundsException: Index: 2300, Size: 2300
    12/06/28 12:21:42      at java.util.ArrayList.RangeCheck(Unknown Source)
    12/06/28 12:21:42      at java.util.ArrayList.get(Unknown Source)
    12/06/28 12:21:42      at com.ejbeans.StlEntryBean.getEntryList(StlEntryBean.java:1587)
    12/06/28 12:21:42      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    12/06/28 12:21:42      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    12/06/28 12:21:42      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    12/06/28 12:21:42      at java.lang.reflect.Method.invoke(Unknown Source)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.java:53)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    12/06/28 12:21:42      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
    12/06/28 12:21:42      at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
    12/06/28 12:21:42      at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
    12/06/28 12:21:42      at Entry_LocalProxy_1dc72ge.getEntryList(Unknown Source)
    12/06/28 12:21:42      at com.ejb.client.EntryClient.getEntryList(EntryClient.java:145)
    12/06/28 12:21:42      at EntryServ.find(EntryServ.java:8613)
    12/06/28 12:21:42      at EntryServ.doGet(EntryServ.java:439)
    12/06/28 12:21:42      at EntryServ.doPost(EntryServ.java:280)
    12/06/28 12:21:42      at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    12/06/28 12:21:42      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    12/06/28 12:21:42      at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    12/06/28 12:21:42      at LogFilter.doFilter(LogFilter.java:57)
    12/06/28 12:21:42      at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:644)
    12/06/28 12:21:42      at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
    12/06/28 12:21:42      at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
    12/06/28 12:21:42      at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
    12/06/28 12:21:42      at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:226)
    12/06/28 12:21:42      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:127)
    12/06/28 12:21:42      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:116)
    12/06/28 12:21:42      at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    12/06/28 12:21:42      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    12/06/28 12:21:42      at java.lang.Thread.run(Unknown Source)

    Single user means a single user logged-In,Multi user means 10-20 users logged in via apache jmeter for testing performance..

    Let me know if anthing else required

    Edited by: user9052593 on Jun 28, 2012 12:12 AM
  • 7. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    gimbal2 Guru
    Currently Being Moderated
    com.ejbeans.StlEntryBean.getEntryList(StlEntryBean.java:1587)
    Is that one of your own classes?

    I have this nagging feeling that you're putting member variables in the STATELESS EJB. In other words: you're giving state to a STATELESS EJB. And if you do that means you did not change any code, you just changed the XML configuration without knowing or even caring about the consequences. That would explain why it works when just one user does stuff and things crumble when multiple users do stuff, you've created multithreading issues.
  • 8. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    944271 Newbie
    Currently Being Moderated
    Yes you are correct,Basically i segregated Stateful(StfgBean) and Stateless beans(StlgBean)..Earlier all are mixed in one bean(StlgBean)..Now i took Stateful methods from mixed bean and made an entry of Stateful And the mixed bean which was running as Stateful renamed to stateless..

    So the problem with that mixed bean"StlgBean"..Its not running as Stateless but running as Stateful..

    ----------------------------------------------------------------Working Fine for single and multi users----------------------------------------------------
    <session>
    <description>Entity Bean Employee Example</description>
    <ejb-name>Stlg</ejb-name>
    <local-home>com..ejb.session.ejbeans.StlgHome</local-home>
    <local>com.ejb.session.ejbeans.Stlg</local>
    <ejb-class>com.ejb.session.ejbeans.StlgBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>

    <session>
    <description>Entity Bean Employee Example</description>
    <ejb-name>Stfg</ejb-name>
    <local-home>com..ejb.session.ejbeans.StfgHome</local-home>
    <local>com.ejb.session.ejbeans.Stfg</local>
    <ejb-class>com.ejb.session.ejbeans.StfgBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    ----------------------------------------------------------------Working Fine for single and multi users----------------------------------------------------


    ----------------------------------------------------------------Working Fine for single user and exception for multi users----------------------------------------------------
    <session>
    <description>Entity Bean Employee Example</description>
    <ejb-name>Stlg</ejb-name>
    <local-home>com..ejb.session.ejbeans.StlgHome</local-home>
    <local>com.ejb.session.ejbeans.Stlg</local>
    <ejb-class>com.ejb.session.ejbeans.StlgBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>

    <session>
    <description>Entity Bean Employee Example</description>
    <ejb-name>Stfg</ejb-name>
    <local-home>com..ejb.session.ejbeans.StfgHome</local-home>
    <local>com.ejb.session.ejbeans.Stfg</local>
    <ejb-class>com.ejb.session.ejbeans.StfgBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    ----------------------------------------------------------------Working Fine for single and exception for multi users------------------------------------------------------------

    Edited by: user9052593 on Jun 28, 2012 5:38 AM
  • 9. Re: Exception came when change stateful to stateless in ejb-jar.xml [Ejb 2.0]
    944271 Newbie
    Currently Being Moderated
    -----------------------ejb-jar.xml---------------------------------

    <session>
    <description>Entity Bean</description>
    <ejb-name>Stl</ejb-name>
    <local-home>com.ejb.session.ejbeans.StlHome</local-home>
    <local>com.ejb.session.ejbeans.Stl</local>
    <ejb-class>com.ejb.session.ejbeans.StlBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>


    -----------------------ejb-jar.xml---------------------------------

    --------------------------------------------------StlBean---------------------------------------------------

    public ArrayList setaArrList() throws RemoteException {
    makeConnection();

    try {
    results = statement.executeQuery(aExQry);

    resultsetmetadata = results.getMetaData();
    int i = resultsetmetadata.getColumnCount();
    totcols = i;
    int j = 1;
    ArrayList arr = new ArrayList();
    ArrayList arrnm = new ArrayList();

    while (results.next()) {
    for (int k = 1; k <= i; k++) {
    String s2 = resultsetmetadata.getColumnName(k);
    int coltype = resultsetmetadata.getColumnType(k);
    String s3 = null;

    if(coltype == java.sql.Types.CLOB) {
    Clob fileAsCLOB = null;
    long length = 0;
    fileAsCLOB = results.getClob(resultsetmetadata.getColumnName(k));
    if(fileAsCLOB != null) {
    length = fileAsCLOB.length();
    s3 = fileAsCLOB.getSubString(1, (int) length);
    }
    } else {
    s3 = results.getString(resultsetmetadata.getColumnName(k));
    }

    if (!arrnm.contains(s2)) {
    s2 = setString(s2);
    arrnm.add(s2);
    }

    s3 = setString(s3);
    arr.add(s3);
    }

    j++;
    }


    this.x= arrnm;

    }

    public ArrayList getxArrList() throws RemoteException {
    try {
    return x;
    }
    --------------------------------------------------StlBean---------------------------------------------------

    Problem is with getxArrList() ,We not getting the correct value of x when tested for 2 users...How to get correct result if we dont want our bean to be stateful

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points