title: NoClassDefFoundError: javax/persistence/Converter when importing jpa application context in webservice module
body: <p>I'm getting the following error when calling the jpa module from my webservice module in my multi-module maven project.</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring/applicationContext-mysql.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/persistence/Converter</p>
  </blockquote>
  
  <p>I've added a resource import in my spring-ws-servlet.xml file in the webservice module</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:sws="http://www.springframework.org/schema/web-services" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
    &lt;context:component-scan base-package="org.learn.spring" /&gt;
  
    &lt;sws:annotation-driven/&gt;
  
    &lt;sws:dynamic-wsdl id="osinvoke" portTypeName="EAIOSInvoke" locationUri="/osinvoke/" targetNamespace="http://spring.learn.com/eai/definitions"&gt;
      &lt;sws:xsd location="/WEB-INF/osinvoke.xsd" /&gt;
    &lt;/sws:dynamic-wsdl&gt;
  
    &lt;import resource="classpath:/spring/applicationContext-mysql.xml" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>And here is the applicationContext-mysql.xml file from the jpa module</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:security="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
                  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
                  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"&gt;
  
    &lt;tx:annotation-driven /&gt;
    &lt;context:annotation-config /&gt;
    &lt;context:component-scan base-package="org.learn.spring" /&gt;
  
    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/cmddb" /&gt;
      &lt;property name="username" value="testdb" /&gt;
      &lt;property name="password" value="testpass" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="persistenceUnitName" value="jpaData" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
        &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
        &lt;props&gt;
          &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
          &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;prop key="hibernate.format_sql"&gt;false&lt;/prop&gt;
          &lt;prop key="hibernate.hbm2ddl.auto"&gt;validate&lt;/prop&gt;
        &lt;/props&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
    &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
    &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>The unit tests in jpa module are able to detect the application context and create the entity manager from the context file.  The webservice module is unable to create the entityManagerFactory object.</p>