Obtaining PersistenceManager from Session Bean in JBoss 3.0.4

Hi,
I'm attempting to use the JCA for JBoss with Kodo 2.4.0. The kodo.rar seems to deploy ok:
2002-12-18 11:19:43,640 INFO [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] Bound connection factory for resource adapter 'KodoJDO' to JNDI name 'java:/kodo'
2002-12-18 11:19:43,640 INFO [org.jboss.resource.connectionmanager.LocalTxConnectionManager] Started
2002-12-18 11:19:43,640 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/kodo.rar
In my session bean, I access the PersistenceManager using the following code:
InitialContext context _ new InitialContext();
JDOConnectionFactory factory _ (JDOConnectionFactory)context.lookup("java:/kodo");
PersistenceManager pm _ (PersistenceManager)factory.getConnection();
The code generates a JDOFatalDataStoreException when I try to execute it:
Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac; - nested throwable: (javax.resource.ResourceException: Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac)
And when I execute it a second time around, it seems to retrieve the PersistenceManager ok, but when I try to invoke methods on it, I get an SQLException:
Connection is broken: Software caused connection abort: socket write error
at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newDataStoreId(JDBCStoreManager.java:464)
     at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(PersistenceManagerImpl.java:1107)
     at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:1059)
     at org.aims.his.ejb.PatientBean.createPatient(PatientBean.java:117)
     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:178)
     at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
     at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
     ... 47 more
So...what did I miss? Could it be the configuration of my connection to the database in kodo-service.xml (see attached)? In the server log files I didn't see any of my connection properties.
Any help is appreciated.
Thanks,
Jeff

Ok, looks like it was the kodo-service.xml file. I removed the ConnectionFactoryName entry and most of the options were commented out which I didn't catch...
Thanks,
Jeff
"Jeff Carnegie" <[email protected]> wrote in message news:[email protected]...
Hi,
I'm attempting to use the JCA for JBoss with Kodo 2.4.0. The kodo.rar seems to deploy ok:
2002-12-18 11:19:43,640 INFO [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] Bound connection factory for resource adapter 'KodoJDO' to JNDI name 'java:/kodo'
2002-12-18 11:19:43,640 INFO [org.jboss.resource.connectionmanager.LocalTxConnectionManager] Started
2002-12-18 11:19:43,640 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/kodo.rar
In my session bean, I access the PersistenceManager using the following code:
InitialContext context _ new InitialContext();
JDOConnectionFactory factory _ (JDOConnectionFactory)context.lookup("java:/kodo");
PersistenceManager pm _ (PersistenceManager)factory.getConnection();
The code generates a JDOFatalDataStoreException when I try to execute it:
Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac; - nested throwable: (javax.resource.ResourceException: Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac)
And when I execute it a second time around, it seems to retrieve the PersistenceManager ok, but when I try to invoke methods on it, I get an SQLException:
Connection is broken: Software caused connection abort: socket write error
at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newDataStoreId(JDBCStoreManager.java:464)
at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(PersistenceManagerImpl.java:1107)
at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:1059)
at org.aims.his.ejb.PatientBean.createPatient(PatientBean.java:117)
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:178)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
... 47 more
So...what did I miss? Could it be the configuration of my connection to the database in kodo-service.xml (see attached)? In the server log files I didn't see any of my connection properties.
Any help is appreciated.
Thanks,
Jeff

