5 Replies Latest reply on Feb 3, 2011 5:40 PM by ventmonkey

    Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven

    ventmonkey

      Hi all.  Sorry if this question should be asked in the jboss as, or hibernate forums. 


      I am trying to deploy a seam app to Jboss AS 6.0.0.Final, using the hibernate included in the Seam pom, and have the following in my pom.xml


          <properties>
              <version.seam>2.2.1.Final</version.seam>
          </properties>
      
          <dependency>
              <groupId>org.jboss.seam</groupId>
              <artifactId>jboss-seam</artifactId>
              <version>${version.seam}</version>
          </dependency>
      
          <dependency>
              <groupId>org.jboss.seam</groupId>
              <artifactId>jboss-seam-ui</artifactId>
              <version>${version.seam}</version>
          </dependency>
      
          <dependency>
              <groupId>org.jboss.seam</groupId>
              <artifactId>jboss-seam-remoting</artifactId>
              <version>${version.seam}</version>
          </dependency>
      
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-core</artifactId>
                  <scope>compile</scope>
                  <exclusions>
                      <exclusion>
                          <groupId>antlr</groupId>
                          <artifactId>antlr</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-search</artifactId>
                  <scope>compile</scope>
                  <exclusions>
                      <exclusion>
                          <groupId>antlr</groupId>
                          <artifactId>antlr</artifactId>
                      </exclusion>
                      <exclusion>
                          <groupId>org.hibernate</groupId>
                          <artifactId>hibernate-core</artifactId>
                      </exclusion>
                      <exclusion>
                          <groupId>org.hibernate</groupId>
                          <artifactId>ejb3-persistence</artifactId>
                      </exclusion>
                      <exclusion>
                          <groupId>org.hibernate</groupId>
                          <artifactId>hibernate-commons-annotations</artifactId>
                      </exclusion>
                      <exclusion>
                          <groupId>org.slf4j</groupId>
                          <artifactId>slf4j-api</artifactId>
                      </exclusion>
                      <exclusion>
                          <groupId>javax.transaction</groupId>
                          <artifactId>jta</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-annotations</artifactId>
                  <scope>compile</scope>
                  <exclusions>
                      <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-entitymanager</artifactId>
                  <scope>compile</scope>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-commons-annotations</artifactId>
                  <scope>compile</scope>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-tools</artifactId>
                  <scope>compile</scope>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-validator</artifactId>
                  <scope>compile</scope>
              </dependency>
              <dependency>
                  <groupId>org.hibernate.javax.persistence</groupId>
                  <artifactId>hibernate-jpa-2.0-api</artifactId>
                  <version>1.0.0.Final</version>
                  <scope>compile</scope>
              </dependency>
      
              <dependency>
                  <groupId>org.apache.lucene</groupId>
                  <artifactId>lucene-snowball</artifactId>
                  <version>2.4.1</version>
              </dependency>
      ......
      
           <build>
              <pluginManagement>
                  <plugins>
                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-ear-plugin</artifactId>
                          <version>2.5</version>
                          <configuration>
                              <version>5</version>
                              <defaultLibBundleDir>lib</defaultLibBundleDir>
                              <modules>
                                  <ejbModule>
                                      <groupId>com.myproj</groupId>
                                      <artifactId>myproj-ejb</artifactId>
                                  </ejbModule>
                              </modules>
                              <jboss>
                                  <loader-repository>
        com.myproj:archive=unique-archive-name
                                  </loader-repository>
                                  <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                              </jboss>
                          </configuration>
                      </plugin>
                  </plugins>
              </pluginManagement>
          </build>
      



      my META-INF/jboss-app.xml looks like



      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
              "-//JBoss//DTD J2EE Application 1.4//EN"
              "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
        <loader-repository>com.myproj:archive=unique-archive-name<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
        </loader-repository>
      </jboss-app>
      
      



      When I deploy, I get the following message




      19:17:36,321 ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:ear=myproj-ear-1.0-SNAPSHOT.ear,jar=myproj-ejb-1.0-SNAPSHOT.jar,name=GoogleAccountBean,service=EJB3 state=Create: java.lang.ClassCastException: org.hibernate.hql.ast.HqlToken cannot be cast to org.hibernate.hql.ast.HqlToken
              at org.hibernate.hql.ast.HqlLexer.makeToken(HqlLexer.java:62) [:3.6.0.Final]
              at org.hibernate.hql.antlr.HqlBaseLexer.mIDENT(HqlBaseLexer.java:599) [:3.6.0.Final]
              at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:270) [:3.6.0.Final]
              at antlr.TokenBuffer.fill(Unknown Source) [:6.0.0.Final]
              at antlr.TokenBuffer.LA(Unknown Source) [:6.0.0.Final]
              at antlr.LLkParser.LA(Unknown Source) [:6.0.0.Final]
              at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:141) [:3.6.0.Final]
              at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:274) [:3.6.0.Final]
              at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182) [:3.6.0.Final]
              at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) [:3.6.0.Final]
              at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101) [:3.6.0.Final]
              at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80) [:3.6.0.Final]
              at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124) [:3.6.0.Final]
              at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) [:3.6.0.Final]
              at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) [:3.6.0.Final]
              at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770) [:3.6.0.Final]
              at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:272) [:3.6.0.Final]
              at org.jboss.ejb3.timerservice.mk2.TimerServiceImpl.getActiveTimers(TimerServiceImpl.java:983) [:1.0.0-alpha-13]
              at org.jboss.ejb3.timerservice.mk2.TimerServiceImpl.restoreTimers(TimerServiceImpl.java:738) [:1.0.0-alpha-13]
              at org.jboss.ejb3.timerservice.mk2.TimerServiceFactoryImpl.restoreTimerService(TimerServiceFactoryImpl.java:123) [:1.0.0-alpha-13]
              at org.jboss.ejb3.TimerServiceContainer.restoreTimerService(TimerServiceContainer.java:244) [:1.7.17]
              at org.jboss.ejb3.TimerServiceContainer.afterStart(TimerServiceContainer.java:129) [:1.7.17]
              at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:1113) [:1.7.17]
      


      I cannot figure out if I am missing a hibernate lib, or if this is a class loading order issue.  Please help.  Has anyone else gotten Seam 2.2.1, Hibernate-search, and Jboss AS 6 working in a maven project?


      Thanks,
      Mason

        • 1. Re: Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven
          ventmonkey

          oh, and the libraries that are downloaded by maven are...
          find . -name *hiber*.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-tools-3.2.4.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-commons-annotations-3.1.0.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-entitymanager-3.4.0.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-validator-3.1.0.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-annotations-3.4.0.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-search-3.1.1.GA.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-core-3.3.1.GA.jar
          mason@mason-desktop:/proj/myproj$ find . -name *seam*.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-remoting-2.2.1.Final.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-ui-2.2.1.Final.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-2.2.1.Final.jar
          ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/jboss-seam-2.2.1.Final.jar
          mason@mason-desktop:/proj/myproj$

          • 2. Re: Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven
            ventmonkey

            ack!  sorry...that should be



            find . -name \*hiber\*.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-tools-3.2.4.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-commons-annotations-3.1.0.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-entitymanager-3.4.0.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-validator-3.1.0.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-annotations-3.4.0.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-search-3.1.1.GA.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/hibernate-core-3.3.1.GA.jar
            mason@mason-desktop:/proj/myproj$ find . -name \*seam\*.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-remoting-2.2.1.Final.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-ui-2.2.1.Final.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/lib/jboss-seam-2.2.1.Final.jar
            ./myproj-ear/target/myproj-ear-1.0-SNAPSHOT/jboss-seam-2.2.1.Final.jar
            mason@mason-desktop:/proj/myproj$ 



            • 3. Re: Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven
              mana.hotmana76.gmail.com

              You can't use hibernate-*.jar from seam distribution in JBoss AS 6.


              Look at Blog or DvdStore example build script, which for JBoss AS 6 use Hibernate Search 3.3 and don't include Hibernate  jars which are already integrated in JBoss AS.



              Shortly summarizing exclude all hibernate-*.jars except hibernate-search (3.3.x). Or in different way - they should be set up with scope=PROVIDED not compile.

              • 4. Re: Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven
                ventmonkey

                Thanks for your help Marek.


                I tried setting all Hibernate to scope PROVIDED, except Hibernate-search to scope compiled, which only adds the following Hibernate jar to my project...hibernate-search-3.1.1.GA.jar.  With that I get the following error...




                20:44:10,621 INFO  [Version] Hibernate Search 3.1.1.GA
                20:44:10,771 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=myproj-ear-1.0-SNAPSHOT.ear/persistence.xml#FiviProduction-ejbPU state=Create: java.lang.NoSuchMethodError: org.hibernate.util.SoftLimitMRUCache.<init>(I)V
                        at org.hibernate.search.filter.MRUFilterCachingStrategy.initialize(MRUFilterCachingStrategy.java:25)
                        at org.hibernate.search.impl.SearchFactoryImpl.buildFilterCachingStrategy(SearchFactoryImpl.java:461)
                        at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:131)
                        at org.hibernate.search.event.ContextHolder.getOrBuildSearchFactory(ContextHolder.java:30)
                        at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:79)
                        at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198) [:3.6.0.Final]
                        at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181) [:3.6.0.Final]
                        at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194) [:3.6.0.Final]
                        at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1980) [:3.6.0.Final]
                        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842) [:3.6.0.Final]
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902) [:3.6.0.Final]
                        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) [:3.6.0.Final]
                        at org.jboss.jpa.builder.DefaultCEMFBuilder.build(DefaultCEMFBuilder.java:47) [:1.0.2-alpha-3]
                        at org.jboss.as.jpa.scanner.HackCEMFBuilder.build(HackCEMFBuilder.java:49) [:6.0.0.Final]
                        at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:275) [:1.0.2-alpha-3]
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]
                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]






                I also looked at the seam wiki example, and it includes the following hibernate jars
                hibernate3.jar  hibernate-annotations.jar  hibernate-commons-annotations.jar  hibernate-entitymanager.jar  hibernate-search.jar  hibernate-tools.jar  hibernate-validator.jar.  I believe I had duplicated that with having all Hibernate depends set to Compile, but I could be wrong!



                Thanks,
                Mason

                • 5. Re: Seam 2.2.1.final, Hibernate-search, jboss AS 6, and Maven
                  ventmonkey

                  I think I figured it out.  Using the hibernate-search lib from the seam example worked. I realized that my hibernate-search dependency was using the hibernate-search within seam under the pom's dependencyManagement.  Once I excluded hibernate-search and set a version (3.3.0, was previously using 3.3.1 from seam), maven downloaded hibernate-search-3.3.0.Final.jar and hibernate-search-analyzers-3.3.0.Final.jar, and it seems to be worknig!  er, actually, I'm getting other errors, but I think I can get through those.  Thanks!