4 Replies Latest reply on Jul 15, 2009 1:56 PM by caye

    hibernate is is unable to find my ejbs.jar

    ssatir

      Hi!


      I have set up a multi module ear project with maven. I have put the tests into a separate project. To test my seam components i use jboss embedded inside maven. My project structure looks like this:


      relis
      |-- relis-ear
      |   -- src
      |       -- main
      |           |-- application
      |           |   -- META-INF
      |           -- resources
      |-- relis-ejb
      |   -- src
      |       |-- main
      |       |   |-- java
      |       |   |   -- com
      |       |   |       -- hp
      |       |   |           -- relis
      |       |   |               |-- action
      |       |   |               |-- dao
      |       |   |               -- model
      |       |   -- resources
      |       |       -- META-INF
      |       -- test
      |-- relis-test
      |   |-- bootstrap
      |   |   |-- META-INF
      |   |   |-- conf
      |   |   |   -- props
      |   |   |-- deploy
      |   |   |   |-- jboss-local-jdbc.rar
      |   |   |   |   -- META-INF
      |   |   |   -- messaging
      |   |   |-- deployers
      |   |   -- stylesheets
      |   -- src
      |       |-- main
      |       -- test
      |           |-- java
      |           |   -- com
      |           |       -- hp
      |           |           -- relis
      |           |               -- test
      |           -- resources
      |               -- META-INF
      -- relis-web
          -- src
              |-- main
              |   |-- java
              |   |-- resources
              |   -- webapp
              |       |-- META-INF
              |       -- WEB-INF
              |           -- lib
              -- test
      



      When i run mvn test inside my parent project, everythings works fine. the jboss embedded starts up properly and my test succeeds.


      But when i run mvn package or install the tests fail, because hibernate does not register my entity. In the log i have noticed the following lines:


      WARN  [org.hibernate.ejb.packaging.InputStreamZippedJarVisitor] Unable to find file (ignored): jar:file:/home/relisdev01/relis/project/relis/relis-ejb/target/relis-ejb-0.0.1-SNAPSHOT.jar!/
      java.io.IOException: no entry name specified
      .
      .
      ERROR [org.jboss.aspects.tx.TxPolicy] javax.ejb.EJBTransactionRolledbackException: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select username from User where username = :el1]



      My test project pom looks like this:


      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
              <parent>
                      <artifactId>relis</artifactId>
                      <groupId>com.hp.relis</groupId>
                      <version>0.0.1-SNAPSHOT</version>
              </parent>
              <modelVersion>4.0.0</modelVersion>
              <groupId>com.hp.relis</groupId>
              <artifactId>relis-test</artifactId>
              <packaging>jar</packaging>
              <name>relis-test</name>
              <version>0.0.1-SNAPSHOT</version>
      
              <dependencies>
                      <dependency>
                              <groupId>com.hp.relis</groupId>
                              <artifactId>relis-ejb</artifactId>
                              <version>${project.version}</version>
                              <type>ejb</type>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam.embedded</groupId>
                              <artifactId>jboss-embedded-all</artifactId>
                              <version>beta3</version>
                              <scope>test</scope>
                              <exclusions>
                                      <exclusion>
                                              <groupId>org.jboss.microcontainer</groupId>
                                              <artifactId>jboss-deployers-client-spi</artifactId>
                                      </exclusion>
                              </exclusions>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam.embedded</groupId>
                              <artifactId>jboss-embedded-api</artifactId>
                              <version>beta3</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam.embedded</groupId>
                              <artifactId>hibernate-all</artifactId>
                              <version>beta3</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam.embedded</groupId>
                              <artifactId>thirdparty-all</artifactId>
                              <version>beta3</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam</artifactId>
                              <version>${seam.version}</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-el</artifactId>
                              <version>2.0.0.GA</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>javax.faces</groupId>
                              <artifactId>jsf-api</artifactId>
                              <version>${jsf.version}</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>javax.el</groupId>
                              <artifactId>el-api</artifactId>
                              <version>1.0</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>javax.activation</groupId>
                              <artifactId>activation</artifactId>
                              <version>1.1</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.testng</groupId>
                              <artifactId>testng</artifactId>
                              <version>5.8</version>
                              <classifier>jdk15</classifier>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.slf4j</groupId>
                              <artifactId>slf4j-api</artifactId>
                              <version>1.4.2</version>
                              <scope>test</scope>
                      </dependency>
                      <dependency>
                              <groupId>org.slf4j</groupId>
                              <artifactId>slf4j-nop</artifactId>
                              <version>1.4.2</version>
                              <scope>test</scope>
                      </dependency>
              </dependencies>
      
              <build>
                      <testResources>
                              <testResource>
                                      <directory>bootstrap</directory>
                              </testResource>
                              <testResource>
                                      <directory>src/test/resources</directory>
                              </testResource>
                      </testResources>
              </build>
      
              <reporting>
                      <plugins>
                              <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-surefire-report-plugin</artifactId>
                                      <version>2.4.2</version>
                              </plugin>
                      </plugins>
              </reporting>
      
      </project>
      



      I have no idea why my test does not run whithin package or install but otherwise runs correct when i run mvn test alone.
      Does anybody have a hint what i am doing wrong?


      Thanks in advance!
      Serkan

        • 1. Re: hibernate is is unable to find my ejbs.jar
          ssatir

          OK. I didn't solve the problem, but made a workaround. I integrated the seamtests into the EJB Project. Now everything works fine. Nevertheless very strange.
          Bye

          • 2. Re: hibernate is is unable to find my ejbs.jar
            spagop

            I also got today in my application the same problem. That will great, if you can describe how you solve the problem. This can be useful for other seam users.


            Error:
            Caused by: javax.el.ELException: javax.ejb.EJBTransactionRolledbackException: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped


            Thanks   

            • 3. Re: hibernate is is unable to find my ejbs.jar
              caye

              I am facing also the same issue. Any ideas of how to get it working? For me is impossible to make the same workaround since i cannot instantiate the ears from the ejb

              • 4. Re: hibernate is is unable to find my ejbs.jar
                caye

                Finally i managed to solve it, it was because hibernate seems unable of find the entities once packaged in seam if we are testing from another module, so all you have to do at the end is declare the whole package name before the entity. So in your case it might be the query like




                select user.username from com.hp.relis.model.User user where user.username = :ell





                more or less.. :)