Similar Messages

  • URGENT ! JDEV 10.1.2 Problem with data control generated from session bean

    I got a problem with data control generated from session bean which return a collection of data transfer object.
    The dto's seem to be correct. The session bean load correctly the data into and the object's are plenty of data. Using the console to display the dto content is ok.
    When generating a data control from this session bean and associate the dto included in the collection only the first object level and one-to-one dto object are correctly setted in the data control. Object that represent collection into the dto (one-to-many foreign key) are setted as collection with an iterator but the structure of the object is not setted. I don't know how to associate this second level of collection with the dto bean class to obtain the attributes definition.
    I created a case with hr schema like the hrApp demo application in the tutorial with departments and employees table. I got the same problem.
    Is it a bug ?
    It exists a workaround to force the data control to understand the collection data structure ?
    Help is welcome ! this is urgent !!!

    we found the problem by assigning the child dto bean class to the node representing the iterator in the xml file corresponding to the master dto.

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • How to send message to MessageDrivenBean from Session bean in JDeveloper

    HI I am trying to write a sample program using JDeveloper.
    I am trying to do these steps
    1) client class which gets Session bean and calls its method.
    2) write Stateless Session bean with a method which gets MDB and sends message.
    3) write Message Driven Bean ( which prints message recieved from Session bean )
    Set up
    =======
    jms.xml
    {JDevHome}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml : changed jms.xml file and included
         <topic name="Demo Topic" location="jms/theTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    orion-ejb-jar.xml:
    edited MDB entry to
    <message-driven-deployment name="MessageLogger"
    destination-location="jms/theTopic" connection-factory-location="jms/theTopicConnectionFactory">
    </message-driven-deployment>
    Implementation
    ===============
    In client class:
    I am getting session bean like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.rmi.RMIInitialContextFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:23891/current-workspace-app");
    Context ctx = new InitialContext(props);
    MySessionHome home = (MySessionHome)
              javax.rmi.PortableRemoteObject.narrow(obj, MySessionHome.class);
    This part works fine, and I am calling method on session bean created out of home.
    In Session bean:
    I want to get TopicConnectionFactory and tried these two ways:
    a)
    getting the context by setting new environemnt values like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.jms.EvermindConnectionFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:9227/current-workspace-app");
    Context ctx = new InitialContext( props);
    When I try this,it is complaining that it cannot instantiate EvermindConnectionFactory.
    I am not sure which factory class we have to use here.i tried all the Factory class in that package.but didn't worked.
    next I used,
    b)
    tried to use default context in session bean to get MDB factory
    String TOPIC_NAME="jms/theTopic";
    String TOPIC_CONNECTION_FACTORY="jms/theTopicConnectionFactory";
    TopicConnectionFactory connectionFactory = (TopicConnectionFactory)new InitialContext().lookup("java:comp/env/" + TOPIC_CONNECTION_FACTORY);
    this gives
    04/06/13 23:46:09 javax.naming.NameNotFoundException: jms/theTopicConnectionFactory not found in MySession
    04/06/13 23:46:09      at com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:93)
    this may be because JMS server runs on different port than other EJBs and have different namespaces.
    Can any body give info,how we can make use of Message Driven bean from a Session Bean or from a JSP page or from a simple class inside JDeveloper.
    Thanks in advance.
    gopal

    Hi,
    There are some hints in this forum for how to do this.
    I put together and make it working.
    This example creates an MD Bean and have a simple message and a client class send messages to that bean.
    Steps
    =====
    1)
    a)in {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml
         <topic name="Demo Topic" location="jms/demoTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    b) in current project in orion-ejb-jar.xml
    go to orion-ejb-jar properties and add these values there to MDB node
    destination-location=jms/demoTopic
    connection-factory-location=jms/theTopicConnectionFactory
    2) create a dummy session bean and a dummy client for that session bean
    This sets default configuration for the client application we write
    doing so we do not need to set properties to get Initial context.It makes use of
    {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\.client\jndi.properties
    We can directly get Contexxt ctx = new InitialContext();
    3) Create MDB and put this sample code in method
    onMessage()
    TextMessage tm = (TextMessage) msg;
    try {
    String text = tm.getText();
    System.err.println("Received new message : " + text);
    catch(JMSException e) {
    e.printStackTrace();
    4) go to properties for the MDB and set Destination to Topic
    5) write Client code
    Context ctx =new InitialContext();
    // 1: Lookup ConnectionFactory via JNDI
    TopicConnectionFactory factory =     
    (TopicConnectionFactory) ctx.lookup("jms/theTopicConnectionFactory");
    // 2: Use ConnectionFactory to create JMS connection
    TopicConnection connection = factory.createTopicConnection();
    // 3: Use Connection to create session
    TopicSession session = connection.createTopicSession( false, Session.AUTO_ACKNOWLEDGE);
    // 4: Lookup Desintation (topic) via JNDI
    Topic topic = (Topic) ctx.lookup("jms/demoTopic");
    // 5: Create a Message Producer
    TopicPublisher publisher = session.createPublisher(topic);
    // 6: Create a text message, and publish it
    TextMessage msg = session.createTextMessage();
    msg.setText("This is a test message from My Test Client!!! .");
    publisher.publish(msg);
    6) Run the server and run the client

  • Deploying App Module as EJB Session Bean to JBoss

    I am attempting to follow the How-To at
    http://otn.oracle.com/products/jdev/howtos/appservers/deploy_bc4j_to_jboss.html for deploying BC4J to JBoss. In particular, I was looking at the section 'BC4J as an EJB Session Bean', because that is the route we would like to take.
    The document instructs you to create a business components deployment profile.. ok, done.
    It then instructs you to copy the app module configuration that was just created and rename it. However, the editor will not let you rename the configuration.
    Then when 'Creating a JSP to Access Your Application Module as a EJB', the wizard to create the JSP will not allow you to select the app module configuration that was just created. It only shows the Local configuration.
    What am I doing wrong? I am using JDeveloper 9.0.3.1.
    My ultimate goal is to take an existing BC4J/JSP application and deploy the app module as an EJB, so the JSP and EJB can reside on separate machines.
    Any pointers that anyone can give me about deploying an app module as a Session Facade (BMT) to JBoss, with a JSP front end, is greatly appreciated. I have read the how-tos available from OTN. I have relatively little experience with EJB, so please forgive me if there's something obvious I'm missing.
    Thanks!!!

    Can this be solved by application module pooling? How
    can we use the PoolMgr to work with the session
    beans?You can use a stateless checkout/checkin appmodule.
    Take a look at the following help topics which explain this in good detail.
    "About Application Module Pooling"
    "About JSP Pages and Application Module Pooling"
    The pool can help reuse the appmodule instance across requests thus reducing the number of concurrent db sessions.
    Dhiraj

  • Direct DB access from Session Bean w/o using Serialized Objects

    I am developing a system where I am receiving some messages (data ) inside session bean and I want to log that data into data base �.i.e inserting that data in to various tables. I am not showing that data to client ( that is taken care by another application).
    So I am directly calling insert methods on various tables instead of going for serialized classes for each of that tables and calling setter methods. Is this approach correct? Or this will create nightmares when millions of messages are to be logged? Do I have to make serialized objects? Please post the suggestions ..Thank you in advance.
    If session bean is making direct inserts in the DB using Helper classes as shown below �is there any problem of concurrency?? Means multiple session bean instances inserting data in the same table using the helper class will create any problems?? I am using MySql db presently. Or all will work fine coz I am using the data source and pool available in welogic app server?
    Is this a good approach if my application is doing inserts 90% of times? or I have to use entity beans or serialized objects encapsulating each class?
    public class Logger implements SessionBean
    DAO dao = getDAO();
    dao.insertXyzLog(�x�, �y�,�.);
    private DAO getDAO(){
    if(Dao == null) {
    oao = DAOFactory.getDAO();
    return Dao;
    //other std methods
    public interface DAO {
    // methods to directly insert data in to the tables
    //some methods to look for required value in another tables
    public abstract void insertXyzLog (String x, Stringy, ���.);
    public class DAOImpl implements DAO {
    // look up for JNDI data sourse
    //method to return connection
    public void insertXyzLog (String x, Stirng y�){
    //SQLs for inserting into Xyz table using connection obtained above.

    Hi,
    Nothing wrong in using Helper class to insert into table. It won't create problem as long as your database server able to handle that many request from client.
    If you use weblogic server and datasource, the server will take care of all connection pool management depending upon your configuration parameters.
    Moreover, insert won't lock the table. So you need not worry about those things.
    Best Luck,
    Senthil Babu
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Problem calling entity bean from session bean using sun one app server

    Hi,
    I am getting the following exception while calling entity bean(bmp) from stateless session(cmp)bean.
    SEVERE: IOP5012: Some runtime exception ocurred in IIOP: [javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: Unable to create reference org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 1015 completed: No]
    SEVERE: IOP5013: Unable to create reference: [org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 1015 completed: No]
    SEVERE: EJB5029: Exception getting ejb context : [CustomerEJB]
    SEVERE:
    WARNING: CORE3283: stderr: javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 9998 Maybe; nested exception is:
    WARNING: CORE3283: stderr: org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
    WARNING: CORE3283: stderr: at com.sun.corba.ee.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDelegate.java:114)
    WARNING: CORE3283: stderr: at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:358)
    WARNING: CORE3283: stderr: at javax.rmi.CORBA.Util.wrapException(Util.java:277)
    WARNING: CORE3283: stderr:
    My primary key implementation is
    public class CustomerEJBKey implements java.io.Serializable {
    static final long serialVersionUID = 3206093459760846163L;
    public String customerId;
    public DBConfigBean dbConfigBean;
    * Creates an empty key for Entity Bean: CustomerEJB
    /*public CustomerEJBKey() {
    public CustomerEJBKey(String customerId,DBConfigBean dbConfigBean){
    this.customerId = customerId;
    this.dbConfigBean = dbConfigBean;
    public String getCustomer(){
    return customerId;
    public DBConfigBean getDBConfigBean(){
    return dbConfigBean;
    * Returns true if both keys are equal.
    public boolean equals(Object key) {
    if(key instanceof CustomerEJBKey)
    return this.customerId.equals(((CustomerEJBKey)key).customerId) &&
    this.dbConfigBean.equals(((CustomerEJBKey)key).dbConfigBean);
    else
    return false;
    * Returns the hash code for the key.
    public int hashCode() {
    return customerId.hashCode() + dbConfigBean.hashCode();
    and entity bean method invocation is,
    homeFactory = EJBHomeFactory.getInstance();
    home = (CustomerEJBHome) homeFactory.lookup(CustomerEJBHome.class);
    remote = (CustomerEJB) PortableRemoteObject.narrow( home.findByPrimaryKey(new CustomerEJBKey(customerId,dbBean)), CustomerEJB.class);
    This works fine in Websphere and JBoss. Do you have any idea why I am getting this exception?
    Appreciate your response.
    Regards,
    Sankar.

    My suggestion is to put some System.out.println() statements and see if the output helps in any way in debugging. I can't think of anything on the top of my head although I have been working lightly on SunONE.
    By the way, you referred the stateless bean as CMP. Just wanted to tell you that you are wrong. The terms CMP and BMP refer to persistence, which is applied to Database tables and not to stateless/stateful session beans which are written for some specific purpose independent of underlying database.

  • Problem invoking gogle web service from session bean

    Hello
    I have developed a Web-Client which consumes the google-WebService with Apache Axis. I have generated the corresponding classes with WSDL2Java and the client works without problems. A little code fragment from my client:
    GoogleSearchService service = new GoogleSearchServiceLocator();
              // Now use the service to get a stub to the Service Definition Interface (SDI)
              GoogleSearchPort google = service.getGoogleSearchPort();
             GoogleSearchResult googleSearchResult =  google.doGoogleSearch(GOOGLE_KEY, // java.lang.String key
                           q.toString(), //java.lang.String q
                           0, // int start
                           10, // int maxResults
                           false, //boolean filter
                           "", // java.lang.String restrict      
                           false, //boolean safeSearch              
                           "lang_ja|lang_en", // java.lang.String lr
                           "UTF-8", // java.lang.String ie
                           "UTF-8"); // java.lang.String oeNow I have to put the Web-Client in a SessionBean. Therfore I defined the code of the web-client in a method and put it into a stateless session bean and wrote a client for the session bean. But when the session bean invokes the corresponding method for consuming the google web service, there always occurs the following error:
    [java] Exception in thread "main" java.rmi.ServerError: Unexpected Error; nested exception is:
    [java] java.lang.NoClassDefFoundError: GoogleSearch/GoogleSearchService
    But I have definitely all necessary classes in my classpath, like GoogleSearchService, etc. So all necessary classes are available. And the code to conume the web service als works because as said I tested it with a web-client.
    Has anybody an idea what went wrong here? Is there anything important when I a web service is invoked by a session bean??:(
    regards
    pat

    Has nobdy an idea?? :(( I tried for such a long time but I was not able to fix this problem....:(
    Please help...

  • Generating web service from session bean

    Hi
    I have a session bean in one project which has a service-endpoint defined.
    My web services are in another project entirely, within the same workspace if that helps any.
    When I generate the web service from the EJB JDev turns the business tier project into a web project,
    I don't see any options to include the web service in the web project.
    I've reversed all of the changes, but wonder if I shouldn't redo it and copy the mapping file and configuration
    across to the web project and reverse the changes in the business tier.
    This is a workaround that I'm hoping to avoid, as I'm doing the "howto" for this in our project.
    How is this normally done?

    I tried generating the web servioce from WSDL, in the web project.
    I tested and the web service works fine.
    Then I changed the config file to point to the ejb, but the server won't start up....
    *08/09/17 10:58:40 WARNING: Application.setConfig Application: current-workspace-app is in failed state as initialization failed.*
    This is the webservices.xml bit I updated...
         <ejb-link>SomeOrOtherEjbName</ejb-link> The bit I found in webservices.xml when the service is in the business tier.
    <!-- <servlet-link>SomeOrOtherWebServiceSoapHttpPort</servlet-link> --> The service that works in the web tier.

  • Calling stored procedure from session bean method

    I have a situation like this :
    I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
    session bean method start
    store some data in tables(using my OR layer)
    call the stored procedure
    session bean method end
    My question is :
    Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
    secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
    Thanks
    Vimal

    Hi Vimal,
    Will the data that I am storing in tables from within
    the session bean method, be available to the code
    executing inside stored proc.There's only one way to find out (isn't there?)
    secondly, how do I sync the transcation which is
    being initiated by the container with the transaction
    under which the stored proc is executing or is it
    that the stored procedure code will also be executing
    under the container managed transcation.Again, why not just "suck it and see!"
    [Or is there some reason why you can't?]
    As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
    In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
    However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
    Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
    Hope this has helped.
    Good Luck,
    Avi.

  • Database access from session bean

    Hello,
    I have a stateless session bean which performs some complex
    calculations, and also does some database access.
    For the database access the bean class has a datasource as
    follows:
    public class TestBean implements SessionBean {
    private DataSource ds_;
    public void ejbCreate() {
         getDataSources();
    private void getDataSources() {
         try {
         Context ictx = new InitialContext();
         ds_ = (DataSource)ictx.lookup("java:comp/env/jdbc/TestDB");
         } catch (Exception e) {
         e.printStackTrace();
         throw new EJBException(e);
    Now this class has a method (which is also in the remote interface)
    calculateSomething(). This method constructs a number of other
    objects that do the actual calculation, and one of these objects
    does the actual database access. How would another object be able to
    use the datasource that was constructed in the bean class?
    I could pass the datasource reference to that object, but that would
    break my encapsulation. This is because that object does not get
    created directly by the bean object, but rather the way the objects
    interact is something like A -> B -> C, where A is the TestBean, and
    C is the object that does the DB access. If I passed the datasource,
    I would need to make B aware of the datasource, which doesn't
    seem good design, because B doesn't do any database access.
    Alternatively I could do the lookup in class C, but that would
    degrade the performance, as an object C gets created and destroyed
    every time the calculateSomething() method is called.
    A third option I have thought of, is to add a public method to the
    bean that returns a connection. Whenever another object gets
    created, a reference to the bean object will be passed along. Then,
    if another object needs to do database access, it will call back
    the bean to get a connection. This seems just as bad (if not worse)
    than the first option.
    Does anyone have an elegant solution for this situation? What is
    the best practice of handling datasources when a bean class doesn't
    do the database access itself? In all the examples I've seen so far,
    all the functionality was in the session bean class, but again that
    doesn't seem good OO design, and would result in a single huge class.
    regards,
    Kostas

    Thanks again to both for the replies. Here are my responses:
    Yi Lin: Yes, I know that an entity bean would solve this problem, however it has been decided not to use entity beans so this is not my call (I think the reason entity beans are not allowed in this project is that they are considered risky: there are other applications that access the same database, so if the container caches entity bean data as you describe, then the users might get inconsistent results).
    Gerard: Actually object B is the one that has the business logic and C is a peer object that only does database access and no calculaitons. For example B can be Customer, and C CustomerDB. This is why object B does not have any knowledge of datasources or connections. So my design does not appear to be that bad!
    As far as the factory you propose is concerned, I cannot understand how this would solve my problem. In order to solve this situation the factory would need to be persistent, i.e. get created by the ejbCreate() method, and destroyed whenever the container decides to destroy the bean. There would be no point in object C creating the factory, as I would have the overhead of doing the JNDI lookup every time I create a C.
    So the question remains the same: how would I pass a reference to the factory from A to C without making B aware of it?

  • Calling Data Control from Session bean

    Is it possible to use workshop data control from with in Session bean.

    If the client code is located in the same "deployment unit" (e.g. EAR
    file) as the EJBs, then you can pass the data by reference.
    Serialization is required when crossing between deployment units. This
    is required to support redeployment.
    Hyung-Jin Kim wrote:
    I recently downloaded WL6.0 and I noticed that when a
    session bean returns data to its client, the data is
    always serialized back the client -- EVEN it the client
    is on the same machine. Ideally, I would prefer that a
    reference to the data simply be returned to the client.
    Does the serialization occur because WL6.0 put session
    beans in its own ClassLoader or does the serialization occur
    because of the way WL6.0 compiles the RMI stubs? Thanks
    for your response.
    -hjk

  • NoSuchObjectException from Session bean wrapper

    Hi,
    I am getting the following exception when accessing a session bean.
    The exception is thorwn from a method of a statful session bean. The lines before and after the particular line are exceuted properly
    public void cloneBasket(eprcBasketSF pDestinationBkt) throws RemoteException{
    pDestinationBkt.setIsJobValid(this.m_IsBktJobValid);
    pDestinationBkt.setIsAppValid(this.m_IsBktAppValid);
    pDestinationBkt.setIsSubValid(this.m_IsBktSubValid);
    pDestinationBkt.setIsPOValid(this.m_IsBktPOValid);
    pDestinationBkt.setIsEdaValid(this.m_IsBktEdaValid);
    pDestinationBkt.setIsIdaValid(this.m_IsBktIdaValid);
    //** Exception is thrown at this line only
    pDestinationBkt.setBasketLines(this.m_bktLines);
    pDestinationBkt.setDeletedBasketLines(cloneDeletedBasketLines());
    java.rmi.NoSuchObjectException: Session has timed out
    at com.evermind.server.ejb.StatefulSessionEJBObject.throwPassivisationEx
    ception(.:215)
    at eprcBasketSF_StatefulSessionBeanWrapper3.cloneBasket(eprcBasketSF_Sta
    tefulSessionBeanWrapper3.java:469)
    at com.comp.eProcurement.eprcCore.eprcBasketJBean.cloneBasket(eprcBaske
    tJBean.java:58)
    at com.comp.eProcurement.eprcCore.eprcBasketTemplateManager.retrieveBas
    ketByKey(eprcBasketTemplateManager.java:1471)
    at com.comp.eProcurement.eprcCore.eprcBasketTemplateManager.getCurrentB
    asket(eprcBasketTemplateManager.java:598)
    at com.comp.eProcurement.eprcCore.eprcEprocSession.passivate(eprcEprocS
    ession.java:953)
    We are using orion server 1.5.3. Can any body tell me what could be causing this problem.
    Thanks in advance
    karthi

    Hi,
    I got an exact same error. I'm using Oracle 9i App Server, but it's based on Orion server, which you're using.
    When I try to use stateful session bean, I also got "Session has timed out" error at the exact same point (com.evermind.server.ejb.
    StatefulSessionEJBObject.throwPassivisationException).
    I have no clue, either. My session bean worked fine bofore, but after I updated records in the database, then something went wrong. First, I thought database connection problem or something, but it's definitely not.
    If you find out the problem, please post it here or send me email below.
    [email protected]
    If I figure it out, I'll post it here, too.
    thanks.
    -tom

  • Working list from Session Bean

    In a method of a session bean, I need to get the list of tasks of a user from the TaskManager service of BPEL. I can not find any sample in Web, so if anyone can help me, I appreciate it.
    I am using the JDeveloper 10.1.3.1.

    can u list the entire source for the method...

  • Calling a web service from Session bean

    Hi Experts,
    Can anybody help in calling a web serivce frm a session bean's business method??
    Hw do we do that?
    I have one requirement where i want to send emails to set of users for which i have email sending web service ready.. How can i call it thru a session bean's business method???
    Pls help,
    Regards,
    Amey

    Hi Amey,
    This documents explains how to use an EJB as Web service endpoint: http://help.sap.com/saphelp_nwce10/helpdata/en/46/307a6c50094f09e10000000a114a6b/frameset.htm
    I hope this helps.
    Best regards,
    Ekaterina

Maybe you are looking for