1 Reply Latest reply on Dec 8, 2003 11:56 PM by prashan

    CMP2.x Generate PK using Jboss 3.2.1 & oracle8.1.7

    axen

      Hi,

      I am having a problem when generating a primary key using an Oracle sequence.

      Jboss generates the following error:

      org.jboss.deployment.DeploymentException: Invalid XML: file=jar:file:/C:/jboss-3.2.2/server/default/tmp/deploy/tmp19088localys.ear-contents/MessagePersistor.jar!/META-INF/jbosscmp-jdbc.xml
      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:296)
      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:247)
      at org.jboss.metadata.XmlFileLoader.getDocumentFromURL(XmlFileLoader.java:219)
      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:203)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:74)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:676)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:372)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:320)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:343)
      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.GeneratedMethodAccessor4.invoke(Unknown Source)




      My jbosscmp-jdbc.xml looks like that:

      <jbosscmp-jdbc>

      java:/OracleDS
      <datasource-mapping>Oracle8</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

      <enterprise-beans>

      <ejb-name>MessagePersistor</ejb-name>
      <table-name>xml_Message</table-name>

      <cmp-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      <auto-increment/>
      </cmp-field>
      <cmp-field>
      <field-name>dateMessage</field-name>
      <column-name>date_message</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>message</field-name>
      <column-name>message</column-name>

      </cmp-field>

      <entity-command name="pk-sql">
      SELECT nextval('xml_message_seq')
      </entity-command>


      </enterprise-beans>

      </jbosscmp-jdbc>

      Do you have an idea of the error ?????
      If you find better solutions pls, tell it.

      Thanks,
      David

        • 1. Re: CMP2.x Generate PK using Jboss 3.2.1 & oracle8.1.7
          prashan

          Hi axen,

          I think your problem is in your jbosscmp-jdbc.xml file.

          If you want to generate a primary key automatically, you have to specify it in the jbosscmp-jdbc.xml as follows :

          <unknown-pk>
          <unknown-pk-class>java.lang.Integer</unknown-pk-class>
          <field-name>keyvalue</field-name>
          <column-name>keyvalue</column-name>
          <auto-increment/>
          </unknown-pk>
          <entity-command name="pk-sql"/>

          The primary key field should not be declared as <cmp-field> and this should be placed under the final <cmp-field> tags according to the DTD, which is available here :
          http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd

          Hope this helps.