Hello

I am having a problem with a simple entity bean which uses
TX_NOT_SUPPORTED as its transaction attribute.  It is a
serial number generator, and I am using 
bean managed persistence.

A bean instance can be loaded, and methods called without
problem.  But when the bean is to be persisted (either on
shutdown/synchronization via jonasadmin,  or 
due to the passivation-timeout expiring), an exception
occurs in my ejbStore method when I try to get a Connection
from the DataSource.  The following 
exception is thrown :-

javax.naming.NameNotFoundException: No context for this
component
 at
org.objectweb.jonas.naming.java.javaURLContext.findContextFor(javaURLContext.java:122)
 at
org.objectweb.jonas.naming.java.javaURLContext.lookup(javaURLContext.java:163)
 at
javax.naming.InitialContext.lookup(InitialContext.java:350)
 at
test.SerialNumberBean.getConnection(SerialNumberBean.java:134)
 at test.SerialNumberBean.ejbStore(SerialNumberBean.java:98)
 at
org.objectweb.jonas_ejb.container.EntityContextImpl.storeIfModified(EntityContextImpl.java:282)
 at
org.objectweb.jonas_ejb.container.EntityContextImpl.passivate(EntityContextImpl.java:328)
 at
org.objectweb.jonas_ejb.container.ContextSwitch.passivateIH(ContextSwitch.java:274)
 at
org.objectweb.jonas_ejb.container.JBeanEntity.passivateIH(JBeanEntity.java:342)
 at
org.objectweb.jonas_ejb.container.JEntityHome.passivateAllIH(JEntityHome.java:357)
 at
org.objectweb.jonas_ejb.container.JContainerImpl.syncAll(JContainerImpl.java:257)
 at
org.objectweb.jonas_ejb.container.JContainerImpl.swapper(JContainerImpl.java:208)
 at
org.objectweb.jonas_ejb.container.Swapper.run(JContainerImpl.java:67)

The bean behaves perfectly if its transaction attribute is
"Required" rather than "NotSupported".

Looking at Jonas's trace output, it seems that the
"component context" is being reset to null after the
instance is loaded via ejbLoad.  Then, when it is requested
later Jonas complains with the above exception because it is
null. 

I am using Jonas 2.2.7, jdk 1.3.0.

My deployment descriptors are pretty standard :-

<!DOCTYPE jonas-ejb-jar SYSTEM "jonas-ejb-jar.dtd">
<jonas-ejb-jar>
  <jonas-entity>
    <ejb-name>SerialNumberBean</ejb-name>
    <passivation-timeout>5</passivation-timeout>
    <jndi-name>SerialNumberHome</jndi-name>
    <jonas-resource>
      <res-ref-name>jdbc/TestDataSource</res-ref-name>
      <jndi-name>jdbc_2</jndi-name>
    </jonas-resource>
  </jonas-entity>
</jonas-ejb-jar>

and

<!DOCTYPE ejb-jar SYSTEM "ejb-jar_1_1.dtd">
<ejb-jar>
  <enterprise-beans>
    <entity>
      <description>Deployment descriptor for the Agent
bean</description>
      <display-name>SerialNumberBean</display-name>
      <ejb-name>SerialNumberBean</ejb-name>
      <home>test.SerialNumberHome</home>
      <remote>test.SerialNumber</remote>
      <ejb-class>test.SerialNumberBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>False</reentrant>
      <resource-ref>
 <res-ref-name>jdbc/TestDataSource</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
      </resource-ref>
    </entity>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      <method>
 <ejb-name>SerialNumberBean</ejb-name>
 <method-name>*</method-name>
      </method>
      <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>

And my method of getting the DataSource is as follows :-

   private Connection getConnection() {
      try {
         // Finds DataSource from JNDI
         Context initialContext = new InitialContext();
         DataSource d =
(DataSource)initialContext.lookup("java:comp/env/jdbc/TestDataSource");
         return d.getConnection();               <<< this is
where the exception is thrown on an ejbStore when
passivated.
      } catch (NamingException e) {
         e.printStackTrace();
         throw new EJBException(e);
      } catch (SQLException e) {
         e.printStackTrace();
         throw new EJBException(e);
      }
   }

I've also put all the source and other files needed to
reproduce the problem in a zip file at the following
location :-

http://www.parlett.dial.pipex.com/ejbprob/files.zip

Thanks for your anticipated help.


R P  Parlett
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to