Fra83
Fra83

Reputation: 521

ClassNotFoundException when I add PersistenceExceptionTranslationPostProcess in applicationContext.xml

I want to include PersistenceExceptionTranslationPostProcessor in my application.

I have a web project and an ejb project

In the web project, i added in applicationContext.xml

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

and in web.xml I set

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/dispatcher-config.xml,
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>

Then, in ejb project, I have pom.xml like this:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.2.3.RELEASE</version>
        <scope>provided</scope>
    </dependency>

and have class with @repository annotation. So, when I start my web application, I have the following error:

java.lang.ClassNotFoundException: org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor

If I delete, from my web.xml the loading of application.xml, the error disappears. Does anyone know the right configuration for this problem?

This is pom of web tier

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>com.app</groupId>
        <artifactId>delegate</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.5.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.5.2</version>
    </dependency>
    <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>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.security.version}</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.1</version>
    </dependency>
</dependencies>

this is pom of delegate tier

<dependency>
<groupId>com.app</groupId>
<artifactId>ejb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>ejb</type>

this is pom of ejb tier

<dependency>
   <groupId>org.jboss.spec.javax.ejb</groupId>
   <artifactId>jboss-ejb-api_3.1_spec</artifactId>
   <version>1.0.1.Final</version>
</dependency>
<dependency>
    <groupId>com.app</groupId>
    <artifactId>ejb-util</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.8.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.annotation</groupId>
    <artifactId>jboss-annotations-api_1.1_spec</artifactId>
    <version>1.0.0.Final</version>
<scope>provided</scope>

and finally this is pom of ejb-util

<dependency>
   <groupId>org.jboss.spec.javax.ejb</groupId>
   <artifactId>jboss-ejb-api_3.1_spec</artifactId>
   <version>1.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.interceptor</groupId>
    <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
    <version>1.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.2.11.Final</version>
    <scope>provided</scope>
</dependency>
<dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>3.2.3.RELEASE</version>
    <scope>provided</scope>
</dependency>  

this is ear pom

<dependency>
    <groupId>com.app</groupId>
    <artifactId>web</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
</dependency>
<dependency>
    <groupId>com.app</groupId>
    <artifactId>ejb</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>ejb</type>
</dependency>

Upvotes: 0

Views: 104

Answers (1)

Alan Hay
Alan Hay

Reputation: 23226

As the following indicates, you will find this class in the spring-tx bundle:

https://repository.sonatype.org/index.html#nexus-search;classname~org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor

So if you add the following to your POM it should work:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>3.2.3.RELEASE</version>
</dependency>

Upvotes: 1

Related Questions