title: error deploying a SpringData JPA2, hibernate cxf web service in jboss AS 7.2
body: <p>I am developing a SpringData/JPA2 web service that uses Hibernate as the persistence provider.
  It uses the following frameworks:
  <code>cxf=2.6.2</code>
  <code>hibernate= 4.1.1.Final</code>
  <code>springframework=3.1.2.RELEASE</code>
  <code>spring.data=1.2.0.RELEASE</code></p>
  
  <p>The database related code is in the "core sub-module" which works fine while unit testing from Eclipse. I have another sub-module for the webservice which has the core-submodule as a dependency. It seems to work fine so far during development when I did unit testing from eclipse. 
  Now, that I have made sufficient progress, I am attempting to deploy it into a new install of jboss AS 7.2 in my desktop.
  I have set up the datasource in the standalone.xml and also deployed the driver for jTDS 1.2.7 in the modules directory.</p>
  
  <p>When I deploy my war file, I am getting this error stack trace. I cannot figure out where to start in trouble shooting this error. So any hints or pointes are appreciated as I am at a loss as to where to start:(
  The stack trace is pasted below:</p>
  
  <pre><code>    15:52:34,954 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (MSC service thread 1-3) 
      Bean 'entityManagerFactory' of type [class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
      15:52:34,972 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (MSC service thread 1-3) 
      Bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
      15:52:34,976 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (MSC service thread 1-3) 
      Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
      15:52:34,983 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) 
      Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1bb71ac: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#1,dataSource,entityManagerFactory,entrLoanRepository,keyRefRepository,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,addKeyRefService,createEntrLoanService,disableAllKeyRefService,retrieveEntrLoanService,entrLoanServiceImpl,keyRefServiceImpl,retrieveKeyRefService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
      15:52:35,487 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) 
      Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1bb71ac: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#1,dataSource,entityManagerFactory,entrLoanRepository,keyRefRepository,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,addKeyRefService,createEntrLoanService,disableAllKeyRefService,retrieveEntrLoanService,entrLoanServiceImpl,keyRefServiceImpl,retrieveKeyRefService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
      15:52:35,499 INFO  [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] (MSC service thread 1-3) 
      Closing JPA EntityManagerFactory for persistence unit 'persistenceUnit'
      15:52:35,503 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) 
      MSC00001: Failed to start service jboss.deployment.unit."euclid-ws.war".
      INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."euclid-ws.war".
      INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "euclid-ws.war"
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Alpha1-SNAPSHOT.jar:7.2.0.Alpha1-SNAPSHOT]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_33]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_33]
          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_33]
      Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'entrLoanServiceImpl': Injection of resource dependencies failed; 
      nested exception is org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'entrLoanRepository': 
      FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
          at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.newInstance(NonSpringBusHolder.java:174)
          at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:96)
          at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:129)
          at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:68)
          at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:74)
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Alpha1-SNAPSHOT.jar:7.2.0.Alpha1-SNAPSHOT]
          ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'entrLoanServiceImpl': Injection of resource dependencies failed; 
      nested exception is org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'entrLoanRepository': 
      FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
          at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
          at com.sgbeuclid.ws.web.ServicingContext.getAppContext(ServicingContext.java:16)
          at com.sgbeuclid.ws.web.Euclid.&lt;init&gt;(Euclid.java:52)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_33]
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_33]
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_33]
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_33]
          at java.lang.Class.newInstance0(Class.java:355) [rt.jar:1.6.0_33]
          at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_33]
          at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.newInstance(NonSpringBusHolder.java:170)
          ... 10 more
      Caused by: org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'entrLoanRepository': FactoryBean threw exception on object creation; 
      nested exception is java.lang.NullPointerException
          at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
          at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:443)
          at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:417)
          at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:559)
          at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
          at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
          ... 31 more
      Caused by: java.lang.NullPointerException
          at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:73)
          at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:115)
          at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149)
          at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1220)
          at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:178)
          at org.hibernate.ejb.EntityManagerImpl.&lt;init&gt;(EntityManagerImpl.java:89)
          at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:179)
          at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:174)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_33]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_33]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_33]
          at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_33]
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:376)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:517)
          at $Proxy37.createEntityManager(Unknown Source) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:234)
          at $Proxy40.createNamedQuery(Unknown Source)    at org.springframework.data.jpa.repository.query.NamedQuery.&lt;init&gt;(NamedQuery.java:60)
          at org.springframework.data.jpa.repository.query.NamedQuery.lookupFrom(NamedQuery.java:111)
          at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:125)
          at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:160)
          at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
          at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:280)
          at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148)
          at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125)
          at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41)
          at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
          ... 41 more
  
      15:52:35,611 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 1) 
      JBAS015870: Deploy of deployment "euclid-ws.war" was rolled back with the following failure message: 
      {"JBAS014671: Failed services" =&gt; {"jboss.deployment.unit.\"euclid-ws.war\".
      INSTALL" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"euclid-ws.war\".
      INSTALL: JBAS018733: Failed to process phase INSTALL of deployment \"euclid-ws.war\"
          Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entrLoanServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entrLoanRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entrLoanServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entrLoanRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entrLoanRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
          Caused by: java.lang.NullPointerException"}}
      15:52:35,688 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment euclid-ws.war in 76ms
  </code></pre>
  
  <p>Basically, it looks like it is getting a nullpointer when it is attempting to instantiate the Repository.</p>
  
  <p>Here is the web.xml. Should I be using the CXFServlet ? Or does this look sufficient?</p>
  
  <pre><code>    &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
            version="2.5"&gt; 
  
          &lt;context-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath*:META-INF/spring/applicationContext-ws.xml&lt;/param-value&gt;
          &lt;/context-param&gt;
  
          &lt;listener&gt;
              &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
          &lt;/listener&gt;
  
  
          &lt;!-- 
          commenting out the CXFServlet . It does not appear to be needed while deploying to jboss.
          &lt;servlet&gt;
              &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
              &lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt;
              &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
          &lt;/servlet&gt;
  
          &lt;servlet-mapping&gt;
              &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
              &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;/servlet-mapping&gt;
  
          &lt;session-config&gt;
              &lt;session-timeout&gt;60&lt;/session-timeout&gt;
          &lt;/session-config&gt;
           --&gt;
  
          &lt;servlet&gt;
              &lt;servlet-name&gt;euclid&lt;/servlet-name&gt;
              &lt;servlet-class&gt;com.sgb.euclid.ws.web.Euclid&lt;/servlet-class&gt;
              &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
          &lt;/servlet&gt;
          &lt;servlet-mapping&gt;
              &lt;servlet-name&gt;euclid&lt;/servlet-name&gt;
              &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;/servlet-mapping&gt;
  
      &lt;/web-app&gt;
  </code></pre>
  
  <p>Also, probably not related, but nice to know.
  In the, I saw a WARNing message :</p>
  
  <pre><code>JBAS016012: Deployment deployment "euclid-ws.war" contains CDI annotations but beans.xml was not found.
  </code></pre>
  
  <p>Should I have an empty beans.xml file in WEB-INF although I am not attempting to use CDI explicitly? Or can I safely ignore the warning as I am attempting to use the Spring Container instead?</p>