Can a session bean call a database?? design issue

Is there a thumb rule that all my database calls should be made through an
entity bean ?
I have data that needs to be saved across calls as well as persisted to the
database. But the instance of the object is not going to be modified
concurrently. So basically there is no problem of maintaining the
consistency of data. The class itself takes care of it. Can I put all this
in a STATEFUL session bean which calls my database ??
Devu.

http://java.sun.com/j2ee/sdk_1.2.1/techdocs/guides/ejb/html/Overview4.html#9382
devu wrote:
Is there a thumb rule that all my database calls should be made through an
entity bean ?
I have data that needs to be saved across calls as well as persisted to the
database. But the instance of the object is not going to be modified
concurrently. So basically there is no problem of maintaining the
consistency of data. The class itself takes care of it. Can I put all this
in a STATEFUL session bean which calls my database ??
Devu.

Similar Messages

  • Can CMT Session Bean call BMP Entity Bean in WebLogic 6.0?

              Hi
              Does anybody successfully use CMT Session Bean calling BMP +CMT Entity bean in
              WebLogic6.0? I have the following problem.
              Any idea will be appreciated.
              --Winston
              Let's say we have a Session bean SB, it uses container to manage the transaction.
              A method of SB will call an Entity Bean EB which adopts bean-managed persistence.
              Both SB and EB use CMT and all of their methods use "required" in the descriptor
              file.
              1. If the connection con.getAutoCommit() is true in the EB, then the transaction
              within SB cannot be rolled back as the ejbCreate() has already commit into the
              database.
              2. On the other hand if Connecton of EB con.getAutoCommit() is false, then container
              cannot successfully commit the transaction from SB's method, as EjbCreate and
              EjbStore() in EB are likely using the different database connections, which causes
              EbjStore() fail and the following error message will be sent to the Console:
              ============================================================
              "<Jul 9, 2001 4:16:48 PM PDT> <Error> <EJB> <Exception during commit of transacti
              on transaction=(IdHash=7738920,Name = [EJB TraderBeanImpl.buy()],Xid=105:5e6719a
              ded42e332,Status=Rolled back. [Reason = weblogic.utils.NestedRuntimeException:
              E
              rror writing from beforeCompletion - with nested exception:
              [java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityE
              xception: ejbStore: AccountBean (4003) not updated]],numRepliesOwedMe=0,numRepli
              esOwedOthers=0,seconds since begin=0,seconds left=30,SCInfo[examplesServer]=(sta
              te=rolledback),properties=({weblogic.transaction.name=[EJB TraderBeanImpl.buy()]
              })): java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEnt
              ityException: ejbStore: AccountBean (4003) not updated
              at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRunti
              meUtils.java:57)
              at weblogic.ejb20.manager.DBManager.beforeCompletion(DBManager.java:364)
              at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManag
              er.java:211)
              at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(Serv
              erSCInfo.java:511)
              at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(Se
              rverSCInfo.java:78)
              at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAn
              dChain(ServerTransactionImpl.java:893)
              at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(
              ServerTransactionImpl.java:1229)
              at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTran
              sactionImpl.java:168)
              at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:2
              01)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl.buy(TraderBeanEOI
              mpl.java:37)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl_WLSkel.invoke(Tra
              derBeanEOImpl_WLSkel.java:76)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:373)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:237)
              at weblogic.rmi.internal.BasicRequestHandler.handleRequest(BasicRequestH
              andler.java:118)
              at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
              .java:17)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              --------------- nested within: ------------------
              weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - wit
              h nested exception:
              [java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityE
              xception: ejbStore: AccountBean (4003) not updated]
              at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManag
              er.java:220)
              at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(Serv
              erSCInfo.java:511)
              at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(Se
              rverSCInfo.java:78)
              at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAn
              dChain(ServerTransactionImpl.java:893)
              at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(
              ServerTransactionImpl.java:1229)
              at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTran
              sactionImpl.java:168)
              at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:2
              01)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl.buy(TraderBeanEOI
              mpl.java:37)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl_WLSkel.invoke(Tra
              derBeanEOImpl_WLSkel.java:76)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:373)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:237)
              at weblogic.rmi.internal.BasicRequestHandler.handleRequest(BasicRequestH
              andler.java:118)
              at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
              .java:17)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              --------------- nested within: ------------------
              weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion
              : sync = weblogic.ejb20.internal.TxManager$TxListener@356eb0
              Error writing from beforeCompletion - with nested exception:
              [weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion -
              wi
              th nested exception:
              [java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityE
              xception: ejbStore: AccountBean (4003) not updated]]
              at weblogic.transaction.internal.TransactionImpl.throwRollbackException(
              TransactionImpl.java:1261)
              at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTran
              sactionImpl.java:218)
              at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:2
              01)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl.buy(TraderBeanEOI
              mpl.java:37)
              at examples.ejb.basic.statefulSession.TraderBeanEOImpl_WLSkel.invoke(Tra
              derBeanEOImpl_WLSkel.java:76)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:373)
              at weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.ja
              va:237)
              at weblogic.rmi.internal.BasicRequestHandler.handleRequest(BasicRequestH
              andler.java:118)
              at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
              .java:17)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >"
              

    We did receive a 4.5.1 / 5.1 interoperability patch - but it wasn't quite 'seamless'.
    We never tried to use it.
    SOAP? Isn't that around 50 times slower than RMI?
    Mike
    "Gary Mui" <[email protected]> wrote:
    We ran into this issue last fall and got some feedback from weblogic
    support. They originally said that it could be done (as well as different
    versions talking to one another via JMS) but it turned out that they
    were
    incorrect and ended up saying that it is not possible. Before 6.0 went
    GA,
    BEA said that there would be a interoperability patch to do this, but
    I've
    never seen nor heard of anything regarding it. As a workaround, we
    implemented 4.5.1 / 6.0 communication via SOAP.
    Mike Reiche wrote in message <3b1bcaec$[email protected]>...
    I have the same question - and more. Last year we were told that wecould
    not use
    RMI (and ejbs) between 4.5.1 and 5.1. Which seems kinda weird becauseI've
    heard
    of people using WL ejbs from Tomcat. This issue has caused us to avoidusing
    WL ejbs in any future development which has any chance of ever beingused
    by any
    app server (WL included) that is not under the direct control of thedata
    center.
    I've been trying to convince the Architecture team here that we canuse WL
    EJBs
    and we can call them from other app servers - but can't seem to getany
    supporting
    statement from BEA (maybe I haven't tried hard enough).
    Anyway, a response from BEA would be appreciated.
    - Mike
    "Madhu K" <[email protected]> wrote:
    Is it possible to call a (stateless session) bean deployed in weblogic
    6.0
    from a bean in weblogic 5.1? I have two versions of weblogic running
    on two
    different hosts and I have to call a bean that is running in 6.0 from
    5.1.
    Are there any limitations?
    Appreciate any feedback/suggestions.
    Thanks,
    Madhu

  • Session Bean calling entity bean

    Hi
    How does session bean calls entity bean in weblogic6.1
    Thanks

    have a look in the examples that come with weblogic
    "Anand" <[email protected]> wrote in message
    news:[email protected]..
    >
    >
    Hi
    How does session bean calls entity bean in weblogic6.1
    Thanks

  • Stateless Session Bean calling another Stateless Session Bean

    Hi all,
    I have written 2 Stateless Session bean and would like to call the business method of 2nd Stateless Session Bean in the business method of the 1st.
    I have written the lookup code for 2nd SB in the business method of 1st SB and would like to execute the business method in the same method itself.
    What do I have to do for the same for the following :
    Deployment Descriptor file or any other file needs to be modified.
    I am using Weblogic 6.1 and SQL Server 7.0 as database.
    Thanks in advance,
    Seetesh

    This is actually quite similar to calling a session bean from anywhere.
    Try this
    //Session Bean 2 - Business Method, JNDI name SessionBean2
    public void doSomethingMore(String what)
    // Session Bean 1 which call.
    public void doSomething()
       InitialContext initCtx = new InitialContext();
       SessionBean2Home home2 = null;
       SessionBean2 bean2 = null;
       try
         home2 = (SessionBean2Home)initCtx.lookup("SessionBean2");
         bean2 = home2.create();
       }catch(FinderException ex){..}
        catch(CreateExceptrion ex){..}
       try
         bean2.doSomethingMore("Anything");
       }catch(remoteException ex){..}
    }In my case (webLogic 5.1) I did not need to change anything in any of the deployment descriptor. However, both beans needs top be deployed on same instance of Application server (might work across instances but didnt try)
    This should do it.
    Amitabh

  • EJB 2.1 session bean calling EJB 3 session bean?

    I have a WL 10 (JDK 1.5/EE 5) server that has several EJB 3 stateless session beans deployed and working well. But now I need to allow a JBoss 3.2.3 (JDK 1.4) EJB 2.1 session bean make remote calls into these EJB 3 EJBs. Can this even work?
    It seems to me that EJB 3 calling EJB 2 would be fine, but not in the reverse?

    I have a WL 10 (JDK 1.5/EE 5) server that has several EJB 3 stateless session beans deployed and working well. But now I need to allow a JBoss 3.2.3 (JDK 1.4) EJB 2.1 session bean make remote calls into these EJB 3 EJBs. Can this even work?
    It seems to me that EJB 3 calling EJB 2 would be fine, but not in the reverse?

  • Help Connecting A Stateless Session Bean To MySQL Database

    Hi, I'm trying to connect a simple stateless session bean that has been
    deployed using the admin console to a MySQL database that has been
    set up and pinged using the JDBC Resources/Connection Pools part of the
    admin console.
    When I attempt to connect to the database using the session bean I get the
    following error message:
    Exception in thread "main" java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.RemoteException: ; nested exception is:
         java.sql.SQLException: No database selected
         at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:161)
         at javax.rmi.CORBA.Util.mapSystemException(Unknown Source)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:142)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at DBDynamicStub.testDatabase(_DB_DynamicStub.java)
         at DBClient.main(DBClient.java:9)
    Caused by: java.rmi.RemoteException: ; nested exception is:
         java.sql.SQLException: No database selected
         at com.sun.ejb.containers.InvocationHandlerUtil.throwRemoteException(InvocationHandlerUtil.java:96)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:141)
         at $Proxy26.testDatabase(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:123)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:648)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:192)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1709)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1569)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:951)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:181)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:721)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1258)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:409)
    Caused by: java.sql.SQLException: No database selected
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2379)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2306)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1192)
         at DBBean.testDatabase(DBBean.java:45)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:950)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
    Obviously this means that the bean can't connect to the database but I am
    unsure why this is. When I set up the database using the admin console
    I set the the jndi name to jdbc/test and I've tried using the following look up
    code to find the database that is referenced by the JNDI name:
    Context context = new javax.naming.InitialContext();
              DataSource ds = (DataSource) context.lookup("jdbc/test");
    and also
    Context context = new javax.naming.InitialContext();
    DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/test");
    Neither of these methods work.
    When I look at the JNDI Tree Browsing window which is available from the
    admin console there is no mention of the database at all, there are four
    items in the three, they are:
    UserTransaction
    ->jdbc
    ->ejb
    DBBean
    Do I need to add a JNDI reference somewhere in order for the bean to locate
    the database? I thought that when I created the database in the admin
    console and specified a JNDI name this would be all that's required in order
    for beans to locate the database, obviously not.
    If anyone can offer any advice at all I would be very very grateful.
    Ian

    stmt.execute("use YOUR_DATABASE_NAME");
    // then your db queries.This approach works for me.
    It also works to specify the database in the query like this:
    InitialContext initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource) envCtx.lookup("jdbc/myDB");
    Connection conn = ds.getConnection();
    try {
           Statement statement  = conn.createStatement();
           ResultSet rs = statement.executeQuery("select * from myDB.news");
           ...As you can see I added myDB. to the query.
    But why is this necessary?
    If I use DriverManager instead, this is NOT necessary. Like this:
    Connection connection = null;
    try {
           Class.forName("com.mysql.jdbc.Driver");
           connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myDB", "username", "password");
           Statement statement = connection.createStatement();
           ResultSet rs = statement.executeQuery("select * from news");
           ...Why do I not have to run the query statement.execute("use YOUR_DATABASE_NAME"); or specify the database name in the query statement.executeQuery("select * from myDB.news"); when I use DriverManager to obtain a Connection when I have to do that when using a DataSource?
    It don't seem very efficient to have to run the extra query ( use db-name ) before I run any other query in my application.

  • Dynamic session bean call

    During our development, we're going to call some session beans, but not by the normal way. We have the session bean A, that contains some data such like the name for the remote and home interface and JNDI Name for a session bean B. It also contains the name of a method that shall be called in the session bean B. We can call the method using the specific classes for that (Class, Method, invoke, and so on). Our matter is: how to refer the session bean B in the "ejb-jar.xml" (and in "jboss.xml", since we use JBoss 3.0.0)? To invoke the session bean B, it must exist an "<ejb-ref>" tag in the "ejb-jar.xml", so that I can call the lookup and the session bean is found.
    Can anybody help us, or tell where can we find some help?
    Thanks,
    Jonatan Schroeder
    Medisoft - Brazil

    Hi
    Now I have the same problem that you. Did you solve that?
    I would appreciate your answer
    Thanks in advance,
    Juan

  • Session management in session bean calling session bean

    Hi,
              I've got another question on transaction.
              I have following stateless session beans :
              session1 with trans-attribute Required.
              session2 with trans-attribute Required.
              session1 calls session2 and session3.
              session2 inserts/updates records in the database.
              What am doing is first I call a createSchedule method in session2, which
              creates a new record in the database.
              And then I call an update method on the session2 bean, that will fetch and
              update the newly created record.
              This second update fails, due to some database constraints.
              What I was hoping, that the record should not be created in the database,
              but it did.
              The first method call in session2 succeeded and the second failed !!
              Doesnt both the DML be part of one transaction ?
              Thanks
              Amit
              

    Solved this one too :
              What was happening was, Before I called the create method of the session
              bean, I was calling a find method, and I was capturing the exception, and in
              case theres an exception, assuming that there is no record in the database,
              I create a new record. This find method is in the same session bean,
              session2 along with the create and update methods. Inititally when there was
              no record, the session bean was raising EJBException, due to which the main
              session bean, session1, rollbacks the transaction, it started, but as I was
              catching this exception, so the execution continued, .... next statement
              being create, and as the transaction attribute of it was Required, and as
              the session1 bean's transaction has already been rolled back, there was no
              transaction, so the create method started its own transaction, and created
              the record, and then the update method too did the same, but it gave an
              error, so only update method's transaction got rolled back.
              So I changed the find method to throw FinderException, instead of
              EJBException, so the transaction of sessio1 bean is not lost.
              Its working now.
              But the other problem I posted, where I dont want to throw any exception to
              the client calling the session1 bean, I still havent figured it out, how to
              stop it, although am catching all the exceptions, still the client got
              exception.
              Thanks
              Amit Chauhan
              eTouch System
              510-795-4800 ext 113
              Amit <[email protected]> wrote in message
              news:[email protected]...
              > Hi,
              > I've got another question on transaction.
              > I have following stateless session beans :
              > session1 with trans-attribute Required.
              > session2 with trans-attribute Required.
              >
              > session1 calls session2 and session3.
              >
              > session2 inserts/updates records in the database.
              >
              > What am doing is first I call a createSchedule method in session2, which
              > creates a new record in the database.
              > And then I call an update method on the session2 bean, that will fetch and
              > update the newly created record.
              >
              > This second update fails, due to some database constraints.
              > What I was hoping, that the record should not be created in the database,
              > but it did.
              > The first method call in session2 succeeded and the second failed !!
              >
              > Doesnt both the DML be part of one transaction ?
              >
              > Thanks
              > --
              > Amit
              >
              >
              >
              

  • Session bean calls enttity bean got error !!!! *urgent*

    i have a session bean(customerController)with jndi(ejb/customer) calling entity bean (customer).Both using remote interface. when i build a frame application to test these beans. i get the error below.
    can anybody tell me wat happen ?!!
    23:20:22,861 ERROR [LogInterceptor] EJBException: javax.ejb.EJBException: removeCustomer: null      at sessioncallsentitybean.CustomerControllerBean.createCustomer(CustomerControllerBean.java:63)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:324)      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)      at org.jboss.ejb.Container.invoke(Container.java:738)      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke
    (JRMPInvoker.java:383)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:324)      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)      at sun.rmi.transport.Transport$1.run(Transport.java:148)      at java.security.AccessController.doPrivileged(Native Method)      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)      at java.lang.Thread.run(Thread.java:536)

    seems like the logic stops when session bean is trying to create an instance of entity bean. i ve set my jndi name (ejb/Customer)correctly in the naming code part in session bean. Can u tell me wat steps that i might have missed. pls. thank you so much. =)
    session bean manages to pass through methods below:
    ejbCreate ()
    createCustomer()
    makeConnection()
    releaseConnection()... but throws the EJBException
    public String createCustomer(String custName, String custEmail, String custAddress, String custGender, String custPhoneNo) throws CreateException {
         System.out.println("CustomerControllerBean createCustomer");
        try{
          makeConnection();
          customer = customerHome.create(customerId, custName,
                     custEmail, custAddress, custGender, custPhoneNo);
          releaseConnection();
        } catch (Exception ex){
          releaseConnection();
          throw new EJBException
          ("createCustomer: " + ex.getMessage());
        return customerId;
      }my error is "javax.ejb.EJBException: createCustomer: null" the rest of the error warning is mentioned in the first posted message above.

  • What role can ejb Session Beans  play  jsp session tracking

     

              I am also looking for a way to use JSP as ejb client with WLS5.1. i would appreciate any help.
              -Girish
              Prasad Peddada <[email protected]> wrote:
              >David,
              >     The beans which are refered in jsp specs are java beans and not EJB.
              >
              >Prasad
              >
              >David Levy wrote:
              >>
              >> Hello,
              >>
              >> We are using Jsp/Servlets which will hold session state and subsequently
              >> call ejb Session Beans for transaction/persistence coordination . We are
              >> not sure if we are using the correct techniques to control object memory.
              >>
              >> Summary of what we have:
              >>
              >> A jsp with the "useBean" directive:
              >> <jsp:useBean id="MySession" class="com....MySession"
              >> scope="session"></jsp:useBean>
              >>
              >> The class MySession holds other classes ( all serializable).
              >> The class MySession is NOT an ejb Session Bean
              >>
              >> Questions:
              >> We are considering making class MySession an ejb Session Bean so (via it's
              >> passivate/activate feature) we can control instances in memory as more web
              >> clients start the session from the jsp page. I.E. all web clients will have
              >> their own HttpSession instance which holds on to an ejb Session Bean object
              >> "MySession"( or a passivated representation of it)
              >>
              >> 1) Is this a sufficient approach or will there be other memory concerns?
              >> I.E. What about all the HttpSession objects out there? Do they need to be
              >> passivated as well?
              >>
              >> 2) If its a good idea to passivate the HttpSessions as well, then what
              >> mechanism should be used ( servlet session persistence)? Also, if we are
              >> passivating the HttpSession (which holds on to the MySession object graph)
              >> , then why bother with the SessionBean for passivation
              >>
              >> 3) Currently, we only have a single instance of a servlet handling all
              >> requests. Will multiple instances buy us anything?
              >>
              >> 4) How does clustering relate to this topic?
              >>
              >> 5) Can we change the "jsp:useBean" directive so MySession is an ejb Session
              >> Bean or do we have to do the "home.create()" within a jsp script?
              >>
              >> thanks,
              >> dave
              

  • Local Session Bean calling another local Session Bean in EJB 3.0

    Hi,
    In EJB 3.0, I am trying to do JNDI lookup of a local sesion bean from another session bean's helper class.
    I am not using @EJB injection mechanism here, as call to the local session bean is made in a helper class. Helper classes do not support resource injection.
    Following are the EJB class definitions used in my project. Call to "EJB3Local" made from "EJB1" fails as the "EJB2" helper class is calling "EJB1Local"
    @Stateless
    @EJBs({@EJB(name="EJB2Local", beanInterface=EJB2Local.class),
    @EJB(name="EJB3Local", beanInterface=EJB3Local.class)})
    public class EJB1 implements EJB1Remote, EJB1Local{
    public void findEJB3Local(){
    //1. JNDI lookup for EJB3Local ----
    //2. EJB3Local.someFunction()
    @Stateless
    @EJB(name="EJB1Local", beanInterface=EJB1Local.class)
    public class EJB2 implements EJB2Remote, EJB2Local{
    public void findEJB1Local(){
    //1. JNDI lookup EJB1Local
    // 2. Call EJB1Local.findEJB1Local method
    @Stateless
    public class EJB3 implements EJB3Remote, EJB3Local{
    public void someFunction(){}
    A remote call to EJB2.findEJB1Local() will invoke EJb1Local.findEJB3Local method and the call fails with "java:comp/env/EJB3Local" not found in EJB1Local.
    Has anybody encountered an issue like this issue with local interface calling another local interface?
    Thanks,
    Mohan

    To refer a Ejb from another Ejb include <ejb-ref> element
    in ejb-jar.xml
    <session>
    <ejb-name>SessionBeanA</ejb-name>
    <ejb-ref>
    <ejb-ref-name>SessionBeanB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ejb.SessionBeanBHome</home>
    <remote>com.ejb.SessionBeanB</remote>
    </ejb-ref>
    </session>
    Include a <reference-descriptor> in weblogic-ejb-jar.xml
    <weblogic-enterprise-bean>
    <ejb-name>SessionBeanA</ejb-name>
    <reference-descriptor>
    <ejb-reference-description>
    <ejb-ref-name>SessionBeanB</ejb-ref-name>
    <jndi-name>com.ejb.SessionBeanBHome</jndi-name>
    </ejb-reference-description>
    </reference-descriptor>
    </weblogic-enterprise-bean>
    In SessionBeanA Bean class refer to SessionBeanB with
    a remote reference to SessionBeanB.
    InitialContext initialContext=new InitialContext();
    SessionBeanBHome sessionBeanBHome=(SessionBeanBHome)
    initialContext.lookup("com.ejb.SessionBeanBHome");
    SessionBeanB sessionBeanB=sessionBeanBHome.findByPrimaryKey(primarykey);
    sessionBeanB.update();
    sessionBeanB.getAll();
    thanks,
    Deepak

  • Local Session Bean Call Exception in App Server

    I have been having trouble calling a Local Session bean in Glassfish.
    I set up an example to show the exception I am having:
    MainBeanLocal
        package com.test;
        import javax.ejb.Local;
        @Local
        public interface MainBeanLocal {
             void testCall();
    MainBean:
        package com.test;
        import javax.ejb.Stateless;
         * Session Bean implementation class MainBean
        @Stateless(mappedName = "ejb/MainBean")
        public class MainBean implements MainBeanLocal {
             @Override
             public void testCall() {
                  System.out.println("Test Call Succeeded");
    RemoteBeanRemote:
        package com.test;
        import javax.ejb.Remote;
        @Remote
        public interface RemoteBeanRemote {
             public void callMainBean();
    RemoteBean:
        package com.test;
        import javax.ejb.Stateless;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
         * Session Bean implementation class RemoteBean
        @Stateless(mappedName = "ejb/RemoteBean")
        public class RemoteBean implements RemoteBeanRemote {
             @Override
             public void callMainBean() {
                  try {
                       InitialContext ctx = new InitialContext();
                       MainBeanLocal mb = (MainBeanLocal) ctx.lookup("ejb/MainBean");
                       mb.testCall();
                  } catch (NamingException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
    Test Code:
        package com.test;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
        public class BeanTester {
             public static void main(String[] args){
                  try {
                       InitialContext ctx = new InitialContext();
                       RemoteBeanRemote remote = (RemoteBeanRemote) ctx.lookup("ejb/RemoteBean");
                       remote.callMainBean();
                  } catch (NamingException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
    Output Trace:
        INFO: deployed with moduleid = TestEJB
        INFO: **RemoteBusinessJndiName: ejb/RemoteBean; remoteBusIntf: com.test.RemoteBeanRemote
        INFO: LDR5010: All ejb(s) of [TestEJB] loaded successfully!
        WARNING: javax.naming.NameNotFoundException: MainBean not found
             at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
             at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
             at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
             at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
             at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
             at javax.naming.InitialContext.lookup(InitialContext.java:392)
             at com.test.RemoteBean.callMainBean(RemoteBean.java:19)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
             at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
             at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
             at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
             at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
             at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
             at $Proxy71.callMainBean(Unknown Source)
    ...What am I doing wrong when calling **MainBeanLocal**? I would like to avoid dependency injection, as if the MainBeanLocal was being called from a POJO.
    Note: I have no trouble calling the RemoteBean.. I want to be able to call the local bean from the remote bean.

    Maik,
    If this is still a problem, could you please post the descriptors from the EAR?
    Are you using any annotations?
    - Tim

  • Session bean calling read-only entiti bean

    I have a session bean that is calling a read-only entity bean. I gets the remote
    reference to the bean ok but when I call a method on the entity bean it locks.
    After 5 minutes the call executes but then the session bean times out. Is there
    any special setting I need to do this? I set both transaction attributes to Required.
    Thanks,
    Tim

    5.1
    Seth White <[email protected]> wrote:
    >
    Hi.
    What release are you using?
    Seth
    Tim wrote:
    I have a session bean that is calling a read-only entity bean. I getsthe remote
    reference to the bean ok but when I call a method on the entity beanit locks.
    After 5 minutes the call executes but then the session bean timesout. Is there
    any special setting I need to do this? I set both transaction attributesto Required.
    Thanks,
    Tim

  • Urgent - (session bean calling Entity bean )Help Need for me - Plzzzzzzzzzz

    Hi
    I am created two beans one is Entity bean another one is session . the two beans deployed using diffrent jar files
    . I call the Entity bean methods using session bean
    But i couldn't locate the entity bean Home object through session bean(
    Sub is created but i couldn't get it that home obj stub)
    i get the following error messgae CorbaBad Operation
    i deployed two bean using same jar means my program is working
    Help meeeeeee

    I Send part of code to u
    public String logic1(rsp.ejbbm.ex.studVO s) {
              rsp.ejbbm.student.studentRemote r=null;
              String id = null;
              try {
    System.out.println("sdfsdfsdfs");
              Object obj = ctx.lookup("ejb/student");
              System.out.println("Lookup Succeded ");
              System.out.println("Object value" +obj.toString());
    /// HERE I GOT THE ERRO I COULDn'T Locate IT
    EJBHome obj1 =(EJBHome)javax.rmi.PortableRemoteObject.narrow(obj,rsp.ejbbm.student.studentHome.class);
              System.out.println("Object value" +obj1.toString());
              rsp.ejbbm.student.studentHome home=(rsp.ejbbm.student.studentHome)obj1;
              //studentHome hom=(studentHome)ctx.lookup("ejb/student");
         System.out.println("Object value" +obj.toString() );
         System.out.println("Lookup Converted ");
              home.create(s.getRollno(),s.getName());
              System.out.println("student Record isInserted in Oracle ");
              r= (rsp.ejbbm.student.studentRemote) home.findByPrimaryKey(s.getRollno());
              System.out.println("Student 5555 Name is "+ r.getName());
              id = r.getName();
              catch(Exception e ){
              System.out.println(e.toString());}
              return id;
    * @see javax.ejb.SessionSynchronization#afterBegin()
    public void afterBegin() {
    * @see javax.ejb.SessionSynchronization#afterCompletion(boolean)
    public void afterCompletion(boolean committed) {
    * @see javax.ejb.SessionSynchronization#beforeCompletion()
    public void beforeCompletion() {
    * See section 7.10.3 of the EJB 2.0 specification
    public void ejbCreate() {
              Properties p = new Properties();
              p.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
              try{
         ctx = new InitialContext(p);
         catch(Exception e) {System.out.println("Create Exception "+e.toString());}
    }

  • WLS 10 - When Session Bean calls another, original Exception is lost?

    I have a Stateless Session Bean that makes a call on another one. If an exception is thrown in that 2nd bean, the 1st bean receives an EJBTransactionRolledbackException back from it, but the original Exception that caused it is NOT wrapped by the EJBTransactionRolledbackException, but merely mentioned in that Exception's message.
    If another object - eg. a Servlet - calls one of these beans, the EJB exception contains the original exception wrapped.
    Why would the original exception be lost in the 1st case, but missing in the 2nd? Is this a bug?
    - Tim

    Your remote client passes a DefaultSession to AdminSession.initialize(..). This DefaultSession has to be a remote type. In your client, how does it get DefaultSession?
    Did your client look up DefaultSession, and have it return a (sessionContext.getBusinessObject(DefaultSession.class))? If so, it should work.

Maybe you are looking for