Announcement Announcement Module
Collapse
No announcement yet.
Can't find method javax.persistence.criteria.CriteriaBuilder - Hibernate 3.5.1-Final Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't find method javax.persistence.criteria.CriteriaBuilder - Hibernate 3.5.1-Final

    Hello,

    With Hibernate 3.5.1-Final, I got the following error when I deployed the war file onto tomcat 6.0.8.

    Caused by: java.lang.NoSuchMethodError: javax.persistence.EntityManager.getCriteriaBuilder ()Ljavax/persistence/criteria/CriteriaBuilder;
    at com.ix.msp.persistence.jpa.AbstractFacade.findAll( AbstractFacade.java:56)
    at com.ix.msp.domain.loader.VocabularyLoader.afterPro pertiesSet(VocabularyLoader.java:88)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1469)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1409)
    ... 38 more
    Here is my pom.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <project 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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ixsystems</groupId>
    <artifactId>ixsystems-product-registration-with-criteria</artifactId>
    <name>iXSystems Product Registration with Criteria</name>
    <description>Product registration portlet with criteria</description>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <pluginRepositories>
    <pluginRepository>
    <id>com.springsource.repository.bundles.release</id>
    <name>SpringSource Enterprise Bundle Repository -
    SpringSource Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/release</url>
    </pluginRepository>
    <pluginRepository>
    <id>com.springsource.repository.bundles.external </id>
    <name>SpringSource Enterprise Bundle Repository - External
    Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/external</url>
    </pluginRepository>
    <pluginRepository>
    <id>com.springsource.repository.bundles.mileston e</id>
    <name>SpringSource Enterprise Bundle Repository - External
    Bundle Milestones</name>
    <url>http://repository.springsource.com/maven/bundles/milestone</url>
    </pluginRepository>
    </pluginRepositories>
    <properties>
    <servlet-api.version>2.5</servlet-api.version>
    <portlet-api.version>2.0</portlet-api.version>
    <jstl.version>1.1.2</jstl.version>
    <spring.version>3.0.2.RELEASE</spring.version>
    <hibernate.version>3.5.6-Final</hibernate.version>
    ....
    <liferay.deploy.dir>${liferay.home}/deploy</liferay.deploy.dir>
    </properties>
    <dependencies>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>${hibernate.version}</version>
    <type>jar</type>
    <scope>compile</scope>
    </dependency>

    </dependencies>
    <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <source>1.5</source>
    <target>1.5</target>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.5</version>
    <configuration>
    <workingDirectory>src/main/webapp</workingDirectory>
    <systemPropertyVariables>
    <catalina.base>${catalina.base}</catalina.base>
    </systemPropertyVariables>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.0</version>
    <dependencies>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>${aspectj.version}</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjtools</artifactId>
    <version>${aspectj.version}</version>
    </dependency>
    </dependencies>
    <executions>
    <execution>
    <goals>
    <goal>compile</goal>
    <goal>test-compile</goal>
    </goals>
    </execution>
    </executions>
    <configuration>
    <outxml>true</outxml>
    <aspectLibraries>
    <aspectLibrary>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    </aspectLibrary>
    </aspectLibraries>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>
    <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>run</goal>
    </goals>
    <configuration>
    <tasks>
    <copy
    file="${project.build.directory}/${artifactId}.war"
    tofile="${liferay.deploy.dir}/${artifactId}.war"></copy>
    </tasks>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    <reporting>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.5</version>
    </plugin>
    </plugins>
    </reporting>
    </project>
    The offending line in AbstractFacade.java is:

    public List<T> findAll() {
    CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); <=== offending line
    javax.persistence.criteria.CriteriaQuery<T> cq = cb.createQuery(entityClass);
    cq.select(cq.from(entityClass));
    return getEntityManager().createQuery(cq).getResultList() ;
    }
    Very appreciate for any suggestion and help.

    Thanks
    Sam
    Last edited by samsam007; Jul 12th, 2011, 01:05 AM.

  • #2
    Just checking out a maven repo, I would make sure the dependencies are being resolved. http://repo1.maven.org/maven2/org/hibernate/hibernate/

    Comment


    • #3
      This API is part of persistence.jar which is also a compile time dependency (since it is manadated by JSR specification) although the implementation is provided by Hibernate EnttiyManager project.


      http://docs.jboss.org/hibernate/enti...single/#d0e215 (read section 2.1 Setup)

      "Copy lib/jpa/hibernate-jpa-2.0-api-1.0.0.Final.jar to your classpath as well." I believe this to be Hibernates fixed/improved persistence.jar.

      So check the "effective pom.xml" to confirm this dependancy is being pulled in. Because it is a JSR spec, it may not be automatically pulled in by Maven project hibernate-entitymanager as a dependency.



      Ah also check that Hibernate 3.5.x supports JPA2. I would guess CriteriaBuilder is a JPA2 feature, you may find that Hibernate 3.6.x is the first version to claim full JPA2 support ? 3.5.x might have no or partial support for JPA2 but full support for JPA1.
      Last edited by dlmiles; Jul 13th, 2011, 04:53 PM.

      Comment

      Working...
      X