2 Replies Latest reply on Nov 27, 2001 8:54 AM by Mark Desrosier

    EJB External Reference Issue

    Tom Innes Newbie

      We have two jar files each containing their own EJB's. The first jar file CustomerMaintenance calls a session bean in the second jar file SequenceGenerator. We have followed the instructions in the jboss documentation about external ejb references and yet we get a NoClassDefFoundError. Here are our ejb-jar.xml files and our jboss.xml files as well as the stack trace from the server. Can anyone help????

      PS We have been able to get these beans talking to each other using Borland Application Server.


      CustomerMaintenance
      ejb-jar.xml


      <?xml version="1.0" encoding="Cp1252"?>

      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

      <ejb-jar>
      <enterprise-beans>

      <ejb-name>Org_customer_address</ejb-name>
      customermaintenance.server.Org_customer_addressHome
      customermaintenance.server.Org_customer_address
      <ejb-class>customermaintenance.server.Org_customer_addressBeanBMP</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>ejb/Org_province</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      customermaintenance.server.Org_provinceHome
      customermaintenance.server.Org_province
      <ejb-link>Org_province</ejb-link>
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      <ejb-name>Org_province</ejb-name>
      customermaintenance.server.Org_provinceHome
      customermaintenance.server.Org_province
      <ejb-class>customermaintenance.server.Org_provinceBeanBMP</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>ejb/Org_customer_address</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      customermaintenance.server.Org_customer_addressHome
      customermaintenance.server.Org_customer_address
      <ejb-link>Org_customer_address</ejb-link>
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      <ejb-name>CustomerMaintenanceSession</ejb-name>
      customermaintenance.server.CustomerMaintenanceSessionHome
      customermaintenance.server.CustomerMaintenanceSession
      <ejb-class>customermaintenance.server.CustomerMaintenanceSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/Org_customer_address</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      customermaintenance.server.Org_customer_addressHome
      customermaintenance.server.Org_customer_address
      <ejb-link>Org_customer_address</ejb-link>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>SequenceGeneratorSession</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      sequencegenerator.SequenceGeneratorSessionHome
      sequencegenerator.SequenceGeneratorSession
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>CustomerMaintenanceSession</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>Org_province</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>Org_customer_address</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      Customer Maintenance
      jboss.xml

      <?xml version="1.0" encoding="Cp1252"?>


      <enterprise-beans>

      <ejb-name>Org_customer_address</ejb-name>
      <bean-home-name>Org_customer_address</bean-home-name>
      <ejb-ref>
      <ejb-ref-name>ejb/Org_province</ejb-ref-name>
      <jndi-name>Org_province</jndi-name>
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <jndi-name>DataSource</jndi-name>
      </resource-ref>


      <ejb-name>Org_province</ejb-name>
      <bean-home-name>Org_province</bean-home-name>
      <ejb-ref>
      <ejb-ref-name>ejb/Org_customer_address</ejb-ref-name>
      <jndi-name>Org_customer_address</jndi-name>
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <jndi-name>DataSource</jndi-name>
      </resource-ref>


      <ejb-name>CustomerMaintenanceSession</ejb-name>
      <bean-home-name>CustomerMaintenanceSession</bean-home-name>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <jndi-name>DataSource</jndi-name>
      <cmp-resource>False</cmp-resource>
      </resource-ref>
      <ejb-ref>
      <ejb-ref-name>SequenceGeneratorSession</ejb-ref-name>
      <jndi-name>jnp://192.168.1.1:1099/ejb/SequenceGeneratorSession</jndi-name>
      </ejb-ref>

      </enterprise-beans>
      <datasource-definitions>

      <jndi-name>DataSource</jndi-name>
      jdbc:postgresql://192.168.1.1/rev1
      postgres
      foo
      <driver-class-name>org.postgresql.Driver</driver-class-name>

      </datasource-definitions>



      Sequence Generator
      ejb-jar.xml

      <?xml version="1.0" encoding="Cp1252"?>

      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

      <ejb-jar>
      <enterprise-beans>

      <ejb-name>Key_sequence</ejb-name>
      sequencegenerator.Key_sequenceHome
      sequencegenerator.Key_sequence
      <ejb-class>sequencegenerator.Key_sequenceBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-field>
      <field-name>sequence_name</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>start_sequence</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>next_value</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>max_sequence</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>block_size</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>increment_by</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>roll_over</field-name>
      </cmp-field>
      <primkey-field>sequence_name</primkey-field>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      <ejb-name>SequenceGeneratorSession</ejb-name>
      sequencegenerator.SequenceGeneratorSessionHome
      sequencegenerator.SequenceGeneratorSession
      <ejb-class>sequencegenerator.SequenceGeneratorSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>Key_sequence</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      sequencegenerator.SequenceGeneratorSessionHome
      sequencegenerator.SequenceGeneratorSession
      <ejb-link>SequenceGeneratorSession</ejb-link>
      </ejb-ref>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>Key_sequence</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>SequenceGeneratorSession</ejb-name>
      <method-name>getNextSequence</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      Sequence Generator
      jboss.xml

      <?xml version="1.0" encoding="Cp1252"?>



      <enterprise-beans>

      <ejb-name>Key_sequence</ejb-name>
      <bean-home-name>Key_sequence</bean-home-name>
      <resource-ref>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <jndi-name>DataSource</jndi-name>
      </resource-ref>
      <cmp-info>
      <database-map>
      key_sequence
      </database-map>

      <method-signature>findAll()</method-signature>
      <where-clause />
      <load-state>True</load-state>

      </cmp-info>


      <ejb-name>SequenceGeneratorSession</ejb-name>
      <bean-home-name>SequenceGeneratorSession</bean-home-name>
      <jndi-name>SequenceGeneratorSession</jndi-name>

      </enterprise-beans>
      <datasource-definitions>

      <jndi-name>DataSource</jndi-name>
      jdbc:postgresql://192.168.1.1/rev1
      postgres
      foo
      <driver-class-name>org.postgresql.Driver</driver-class-name>

      </datasource-definitions>



      Stack Trace

      3.2.3/jboss/deploy/CustomerMaintenance.jar
      [J2EE Deployer Default] Deploy J2EE application: file:/app/JBoss-2.4.3_Tomcat-3.2.3/jboss/deploy/CustomerMaintenance.jar
      [J2eeDeployer] Create application CustomerMaintenance.jar
      [J2eeDeployer] install EJB module CustomerMaintenance.jar
      [Container factory] Deploying:file:/app/JBoss-2.4.3_Tomcat-3.2.3/jboss/tmp/deploy/Default/CustomerMaintenance.jar
      [Verifier] Verifying file:/app/JBoss-2.4.3_Tomcat-3.2.3/jboss/tmp/deploy/Default/CustomerMaintenance.jar/ejb1002.jar
      [Verifier]
      Bean : Org_customer_address
      Method : public abstract Org_customer_address findByPrimaryKey(Integer) throws FinderException, RemoteException
      Section: 9.2.8
      Warning: All the exceptions defined in the throws clause of an ejbFind method of the entity bean class must be included in the throws clause of the matching find method of the home interface.

      [Verifier] Org_customer_address: Verified.
      [Verifier]
      Bean : Org_province
      Method : public abstract Org_province findByPrimaryKey(Integer) throws FinderException, RemoteException
      Section: 9.2.8
      Warning: All the exceptions defined in the throws clause of an ejbFind method of the entity bean class must be included in the throws clause of the matching find method of the home interface.

      [Verifier] Org_province: Verified.
      [Verifier] java.lang.NoClassDefFoundError: sequencegenerator/SequenceGeneratorSessionHome
      [Verifier] at java.lang.Class.getMethods0(Native Method)
      [Verifier] at java.lang.Class.getMethods(Class.java:742)
      [Verifier] at org.jboss.verifier.strategy.AbstractVerifier.hasEJBCreateMethod(AbstractVerifier.java:443)
      [Verifier] at org.jboss.verifier.strategy.EJBVerifier11.verifySessionBean(EJBVerifier11.java:567)
      [Verifier] at org.jboss.verifier.strategy.EJBVerifier11.checkSession(EJBVerifier11.java:93)
      [Verifier] at org.jboss.verifier.BeanVerifier.verify(BeanVerifier.java:134)
      [Verifier] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:467)
      [Verifier] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:369)
      [Verifier] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:304)
      [Verifier] at java.lang.reflect.Method.invoke(Native Method)
      [Verifier] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Verifier] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Verifier] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:494)
      [Verifier] at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:468)
      [Verifier] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:208)
      [Verifier] at java.lang.reflect.Method.invoke(Native Method)
      [Verifier] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Verifier] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Verifier] at org.jboss.ejb.AutoDeployer.deploy(AutoDeployer.java:379)
      [Verifier] at org.jboss.ejb.AutoDeployer.run(AutoDeployer.java:217)
      [Verifier] at java.lang.Thread.run(Thread.java:484)


      Tom

        • 1. Re: EJB External Reference Issue
          Luke Studley Newbie

          Hiya Tom

          I had this problem. I'm no expert but as I understand it ejb-ref's will only resolved if the beans are in the same application unit. In you r case you have 2 separate jars so it will not be automatically resolved - you should be able to pick the bean up using the main JBoss JNDI and not the java:comp/env one.

          If you put your 2 jars in a EAR file then the depolyer wuold resolve the dependencies between the 2 files (I believe)

          Luke

          • 2. Re: EJB External Reference Issue
            Mark Desrosier Newbie

            You must include the remote interface class and home class either 1) in the calling jar, or 2) in a jar in the JBoss classpath.

            We elected to create a client jar that is put in lib/ext directory.