7 Replies Latest reply on May 7, 2014 11:49 PM by Ferdinan Tolentino

    JBoss 7.1 + ANTLR3 + Hibernate

    jimmy001 Apprentice

      Hello,

       

      I am trying to port an application (ear) from JBoss 5.1 to JBoss 7.1.1. After some ups and downs I need your help regarding the following issue:

       

      The application relies on antlr 3.3 and uses hibernate (which depends on antlr 2.7.7).  I have added the JBoss hibernate module in the MANIFEST.MF.

      On startup of the application the log shows:

       

      Unable to parse order-by fragment

      at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.render(OrderByFragmentTranslator.java:66)

      at org.hibernate.sql.Template.renderOrderByStringTemplate(Template.java:696)

      at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:558)

      at org.hibernate.persister.collection.OneToManyPersister.<init>(OneToManyPersister.java:85)
      ...

      java.lang.ClassCastException: antlr.CommonToken cannot be cast to antlr.Token

       

      Which according to https://forum.hibernate.org/viewtopic.php?p=2455588 is a classloader issue. My question is (you already guess it) how to solve this problem?

      Perhaps there is some way using the "jboss-deployment-structure.xml" to achieve a way that my app uses the packaged antlr and the jboss hibernate module uses the jboss antlr module?

       

      Thx in advance.

        • 1. Re: JBoss 7.1 + ANTLR3 + Hibernate
          Nicklas Karlsson Master

          You might want to try excluding the org.antlr module in jboss-deployments-structure.xml (and not sure you need the explicit hibernate module dependency).

          • 2. Re: JBoss 7.1 + ANTLR3 + Hibernate
            darren hartford Expert

            Excellent post, I'm running into the same problem (a WAR instead of an EAR however, but also bringing a specific version hibernate4.2.7 and ensure it stays using that version...and allow it to deploy to tomcat as well).

             

            I did not realize you could exclude, so found the example and sharing (WEB-INF/jboss-deployment-structure.xml)

             

            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

            <deployment>

            <exclusions>

            <module name="org.antlr"/>

            <module name="org.hibernate"/>

            </exclusions>

            <deployment>

            </jboss-deployment-structure>

             

             

            Unfortunately, now getting this error --

             

            {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"pos7.war#pos\"" => "org.jboss.msc.service.StartException in

            service jboss.persistenceunit.\"pos7.war#pos\": javax.persistence.PersistenceException: Cannot find scanner class. hiber

            nate.ejb.resource_scanner=org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner

                Caused by: javax.persistence.PersistenceException: Cannot find scanner class. hibernate.ejb.resource_scanner=org.jbo

            ss.as.jpa.hibernate4.HibernateAnnotationScanner

                Caused by: java.lang.ClassNotFoundException: org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner from [Module \"d

            eployment.pos7.war:main\" from Service Module Loader]"}}

             

            The same application deploys and works in a tomcat environment, so I'm unsure what I'm missing for a jboss deployment...maybe there is a persistence.xml that left default/blank behaves differently in jboss7, or another exclusion I missed?

            • 3. Re: JBoss 7.1 + ANTLR3 + Hibernate
              darren hartford Expert

              Resolution, also remove the subsystem:

               

              /WEB-INF/jboss-deployment-structure.xml

               

              <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

              <deployment>

              <exclude-subsystems>

              <subsystem name="jpa" />

              </exclude-subsystems>

              <exclusions>

              <module name="org.antlr"/>

              <module name="org.hibernate"/>

              </exclusions>

              <deployment>

              </jboss-deployment-structure>

              • 4. Re: JBoss 7.1 + ANTLR3 + Hibernate
                Derry yu Newbie

                edit ur pom.xml like below:

                 

                <dependency>

                   <groupId>org.hibernate</groupId>

                   <artifactId>hibernate-core</artifactId>

                   <version>4.0.1.Final</version>

                   <scope>provided</scope>

                  

                   <exclusions>

                      <exclusion>

                         <groupId>antlr</groupId>

                         <artifactId>antlr</artifactId>

                      </exclusion>

                   </exclusions>

                </dependency>

                • 5. Re: JBoss 7.1 + ANTLR3 + Hibernate
                  Stephen Coy Master

                  This will not make any difference because "provided" scope dependencies do not pull in their transient dependencies.

                  • 6. Re: JBoss 7.1 + ANTLR3 + Hibernate
                    swapnesh sharma Newbie

                    You can use sub-deployment in jboss-deployment-structure for more control. Below is an example, modify it for your app.

                     

                    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>

                      <deployment>

                      <dependencies>

                           <!-- Other dependencies -->

                      </dependencies>

                      </deployment>

                       <sub-deployment name="your-war.war">

                      <exclusions>

                      <module name="org.antlr" slot="main" />

                      </exclusions>

                      <dependencies>

                      <module name="org.antlr" slot="3.3"/>

                      </dependencies>

                      </sub-deployment>

                    </jboss-deployment-structure>

                    • 7. Re: JBoss 7.1 + ANTLR3 + Hibernate
                      Ferdinan Tolentino Newbie
                      Hi swapnesh,

                       

                      I also have the same problem with my application. Is your fix applicable to war application?

                      I'm actually migrating from Seam 2.2 (hibernate 3 + JSF1.2 + Richfaces 3 + Jboss AS 5) to Seam 2.3 (Hibernate 4 + JSF2 + Richfaces 4 + Jboss AS 7)

                       

                      Here's my error log:

                      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: app1_unit1] Unable to build EntityManagerFactory

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

                        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        ... 3 more

                      Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.collection.OneToManyPersister

                        at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:248)

                        at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:196)

                        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:375)

                        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                        ... 9 more

                      Caused by: org.hibernate.HibernateException: Unable to parse order-by fragment

                        at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.render(OrderByFragmentTranslator.java:66)

                        at org.hibernate.sql.Template.renderOrderByStringTemplate(Template.java:696)

                        at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:558)

                        at org.hibernate.persister.collection.OneToManyPersister.<init>(OneToManyPersister.java:85)

                        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_38]

                        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_38]

                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_38]

                        at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_38]

                        at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:226)

                        ... 14 more

                      Caused by: java.lang.ClassCastException: antlr.CommonToken cannot be cast to antlr.Token

                        at antlr.CharScanner.makeToken(CharScanner.java:173)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.mIDENT(GeneratedOrderByLexer.java:238)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.nextToken(GeneratedOrderByLexer.java:138)

                        at antlr.TokenBuffer.fill(TokenBuffer.java:69)

                        at antlr.TokenBuffer.LA(TokenBuffer.java:80)

                        at antlr.LLkParser.LA(LLkParser.java:52)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.expression(GeneratedOrderByFragmentParser.java:504)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortKey(GeneratedOrderByFragmentParser.java:325)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortSpecification(GeneratedOrderByFragmentParser.java:241)

                        at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.orderByFragment(GeneratedOrderByFragmentParser.java:190)

                        at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.render(OrderByFragmentTranslator.java:60)

                        ... 22 more

                       

                      and

                       

                      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: app1_unit2] Unable to build EntityManagerFactory

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

                        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        ... 3 more

                      Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister

                        at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:180)

                        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:131)

                        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:345)

                        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                        ... 9 more

                      Caused by: org.hibernate.HibernateException: Unexpected number of trim function operands : 13

                        at org.hibernate.sql.Template$TrimOperands.<init>(Template.java:583)

                        at org.hibernate.sql.Template$TrimOperands.<init>(Template.java:562)

                        at org.hibernate.sql.Template.renderWhereStringTemplate(Template.java:249)

                        at org.hibernate.sql.Template.renderWhereStringTemplate(Template.java:105)

                        at org.hibernate.mapping.Formula.getTemplate(Formula.java:46)

                        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:596)

                        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:142)

                        at sun.reflect.GeneratedConstructorAccessor34.newInstance(Unknown Source) [:1.6.0_38]

                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_38]

                        at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_38]

                        at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:158)

                        ... 14 more

                       

                      Thanks! \m/