Discussions

General J2EE: Can't make an external EJB reference with JBoss

  1. I'm using JBoss 2.4.4 with Tomcat 4.0.1 and MySQL 3.23.47 NT with Windows 2000.

    I deployed successfully an entity bean (EJB name: Account, JNDI name: z/Account) and want to reference it from a session bean (EJBname: LoginManager, JNDI name: z/LoginManager).
    Both are in different jar files.
    (The version with one jar file and internal EJB reference works fine!)

    I wrote the descriptors as described in the JBoss 2.0+ documentation, chapter 7 - "Declaring an EJBreference" - segment "External EJB reference".

    Session bean's ejb-jar.xml looks like this:

    <ejb-jar>
      <display-name>LoginManager EJB</display-name>
      <enterprise-beans>
        <session>
          <description>Manages user login</description>
          <ejb-name>LoginManager</ejb-name>
          <home>z.login.LoginManagerHome</home>
          <remote>z.login.LoginManager</remote>
          <ejb-class>z.login.LoginManagerEJB</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <ejb-ref>
             <ejb-ref-name>z/Account</ejb-ref-name>
             <ejb-ref-type>Entity</ejb-ref-type>
             <home>z.data.AccountHome</home>
             <remote>z.data.Account</remote>
             <!-- Only for internal reference:
             <ejb-link>Account</ejb-link>
             -->
          </ejb-ref>
        </session>
      </enterprise-beans>
    </ejb-jar>


    Session bean's jboss.xml:

    <jboss>
      <secure>false</secure>
      <container-configurations />
      <resource-managers />
      <enterprise-beans>
        <session>
          <ejb-name>LoginManager</ejb-name>
          <jndi-name>z/LoginManager</jndi-name>
          <configuration-name />
          <ejb-ref>
            <ejb-ref-name>z/Account</ejb-ref-name>
            <jndi-name>z/Account</jndi-name>
          </ejb-ref>
        </session>
      </enterprise-beans>
    </jboss>

    I also tried these two versions in session bean's jboss.xml:

    ...
          <ejb-ref>
            ...
            <jndi-name>Account</jndi-name>
          </ejb-ref>
    ...

    ...
          <ejb-ref>
            ...
            <jndi-name>jnp://localhost/Account</jndi-name>
          </ejb-ref>
    ...


    When trying to deploy session bean's jar file (with these different versions) I always get the following exception:

    [INFO,AutoDeployer] Auto deploy of file:/C:/Development/JBoss-2.4.4/jboss/deploy/loginmanager.jar
    [INFO,J2eeDeployer] Deploy J2EE application: file:/C:/Development/JBoss-2.4.4/jboss/deploy/loginmanager.jar
    [INFO,J2eeDeployer] Create application loginmanager.jar
    [INFO,J2eeDeployer] install EJB module loginmanager.jar
    [INFO,ContainerFactory] Deploying:file:/C:/Development/JBoss-2.4.4/jboss/tmp/deploy/Default/loginmanager.jar
    [ERROR,ContainerFactory] Verify failure
    java.lang.NoClassDefFoundError: z/data/Account
            at java.lang.Class.getMethods0(Native Method)
            at java.lang.Class.getMethods(Class.java:742)
            at org.jboss.verifier.strategy.AbstractVerifier.hasEJBCreateMethod(AbstractVerifier.java:456)
            at org.jboss.verifier.strategy.EJBVerifier11.verifySessionBean(EJBVerifier11.java:567)
            at org.jboss.verifier.strategy.EJBVerifier11.checkSession(EJBVerifier11.java:93)
            at org.jboss.verifier.BeanVerifier.verify(BeanVerifier.java:134)
            at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:465)
            at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:369)
            at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
            at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)
            at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:459)
            at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
            at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
            at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
            at java.lang.Thread.run(Thread.java:484)
    [INFO,ContainerFactory] Deploying LoginManager
    [ERROR,J2eeDeployer] Starting loginmanager.jar failed!
    [ERROR,Default] java.lang.NoClassDefFoundError: [Lz/data/Account;
    [ERROR,Default] at java.lang.Class.getMethods0(Native Method)
    [ERROR,Default]
    [ERROR,Default] at java.lang.Class.getMethods(Class.java:742)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.ejb.StatelessSessionContainer.setupBeanMapping(StatelessSessionContainer.java:450)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.ejb.StatelessSessionContainer.init(StatelessSessionContainer.java:155)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.ejb.Application.init(Application.java:202)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:372)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
    [ERROR,Default]
    [ERROR,Default] at java.lang.reflect.Method.invoke(Native Method)
    [ERROR,Default]
    [ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
    [ERROR,Default]
    [ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:459)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
    [ERROR,Default]
    [ERROR,Default] at java.lang.reflect.Method.invoke(Native Method)
    [ERROR,Default]
    [ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
    [ERROR,Default]
    [ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
    [ERROR,Default]
    [ERROR,Default] at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
    [ERROR,Default]
    [ERROR,Default] at java.lang.Thread.run(Thread.java:484)
    [ERROR,Default]
    [INFO,J2eeDeployer] Module loginmanager.jar is not running
    [INFO,J2eeDeployer] Destroying application loginmanager.jar
    [ERROR,AutoDeployer] DeploymentInfo failed:file:/C:/Development/JBoss-2.4.4/jboss/deploy/loginmanager.jar
    org.jboss.deployment.J2eeDeploymentException: Error while starting loginmanager.jar: [Lz/data/Account;, Cause: java.lang.NoClassDefFoundError: [Lz/data/Account;
            at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:524)
            at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:459)
            at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
            at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
            at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
            at java.lang.Thread.run(Thread.java:484)


    Whats about this message:

    [ERROR,Default] java.lang.NoClassDefFoundError: [Lz/data/Account;

    Why "[Lz/data/Account"?

    Who can help?


  2. I'm not sure this answers your question, but let me try: let's say I have two beans A & B, packaged in a.jar and b.jar. Now if A is going to remotely call the methods in B, then a.jar must contain not only all the classes for A, but _also_ the home & remote interfaces for B (as well as any PK or Value classes, or other supplements that A might use) -- all it does NOT need is B's implementation class. I don't quite understand the reason for this, except it has to do with the way separately-deployed JARs are not able to access each other's class files (and why that is, I have no idea).

    Does this make packaging the JARs a pain? YES.

  3. In Dependent Jars section for the EJB Jar Deployment you can add the jar which contains Account. This should make the jar deployed properly.

    Venket
  4. If A depends on B, in the manifest.mf file for A add the following line
    Class-Path: B.jar

    I have done this. It works.

    Pranab
  5. Thanks, works fine!

    Wolfgang