5 Replies Latest reply on May 6, 2004 8:56 AM by atrapp

    How to get CMP EJBs with a Relation running with JBoss...

    atrapp Newbie

      Hi!

      I am trying to get my first 2 EJBs (User and Person) running with JBoss since February, but I get very funny messages from JBoss (Null-pointer-exceptions) when I try to deploy them...

      I am pretty sure, that there is something wrong with my descriptor files (because there is no useful documentation, I have the J2EE docu from sun, the Tuturial from JBoss with NO useful content, bought the JBossBook321, not one sample there either). Is there any documentation around where there is a running sample for this? All I need is 2 EJBs and a 1:n relationship, that can't be too complex???

      Or is there anybody around who can have a look at my sources and I can help him in any other way? (Tomcat/Apache/JSP/Servlets/...)

      Thank you very much in advance...

      08:30:00,783 INFO [EjbModule] Deploying UserEJB
      08:30:00,904 ERROR [EntityContainer] Starting failed
      java.lang.NullPointerException
      at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.hash(ConcurrentReaderHashMap.java:297)
      at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.get(ConcurrentReaderHashMap.java:409)
      at org.jboss.mx.loading.UnifiedLoaderRepository3.getCachedClass(UnifiedLoaderRepository3.java:158)
      at org.jboss.mx.loading.LoaderRepositoryClassLoader.loadClass(LoaderRepositoryClassLoader.java:69)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
      at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:77)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.(JDBCEntityMetaData.java:294)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.(JDBCApplicationMetaData.java:139)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:52)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:706)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:409)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:357)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:342)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy14.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy41.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:331)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy14.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy12.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:544)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:458)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:20
      1)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:212)

      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:191)
      08:30:00,914 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=com/abt/db/user/PersonBean,service=E
      JB
      ... continues with more null pointer exceptions...

        • 1. Re: How to get CMP EJBs with a Relation running with JBoss..
          Alexey Loubyansky Master

          It seems like the remote interface was not found while the home was. What is in the deployment descriptors? And what is the JBoss version?

          • 2. Re: How to get CMP EJBs with a Relation running with JBoss..
            atrapp Newbie

            Thank you for this fast reply!

            JBoss_3_2_3 date=200311301445

            I am sure, that there are a lot of errors, but I had to gather all informations from severel sites...

            ejb-jar.xml:
            <?xml version="1.0"?>

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

            <ejb-jar>
            <enterprise-beans>

            Person
            <ejb-name>PersonEJB</ejb-name>
            com.abt.db.user.PersonHome
            <local-home>com.abt.db.user.PersonLocalHome</local-home>
            com.abt.db.user.Person
            <ejb-class>com.abt.db.user.PersonBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <primkey-field>id</primkey-field>
            <prim-key-class>java.math.BigDecimal</prim-key-class>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>Person</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>surname</field-name>
            <not-null/>
            </cmp-field>

            <query-method>
            <method-name>findBySurname</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM Person p WHERE p.surname = ?1]]>
            </ejb-ql>

            <cmp-field>
            <field-name>firstname</field-name>
            <not-null/>
            </cmp-field>

            <query-method>
            <method-name>findByFirstname</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM Person p WHERE p.firstname = ?1]]>
            </ejb-ql>

            <cmp-field>
            <field-name>birthdate</field-name>
            </cmp-field>

            <query-method>
            <method-name>findByBirthdate</method-name>
            <method-params>
            <method-param>java.sql.Date</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM Person p WHERE p.birthdate = ?1]]>
            </ejb-ql>



            User
            <ejb-name>UserEJB</ejb-name>
            com.abt.db.user.UserHome
            <local-home>com.abt.db.user.UserLocalHome</local-home>
            com.abt.db.user.User
            <ejb-class>com.abt.db.user.UserBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <primkey-field>id</primkey-field>
            <prim-key-class>java.math.BigDecimal</prim-key-class>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>User</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>name</field-name>
            <not-null/>
            </cmp-field>

            <query-method>
            <method-name>findByName</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM User p WHERE p.name = ?1]]>
            </ejb-ql>

            <cmp-field>
            <field-name>password</field-name>
            <not-null/>
            </cmp-field>

            <query-method>
            <method-name>findByPassword</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM User p WHERE p.password = ?1]]>
            </ejb-ql>


            </enterprise-beans>

            <ejb-relation>
            <ejb-relation-name>Person-UserEJB</ejb-relation-name>
            <ejb-relationship-role>
            <ejb-relationship-role-name>person-can-be-a-user</ejb-relationship-role-name>
            One
            <relationship-role-source><ejb-name>PersonEJB</ejb-name></relationship-role-source>
            <cmr-field>
            <cmr-field-name>user</cmr-field-name>
            </cmr-field>
            </ejb-relationship-role>
            <ejb-relationship-role>
            <ejb-relationship-role-name>user-is-a-person</ejb-relationship-role-name>
            One
            <relationship-role-source><ejb-name>UserEJB</ejb-name></relationship-role-source>
            <cmr-field>
            <cmr-field-name>person</cmr-field-name>
            </cmr-field>
            </ejb-relationship-role>
            </ejb-relation>

            </ejb-jar>

            jboss.xml:
            <?xml version="1.0"?>

            <enterprise-beans>

            <ejb-name>PersonEJB</ejb-name>
            <jndi-name>com/abt/db/user/PersonBean</jndi-name>


            <ejb-name>UserEJB</ejb-name>
            <jndi-name>com/abt/db/user/UserBean</jndi-name>

            </enterprise-beans>


            jbosscmp-jdbc.xml:
            <?xml version="1.0"?>

            <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">

            <jbosscmp-jdbc>

            java:/DefaultDS
            <datasource-mapping>Hypersonic SQL</datasource-mapping>
            <create-table>true</create-table>
            <remove-table>true</remove-table>
            <read-only>false</read-only>
            <read-time-out>300000</read-time-out>
            <pk-constraint>false</pk-constraint>
            <fk-constraint>false</fk-constraint>
            <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
            <read-ahead>
            on-load
            <page-size>500</page-size>
            <eager-load-group>group name</eager-load-group>
            </read-ahead>
            <unknown-pk>
            <unknown-pk-class>java.math.BigDecimal</unknown-pk-class>
            <field-name>id</field-name>
            <column-name>id</column-name>
            <jdbc-type>DECIMAL</jdbc-type>
            <sql-type>INT(38)</sql-type>
            <auto-increment/>
            </unknown-pk>

            <enterprise-beans>

            <ejb-name>PersonEJB</ejb-name>
            <table-name>Person</table-name>
            <entity-command name= "hsqldb-fetch-key"/>


            <ejb-name>UserEJB</ejb-name>
            <table-name>User</table-name>
            <entity-command name= "hsqldb-fetch-key"/>

            </enterprise-beans>

            <ejb-relation>
            <ejb-relation-name>Person-UserEJB</ejb-relation-name>
            <foreign-key-mapping/>
            <ejb-relationship-role>
            <ejb-relationship-role-name>person-can-be-a-user</ejb-relationship-role-name>
            <key-fields>
            <key-field>
            <field-name>id</field-name>
            <column-name>user</column-name>
            </key-field>
            </key-fields>
            </ejb-relationship-role>
            <ejb-relationship-role>
            <ejb-relationship-role-name>user-is-a-person</ejb-relationship-role-name>
            <key-fields>
            <key-field>
            <field-name>id</field-name>
            <column-name>person</column-name>
            </key-field>
            </key-fields>
            </ejb-relationship-role>
            </ejb-relation>

            </jbosscmp-jdbc>

            The two beans have the local, local home, remote, local remote and Bean classes implemented.

            • 3. Re: How to get CMP EJBs with a Relation running with JBoss..
              sesques Novice

              You should post code and descriptors within "code" or "quote" to see all the tags:

              Many errors BTW:

              I don't see the local interface declaration (just local-home, remote and home) for both EJB's.

              Also, your EJB-QL queries must refer to the bean in the FROM clause, not the table.

              Try change this, and pray ;-)

              Pascal

              • 4. Re: How to get CMP EJBs with a Relation running with JBoss..
                atrapp Newbie

                Wow. Great. Very much better!!!
                Thank you very much!

                Now I have errors which have some meaning to me :)

                • 5. Re: How to get CMP EJBs with a Relation running with JBoss..
                  atrapp Newbie

                  SUCCESS! Everything deployed without errors!
                  Thanks to both of you, you are GREAT!