One to many relationships throwing a Excetion
---------------------------------------------
Key: JBAS-3850
URL:
http://jira.jboss.com/jira/browse/JBAS-3850
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: CMP service
Affects Versions: JBossAS-4.0.5.GA
Environment: Windows XP, JBoss 4.0.5GA, JBoss 4.0.4GA and JBoss 3.2.8.SP1
AMD Sempron 3000+
2.00 GHz
512 Mb RAM
Reporter: Santiago de la Nava Santos
Assigned To: Alexey Loubyansky
Hi all,
I'm having a similar problem with one to many relationship, CMP persistence and EJB 2
specification. I have tested the problem at versions 3.2.8.SP1, 4.0.4.GA and 4.0.5.GA, and
they all throws the same Exception. I have an ExperimentEJB that is related to many
ConfigurationEJB. When I try to add the ConfigurationEJB Collection to ExperimentEJB, the
system throws this exception:
11:07:01,323 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(<generated>)
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:212)
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 all the deployment descriptors and are ok:
* ejb-jar.xml
------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<?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>
<session>
<display-name>SessionControlEJB</display-name>
<ejb-name>SessionControlEJB</ejb-name>
<home>softiam.services.ejbs.sessioncontrol.SessionControlHome</home>
<remote>softiam.services.ejbs.sessioncontrol.SessionControl</remote>
<ejb-class>softiam.services.ejbs.sessioncontrol.SessionControlEJB</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
<entity>
<ejb-name>ExperimentEJB</ejb-name>
<home>softiam.services.ejbs.experiment.ExperimentHome</home>
<remote>softiam.services.ejbs.experiment.Experiment</remote>
<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>
<reentrant>True</reentrant>
<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>
<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>
<query>
<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>
<query>
<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>
<query>
<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>
</query>
<persistence-type>Container</persistence-type>
</entity>
<entity>
<ejb-name>ConfigurationEJB</ejb-name>
<home>softiam.services.ejbs.configuration.ConfigurationHome</home>
<remote>softiam.services.ejbs.configuration.Configuration</remote>
<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>
<reentrant>True</reentrant>
<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>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>experiment-configuration</ejb-relation-name>
<ejb-relationship-role>
<description>experiment</description>
<ejb-relationship-role-name>ExperimentRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<description>experiment</description>
<ejb-name>ExperimentEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<description>configuration</description>
<cmr-field-name>configuration</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<description>configuration</description>
<ejb-relationship-role-name>ConfigurationRole</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<cascade-delete />
<relationship-role-source>
<description>configuration</description>
<ejb-name>ConfigurationEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
</relationships>
</ejb-jar>
jboss.xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<?xml version="1.0"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>SessionControlEJB</ejb-name>
<jndi-name>SessionControlEJB</jndi-name>
</session>
<entity>
<ejb-name>ExperimentEJB</ejb-name>
<jndi-name>ExperimentEJB</jndi-name>
</entity>
<entity>
<ejb-name>ConfigurationEJB</ejb-name>
<jndi-name>ConfigurationEJB</jndi-name>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>experiment-configuration</ejb-relation-name>
<foreign-key-mapping />
<ejb-relationship-role>
<ejb-relationship-role-name>ExperimentRole</ejb-relationship-role-name>
<key-fields />
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>ConfigurationRole</ejb-relationship-role-name>
<key-fields />
</ejb-relationship-role>
</ejb-relation>
</relationships>
</jboss>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
The code that add the data to the relationship is like this:
* This is part of the function that generates the collection for the relationship:
public static Vector generateConfiguration(long experimentId, ConfigurationHome
configurationHome,CouplingInfo coupling) throws RemoteException, CreateException{
...
while(it2.hasNext())
{
ParameterInfo parameter=(ParameterInfo)it2.next();
ConfigurationInfo configurationInfo=parameter.getConfigurationInfo();
Configuration config=configurationHome.create(new
Long(experimentId),coupling.getName(),module.getName(),parameter.getName());
...
configurations.add(config);
}
return configurations;
}
* This is part of the code that add the collection generated by the previous function:
Experiment exp=(Experiment)session.getAttribute("currentExperiment");
ConfigurationHome configurationHome=this.softIAMInit.getConfigurationHome();
// This is the setter for the relationship
exp.setConfiguration((Collection)(ConfigurationControl.generateConfiguration(experimentId,configurationHome,coupling)));
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira