Announcement Announcement Module
Collapse
No announcement yet.
Using Criteria Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Criteria

    Hi,

    I am trying to use Criteria in my Spring 3 / JPA / Maven project.

    I keep getting
    Code:
    NoClassDefFoundError: javax/persistence/criteria/Selection
    or
    Code:
    java.lang.NoSuchMethodError: javax.persistence.EntityManager.getCriteriaBuilder()Ljavax/persistence/criteria/CriteriaBuilder;
    I don't really know the difference between the com.springsource.* artifacts and the others I find. Where can I learn more about these? I feel that I missing information like hibernate release notes, ...

    Does anybody have a working pom.xml with Criteria? Which hibernate version is required?

    Here are most of the project's dependencies. (Sorry for posting the long list)
    Code:
    	<properties>
    		<vaadin.version>6.5.4</vaadin.version>
    		<spring.version>3.0.5.RELEASE</spring.version>
    		<spring-security.version>3.0.5.RELEASE</spring-security.version>
    		<aspectj.version>1.6.8.RELEASE</aspectj.version>
    	</properties>
    	<dependencies>
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-core</artifactId>
    			<version>${spring-security.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-config</artifactId>
    			<version>${spring-security.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<!-- <dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-openid</artifactId>
    			<version>${spring-security.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-taglibs</artifactId>
    			<version>${spring-security.version}</version>
    			<scope>compile</scope>
    		</dependency>-->
    		<dependency> <!-- for login.jsp -->
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-web</artifactId>
    			<version>${spring-security.version}</version>
    		</dependency>
    		<!-- when using Spring 2.x <dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-core-tiger</artifactId>
    			<version>${spring-security.version}</version>
    		</dependency> -->
    		
    		<!-- SPRING FRAMEWORK -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.core</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.test</artifactId>
    			<version>${spring.version}</version>
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.context</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.aop</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.aspects</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.jdbc</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.orm</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.transaction</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.web</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>org.springframework.web.servlet</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		
    		<!-- SPRINGSOURCE -->
    		<dependency>
    			<groupId>org.apache.commons</groupId>
    			<artifactId>com.springsource.org.apache.commons.logging</artifactId>
    			<version>1.1.1</version>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet</groupId>
    			<artifactId>com.springsource.javax.servlet.jsp.jstl</artifactId>
    			<version>1.2.0</version>
    		</dependency>
     		<dependency>
    			<groupId>org.hibernate</groupId>
    			<artifactId>com.springsource.org.hibernate.annotations</artifactId>
    			<version>3.3.1.ga</version>
    		</dependency>
    		<dependency>
    			<groupId>org.hibernate</groupId>
    			<artifactId>com.springsource.org.hibernate.ejb</artifactId>
    			<version>3.4.0.GA</version>
    			<!--<version>3.3.2.GA</version>-->
    		</dependency>
    		<dependency>
    			<groupId>org.hibernate</groupId>
    			<artifactId>com.springsource.org.hibernate.validator</artifactId>
    			<version>4.0.0.GA</version>
    			<exclusions>
    				<exclusion>
    					<groupId>org.slf4j</groupId>
    					<artifactId>slf4j-api</artifactId>
    				</exclusion>
    			</exclusions>
    		</dependency>
    		<dependency>
    			<groupId>javax.validation</groupId>
    			<artifactId>com.springsource.javax.validation</artifactId>
    			<version>1.0.0.GA</version>
    		</dependency>
    		<dependency>
    			<groupId>javax.transaction</groupId>
    			<artifactId>com.springsource.javax.transaction</artifactId>
    			<version>1.1.0</version>
    		</dependency>
    		<dependency>
    			<groupId>org.apache.log4j</groupId>
    			<artifactId>com.springsource.org.apache.log4j</artifactId>
    			<version>1.2.15</version>
    		</dependency>
    		<dependency>
    			<groupId>com.mysql.jdbc</groupId>
    			<artifactId>com.springsource.com.mysql.jdbc</artifactId>
    			<version>5.1.6</version>
    		</dependency>
    
    		<!--  for criteria -->
    		<dependency>
    		  <groupId>org.hibernate</groupId>
    		  <artifactId>hibernate-entitymanager</artifactId>
    		  <version>3.5.1-Final</version>
    		</dependency>
    		<!-- <dependency>
    		  <groupId>org.hibernate.javax.persistence</groupId>
    		  <artifactId>hibernate-jpa-2.0-api</artifactId>
    		  <version>1.0.0.Final</version>
    		</dependency> --> 
    		<dependency>
    			<groupId>javax.persistence</groupId>
    			<artifactId>com.springsource.javax.persistence</artifactId>
    			<version>2.0.0</version>
    		</dependency>
    		<dependency>
    			<groupId>org.hibernate.java-persistence</groupId>
    			<artifactId>jpa-api</artifactId>
    			<version>2.0-cr-1</version>
    		</dependency>
    		<!-- <dependency>
    			<groupId>org.springframework.data</groupId>
    			<artifactId>spring-data-commons-core</artifactId>
    			<version>1.0.0.RELEASE</version>
    		</dependency>-->
    
    	</dependencies>
    Thanks,
    Ropo

  • #2
    Judging from the stacktrace you have jpa 1 somewhere in your classpath which is loaded/detected before jpa 2 api... Hence your errors.. Check your dependencies and try to figure out what is pulling in that dependency or check your server (I guess it is at deployment time?).

    Comment

    Working...
    X