-
1. Re: Load relation failed
hubs2121 Feb 10, 2002 2:35 AM (in response to hubs2121)Actually, the jbosscmp-jdbc.xml that I attached generates a different error, as follows:
org.jboss.deployment.DeploymentException: Role: one-child-belongs-to-one-parent
with multiplicity many using foreign-key mapping is not allowed to have key-fiel
ds
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.
loadKeyFields(JDBCRelationshipRoleMetaData.java:352)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.
init(JDBCRelationshipRoleMetaData.java:157)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.(J
DBCRelationMetaData.java:308)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.(JDBCApplicationMetaData.java:383)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXm
lFileLoader.java:75)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaDat
a(JDBCStoreManager.java:503)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.create(JDBCStoreManag
er.java:277)
at org.jboss.ejb.plugins.CMPPersistenceManager.create(CMPPersistenceMana
ger.java:134)
at org.jboss.ejb.EntityContainer.create(EntityContainer.java:342)
at org.jboss.ejb.Application.start(Application.java:214)
at org.jboss.ejb.EJBDeployer.deploy(EJBDeployer.java:431)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:396)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:362)
at org.jboss.deployment.MainDeployer.scan(MainDeployer.java:243)
at org.jboss.deployment.MainDeployer.startService(MainDeployer.java:196)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:1
30)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.system.Server.(Server.java:182)
at org.jboss.Main.boot(Main.java:243)
at org.jboss.Main.run(Main.java:44)
at java.lang.Thread.run(Unknown Source)
02:34:27,665 WARN [MainDeployer] operation failed; ignoring
java.lang.NullPointerException
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.stop(JDBCStoreManager
.java:346)
at org.jboss.ejb.plugins.CMPPersistenceManager.stop(CMPPersistenceManage
r.java:180)
at org.jboss.ejb.EntityContainer.stop(EntityContainer.java:408)
at org.jboss.ejb.Application.stop(Application.java:240)
at org.jboss.ejb.EJBDeployer.deploy(EJBDeployer.java:444)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:396)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:362)
at org.jboss.deployment.MainDeployer.scan(MainDeployer.java:243)
at org.jboss.deployment.MainDeployer.startService(MainDeployer.java:196)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:1
30)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.system.Server.(Server.java:182)
at org.jboss.Main.boot(Main.java:243)
at org.jboss.Main.run(Main.java:44)
at java.lang.Thread.run(Unknown Source)
Any ideas???
Thanks,
Steve -
2. Re: Load relation failed
giorgio42 Feb 10, 2002 11:56 AM (in response to hubs2121)I guess you are using a recent version of RH.
The jbosscmp-jdbc.xml format has changed.
- foreign-key-mapping is now only a flag (an empty element).
- foreign-key-field(s) has become key-field(s).
- And you have to remove the settings for the relationship
field name. It is now generated automatically from the cmr field name (I don't know whether this can be controlled, see commented-out part below).
<ejb-relation>
<ejb-relation-name>Master-Detail</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>master-has-details</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>detail-belongs-to-master</ejb-relationship-role-name>
<!--
<key-fields>
<key-field>
<field-name>id</field-name>
<column-name>FK_MASTER_ID</column-name>
</key-field>
</key-fields>
-->
</ejb-relationship-role>
</ejb-relation>
If you have 1:1 relationships, the fk field is now generated in the other table (so changing foreign-key-field to key-field by search-replace is not enough).
HTH.
Georg -
3. Re: Load relation failed
hubs2121 Feb 10, 2002 2:22 PM (in response to hubs2121)Georg, thanks for the help!
Jboss doesn't want to let me put in the key-fields...it complains that they don't belong there, even when I change the column-name.
So, I just put in <key-fields/> for both sides of the relationship and tried it using the Default Hypersonic database instead. It gave the same error but included more info:
Listening for transport dt_socket at address: 1445
Getting ParentHome
Got ParentHome
The Parent is:
1 John Smith
Children are:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Load relation failed
Embedded Exception
Unexpected token: FROM in statement [SELECT FROM parent WHERE (parentid=1)]; nested exception is:
javax.ejb.EJBException: Load relation failed
Embedded Exception
Unexpected token: FROM in statement [SELECT FROM parent WHERE (parentid=1)]
I am not sure what the container is trying to do with this query but it is clearly wrong...it's not selecting anything!
I must have something configured wrong.
Any other ideas?
Thanks,
Steve -
4. Re: Load relation failed
giorgio42 Feb 11, 2002 4:23 AM (in response to hubs2121)It seems there's actually a bug in the SQL generated
by JDBCLoadRelationCommand.
It creates something like
select ID, from YourTableNameHere
whith the comma after the id being incorrect.
If you set the default logging level in log4j.properties
to DEBUG you may be able to see the statement in the
server log just a few lines above the exception.
I guess we have to wait for a fix.
Dain, any ideas on this?
Georg -
5. Re: Load relation failed
dsundstrom Feb 27, 2002 12:09 AM (in response to hubs2121)Do you still have this problem?
If so please post a bug report.