4 Replies Latest reply on Mar 7, 2011 9:26 AM by dobbo314

    EJB Persistence with JBoss 6 v2

    dobbo314

      JBoss 6.0.0 Final installed and configured to use MySQL as it's backend database.  Well it seams to work.

       

      Had trouble deploying a simple EJB so I stripped things down to the minimum I could.  The EJB JAR file as almost nothing in it:

           0 Sun Mar 06 10:49:58 GMT 2011 META-INF/
         106 Sun Mar 06 10:49:56 GMT 2011 META-INF/MANIFEST.MF
        1038 Sun Mar 06 10:34:42 GMT 2011 META-INF/persistence.xml
           0 Sun Mar 06 10:48:48 GMT 2011 org/
           0 Sun Mar 06 10:48:48 GMT 2011 org/dobbo/
           0 Sun Mar 06 10:48:48 GMT 2011 org/dobbo/stadia/
           0 Sun Mar 06 10:48:48 GMT 2011 org/dobbo/stadia/data/
        1482 Sun Mar 06 10:48:48 GMT 2011 org/dobbo/stadia/data/Name.class
      

       

      Here is the important part of the EJB which is a test case for how I wish to develop my idea:

      @Entity
      @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
      @Table(name="sName")
      public class Name
          implements Serializable {
      
          private UUID theUUID = null;
      
          private String theName = null;
      
          public UUID getUUID() {
              return theUUID;
          }
      
          public void setUUID(UUID newUUID) {
              theUUID = newUUID;}
      
          @Id
          @Column(name="ident", length=36)
          public String getIdentity() {
              return getUUID().toString();
          }
      
          public void setUUID(String newUUID) {
              setUUID(UUID.fromString(newUUID));
          }
      
          @Column(name="name", length=50)
          public final String getName() {
              return theName;
          }
      
          public void setName(String newName) {
              theName = newName;
          }
      }
      

      And the persistance.xml file that was included in the JAR:

       

       

      q         java:/stadiaDS      org.hibernate.ejb.HibernatePersistence 
      
            false 
      
                                                                
         

       

      10:50:39,015 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Parse: name=vfs:///home/jboss/jboss-6.0.0.Final/server/default/deploy/stadia-ejbs.jar state=PreParse mode=Manual requiredState=Parse: org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfs:///home/jboss/jboss-6.0.0.Final/server/default/deploy/stadia-ejbs.jar
           at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [:2.2.0.GA]
           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:383) [:2.2.0.GA]
           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:343) [:2.2.0.GA]
           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:315) [:2.2.0.GA]
           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:255) [:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]
           at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.Final]
           at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
           at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:240) [:0.2.2]
           at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) [:0.2.2]
           at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) [:0.2.2]
           at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) [:0.2.2]
           at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) [:0.2.2]
           at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) [:0.2.2]
           at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) [:0.2.2]
           at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) [:0.2.2]
           at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) [:0.2.2]
           at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) [:0.2.2]
           at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) [:0.2.2]
           at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) [:0.2.2]
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_22]
           at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) [:1.6.0_22]
           at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) [:1.6.0_22]
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) [:1.6.0_22]
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180) [:1.6.0_22]
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) [:1.6.0_22]
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_22]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_22]
           at java.lang.Thread.run(Thread.java:662) [:1.6.0_22]
      Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: vfs:///home/jboss/jboss-6.0.0.Final/server/default/deploy/stadia-ejbs.jar/META-INF/persistence.xml@8,17
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:224) [jbossxb.jar:2.0.3.GA]
           at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:178) [jbossxb.jar:2.0.3.GA]
           at org.jboss.xb.util.JBossXBHelper.parse(JBossXBHelper.java:257) [jbossxb.jar:2.0.3.GA]
           at org.jboss.xb.util.JBossXBHelper.parse(JBossXBHelper.java:231) [jbossxb.jar:2.0.3.GA]
           at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:137) [:2.2.0.GA]
           at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:121) [:2.2.0.GA]
           at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parseAndInit(AbstractVFSParsingDeployer.java:352) [:2.2.0.GA]
           at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parseAndInit(AbstractVFSParsingDeployer.java:334) [:2.2.0.GA]
           at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parse(AbstractVFSParsingDeployer.java:251) [:2.2.0.GA]
           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:369) [:2.2.0.GA]
           ... 41 more
      Caused by: org.xml.sax.SAXException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode, "http://java.sun.com/xml/ns/persistence":properties}' is expected. @ vfs:///home/jboss/jboss-6.0.0.Final/server/default/deploy/stadia-ejbs.jar/META-INF/persistence.xml[8,17]
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.error(SaxJBossXBParser.java:416) [jbossxb.jar:2.0.3.GA]
           at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final]
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:209) [jbossxb.jar:2.0.3.GA]
           ... 50 more
      
      10:50:39,319 WARN  [org.jboss.profileservice.deployment.hotdeploy.HDScanner] Scan failed: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      
      

       

      So my questions:

       

      What have I done wrong, not done, missed?

       

      Where is there a really good (i.e. simple) guide to hybernation in JBoss 6?

       

      Many thanks for your help

        • 1. EJB Persistence with JBoss 6 v2
          wdfink

          Is the posted persistence.xml correct, it is no real xml.

           

          The exception is about incorrect persistence.xml, you should check it or attach the file.

          1 of 1 people found this helpful
          • 2. Re: EJB Persistence with JBoss 6 v2
            dobbo314

            Sorry, didn't see that the persistence file got messed up, it should have read like this:

             

            <?xml version="1.0" encoding="UTF-8"?>
            <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
                         version="2.0">
               <persistence-unit name="stadiaDB" transaction-type="JTA">
                  <jta-data-source>java:/stadiaDS</jta-data-source>
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
            
                  <exclude-unlisted-classes>false</exclude-unlisted-classes>
            
                  <properties>
                    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDialect"/>
                    <property name="hibernate.hbm2ddl.auto" value="update"/>
                    <property name="hibernate.show_sql" value="true"/>
                    <property name="hibernate.format_sql" value="true"/>
                    <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLook
            up"/>
                  </properties>
            
               </persistence-unit>
            </persistence>
            
            

            My goal here is for the EJBs to get stored in the MySQL - any settings that work will do.

             

            Once again thanks for your help

             

            Steve

            1 of 1 people found this helpful
            • 3. EJB Persistence with JBoss 6 v2
              wdfink

              The same error occour if you use a XML editor with validation.

              If I move the <provider> one line up (change posistion of jta-data-source and provider) the xml become valid.

              Check this!

              • 4. Re: EJB Persistence with JBoss 6 v2
                dobbo314

                Thanks Wolf-Dieter Fink.

                That has fixed the problem.  I hadn't thought that although Emacs saw the XML as valid the DTD might have an order to the tags. 

                 

                I also had a problem with the MySQLInnoDialect not working because of a typo and I should have been using "MySQL5InnoDBDialect".

                 

                Just for anyone coming a long afterwards there is also two problems with the EJB file:

                 

                1). The setUUID(String newUUID) should, of course, be called "setIdentity(String new UUID)" or the parsing of the EJB will fail because hybernate will fail as it can't find a setter for the key.

                 

                2). The getUUID() method needs to be marked as "@Transient" so that hybernate doesn't try to map it to a database object.

                 

                But with these three little change my test EJB gets deployed and the table created in the database.  I'm now a happy bunny.

                 

                Many thanks