NullPointerException 从 EntityManagerFactory 创建 EntityManager

NullPointerException creating EntityManager from EntityManagerFactory

我已经成功创建了一个 EntityManagerFactory,使用我 persistence.xml 中添加的持久化单元,但控制台日志显示以这种方式创建 EntityManager 时出现异常:

EntityManagerFactory emf;
EntityManager em;
...
emf = Persistence.createEntityManagerFactory("unidadPersistencia");
em = emf.createEntityManager(); //the error is in this line.

应用程序识别连接并正确table。但我无法创建 EntityManager。

实体:

@Entity
@Table(name = "CVINSTELEMATICA")
public class SolicitudTelematica extends AbstractEntity{

    private static final long serialVersionUID = 1L;

    @Id
    @NotNull
    @Column(name = "ID")
    private long idTelematica;

    @Column(name = "NUMEROMENORES", columnDefinition = "smallint")
    private int numeroMenores;

    @Column(name = "NIFTUTOR", columnDefinition = "nvarchar")
    private String nifTutor; 

Persistence.xml:

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="unidadPersistencia"  transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>  
         <class>es.xunta.amtega.vp301b.entity.SolicitudTelematica</class>
         <properties>
            <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
            <property name="javax.persistence.jdbc.url" value="DB_URL"/> 
            <property name="javax.persistence.jdbc.user" value="usr"/>
            <property name="javax.persistence.jdbc.password" value=pwd/>
         </properties>
    </persistence-unit>
</persistence>

持久性文件或实体中可能缺少某些内容?

跟踪:

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2) 2019-03-26 09:26:45,865 ERROR [http-localhost/127.0.0.1:8443-2] Error: es.xunta.amtega.vp301b.interfaz.web.InterfazController.sacarString() es.xunta.amtega.transversal.archam.core.exception.InternalErrorException

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.transversal.archam.core.aop.LoggingAspect.translate(LoggingAspect.java:130)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.transversal.archam.core.aop.LoggingAspect.logAfterExceptionThrowing(LoggingAspect.java:67)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at java.lang.reflect.Method.invoke(Method.java:606)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)

09:26:45,867 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:609)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:66)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.vp301b.interfaz.web.InterfazController$$EnhancerBySpringCGLIB$$fa3183e9.sacarString(<generated>)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at java.lang.reflect.Method.invoke(Method.java:606)

09:26:45,868 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

09:26:45,869 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.transversal.archam.core.web.filter.RefererManagerFilter.doFilter(RefererManagerFilter.java:78)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,870 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)

09:26:45,871 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:124)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

09:26:45,872 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.transversal.archam.core.web.filter.ExecutionContextFilter.doFilter(ExecutionContextFilter.java:73)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,873 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:122)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.transversal.archam.core.web.filter.ExceptionAwareMultipartFilter.doFilterInternal(ExceptionAwareMultipartFilter.java:64)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,874 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

09:26:45,875 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at java.lang.Thread.run(Thread.java:745)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2) Caused by: java.lang.NullPointerException

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:118)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149)

09:26:45,876 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.jpa.spi.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1602)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.jpa.spi.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:210)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.jpa.internal.EntityManagerImpl.<init>(EntityManagerImpl.java:91)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.jpa.internal.EntityManagerFactoryImpl.internalCreateEntityManager(EntityManagerFactoryImpl.java:345)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.hibernate.jpa.internal.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:313)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.vp301b.interfaz.web.InterfazController.sacarString(InterfazController.java:122)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at es.xunta.amtega.vp301b.interfaz.web.InterfazController$$FastClassBySpringCGLIB$a2d1d25.invoke(<generated>)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)

09:26:45,877 INFO  [stdout] (http-localhost/127.0.0.1:8443-2)   ... 90 more

我正在使用 JBoss EAP 6.1 和 Java 7.

我认为当您使用 JTA 作为事务类型时,您必须处于 JEE 环境中,这样容器(JBoss,在您的情况下)将使用注释 @PersistenceContext 处理实体管理器, 但是这里你自己处理实体管理器,创建实体管理器工厂,你不是在 JEE 环境中,你只是在使用 Java SE,所以我认为你必须将 transaction-type="JTA" 更改为 transaction-type="RESOURCE_LOCAL" 在你的持久化单元 XML 文件中。