2 Replies Latest reply on Nov 14, 2006 7:32 AM by santins

    NullPointerException when adding values to one-many relation

    santins

      Hi All,

      I have two Entity beans (CMP persistence) that have a relation one to many. When I try to populate that relation jboss 4.0.5 GA is giving me this exception:


      13:19:43,921 ERROR [LogInterceptor] RuntimeException in method: public abstract void softiam.services.ejbs.experiment.Ex
      periment.setConfiguration(java.util.Collection) throws java.rmi.RemoteException:
      java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getRelatedPrimaryKey(JDBCCMRFieldBridge.java:1862)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:857)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:723)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler$FieldSetInvoker.invoke(EntityBridgeInvocationH
      andler.java:170)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:105)

      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:76)
      at softiam.services.ejbs.experiment.ExperimentEJB$Proxy.setConfiguration()
      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:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1187)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:87)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:284)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)

      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:126)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:276)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:104)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:68)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:527)
      at org.jboss.ejb.Container.invoke(Container.java:954)
      at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
      at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:112)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      at $Proxy57.setConfiguration(Unknown Source)
      at softiam.services.ui.gwtui.server.SoftIAMServiceImpl.experimentConfigurationSet(SoftIAMServiceImpl.java:211)
      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:585)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:260)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:147)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java
      :664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)


      I have checked the definition and implementation of the relation and all seems ok.

      Can anybody help with this?

      Many thanks,

      Santi

        • 1. Re: NullPointerException when adding values to one-many rela
          santins

          I have seen that there is an open bug for many to many relations:

          http://jira.jboss.com/jira/browse/JBAS-1507

          Maybe it is related to this one. Anyway, this is my ejb-jar.xml that could help:

          <?xml version="1.0" encoding="UTF-8"?>

          <!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>
          <display-name>SoftiamEJBs</display-name>
          <enterprise-beans>

          <display-name>SessionControlEJB</display-name>
          <ejb-name>SessionControlEJB</ejb-name>
          softiam.services.ejbs.sessioncontrol.SessionControlHome
          softiam.services.ejbs.sessioncontrol.SessionControl
          <ejb-class>softiam.services.ejbs.sessioncontrol.SessionControlEJB</ejb-class>
          <session-type>Stateful</session-type>
          <transaction-type>Container</transaction-type>


          <ejb-name>ExperimentEJB</ejb-name>
          softiam.services.ejbs.experiment.ExperimentHome
          softiam.services.ejbs.experiment.Experiment
          <ejb-class>softiam.services.ejbs.experiment.ExperimentEJB</ejb-class>
          <abstract-schema-name>experiments</abstract-schema-name>
          <prim-key-class>java.lang.Long</prim-key-class>
          <primkey-field>experimentId</primkey-field>
          True
          <cmp-field>
          <field-name>experimentId</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>user</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>coupling</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>state</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>experimentIndex</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>name</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>description</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>creationTime</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>operationTime</field-name>
          </cmp-field>

          <query-method>
          <method-name>findExperiments</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <ejb-ql>
          SELECT OBJECT(e)
          FROM experiments e
          WHERE e.user=?1
          </ejb-ql>


          <query-method>
          <method-name>findExperiments</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <ejb-ql>
          SELECT OBJECT(e)
          FROM experiments e
          WHERE e.user=?1 AND e.coupling=?2
          </ejb-ql>


          <query-method>
          <method-name>findRunningExperiments</method-name>
          <method-params></method-params>
          </query-method>
          <ejb-ql>
          SELECT OBJECT(e)
          FROM experiments e
          WHERE e.state=1
          </ejb-ql>


          <query-method>
          <method-name>findNotStartedExperiments</method-name>
          <method-params></method-params>
          </query-method>
          <ejb-ql>
          SELECT OBJECT(e)
          FROM experiments e
          WHERE e.state=0
          </ejb-ql>

          <persistence-type>Container</persistence-type>


          <ejb-name>ConfigurationEJB</ejb-name>
          softiam.services.ejbs.configuration.ConfigurationHome
          softiam.services.ejbs.configuration.Configuration
          <ejb-class>softiam.services.ejbs.configuration.ConfigurationEJB</ejb-class>
          <abstract-schema-name>configurations</abstract-schema-name>
          <prim-key-class>softiam.services.ejbs.configuration.ConfigurationPK</prim-key-class>
          True
          <cmp-field>
          <field-name>experimentId</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>coupling</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>module</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>parameter</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>type</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>singleValue</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>rangeInitial</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>rangeEnd</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>rangeIncrement</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>rangeCombine</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>multipleValues</field-name>
          </cmp-field>
          <cmp-field>
          <field-name>multipleCombine</field-name>
          </cmp-field>
          <persistence-type>Container</persistence-type>

          </enterprise-beans>

          <ejb-relation>
          <ejb-relation-name>experiment-configuration</ejb-relation-name>
          <ejb-relationship-role>
          experiment
          <ejb-relationship-role-name>ExperimentRole</ejb-relationship-role-name>
          One
          <relationship-role-source>
          experiment
          <ejb-name>ExperimentEJB</ejb-name>
          </relationship-role-source>
          <cmr-field>
          configuration
          <cmr-field-name>configuration</cmr-field-name>
          <cmr-field-type>java.util.Collection</cmr-field-type>
          </cmr-field>
          </ejb-relationship-role>
          <ejb-relationship-role>
          configuration
          <ejb-relationship-role-name>ConfigurationRole</ejb-relationship-role-name>
          Many
          <cascade-delete />
          <relationship-role-source>
          configuration
          <ejb-name>ConfigurationEJB</ejb-name>
          </relationship-role-source>
          </ejb-relationship-role>
          </ejb-relation>

          </ejb-jar>


          Many thanks,

          Santi

          • 2. Re: NullPointerException when adding values to one-many rela
            santins

            Finally, The problem was that my entities EJBs hadn't the local interface implemented, that it is compulsory for CMR and relationships. Once I implemented it, all works fine.