我已将我的 Eclipse IDE 从 Helios 升级到 Juno。我已经更新了我的项目以使用 Juno 附带的最新版本的 EclipseLink,它是 2.4 Nightly(如持久性属性中所示)。我有一个项目本身就是一个 JPA 项目 (ProjectA),它依赖于另一个 JPA 项目 (ProjectB)。所以实际上,我有一个项目正在与 2 个单独的数据库通信。当我尝试启动在 Tomcat 下运行的 ProjectA 时,出现下面列出的异常。异常中提到的实体都位于依赖项目 - ProjectB 中。我已经重建了两个项目并重新部署。
我想知道 2.4 是否不是从 2.1.3 直接升级,并且我错过了一些升级文档,其中详细说明了我需要对我的 JPA 项目的配置进行的更改。
将 ProjectA 和 ProjectB 都恢复为 EclipseLink 2.1.3,一切正常
为了节省空间,我只列出了其中一个实体的部分例外情况,但对于项目 B 中定义的每个实体,它都会重复。
Local Exception Stack:
Exception [EclipseLink-60] (Eclipse Persistence Services - 2.4.0.v20110816-r9894): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_set_platform_vh] or [_persistence_get_platform_vh] is not defined in the object [com.blackbox.entities.db.PEcuAcronym].
Internal Exception: java.lang.NoSuchMethodException: com.blackbox.entities.db.PEcuAcronym._persistence_get_platform_vh()
Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[platform]
Descriptor: RelationalDescriptor(com.blackbox.entities.db.PEcuAcronym --> [DatabaseTable(pecuacronym)])
at org.eclipse.persistence.exceptions.DescriptorException.noSuchMethodWhileInitializingAttributesInMethodAccessor(DescriptorException.java:1170)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.initializeAttributes(MethodAttributeAccessor.java:200)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.initializeAttributes(MethodAttributeAccessor.java:181)
at org.eclipse.persistence.mappings.DatabaseMapping.preInitialize(DatabaseMapping.java:1276)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.preInitialize(ForeignReferenceMapping.java:1127)
at org.eclipse.persistence.mappings.ObjectReferenceMapping.preInitialize(ObjectReferenceMapping.java:1054)
at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3571)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:493)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:476)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:435)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:673)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:618)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:474)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:268)
at com.blackbox.dao.JpaBaseDao.findAll(JpaBaseDao.java:50)
at com.blackbox.services.Services.listAllPlatforms(Services.java:70)
at com.blackbox.services.Services.listAllPublishedPlatforms(Services.java:355)
at com.blackbox.x.actions.diagnostics.IdentifyVehicle.prepare(IdentifyVehicle.java:42)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:162)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.blackbox.x.interceptors.Log4jMDCInterceptor.intercept(Log4jMDCInterceptor.java:51)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.blackbox.x.interceptors.RedirectMessageInterceptor.doIntercept(RedirectMessageInterceptor.java:78)
at com.blackbox.x.interceptors.RedirectMessageInterceptor.intercept(RedirectMessageInterceptor.java:63)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:82)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:306)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:323)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1719)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodException: com.blackbox.entities.db.PEcuAcronym._persistence_get_platform_vh()
at java.lang.Class.getDeclaredMethod(Unknown Source)
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.findMethod(PrivilegedAccessHelper.java:82)
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getMethod(PrivilegedAccessHelper.java:283)
at org.eclipse.persistence.internal.helper.Helper.getDeclaredMethod(Helper.java:974)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.initializeAttributes(MethodAttributeAccessor.java:193)
... 94 more
需要明确的是 - 如果我自己部署 ProjectB,那么它会按预期工作。仅当我部署依赖于 ProjectB 的 JPA 项目 A 时才会出现问题。ProjectA 正确打开它自己的持久性上下文,但不是 ProjectB。
我已按要求附上了persistance.xml。
项目A;
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="Genesis" transaction-type="RESOURCE_LOCAL">
<class>com.blackbox.x.entities.SecurityKey</class>
<class>com.blackbox.x.entities.QualifiedSecurityKey</class>
<class>com.blackbox.x.entities.User</class>
<class>com.blackbox.x.entities.Password</class>
<class>com.blackbox.x.entities.ServiceDefinition</class>
<class>com.blackbox.x.entities.IdsFunction</class>
<class>com.blackbox.x.entities.FaultCodeType</class>
<class>com.blackbox.x.entities.FaultCodeDescription</class>
<class>com.blackbox.x.entities.VehicleActivityLogEntry</class>
<class>com.blackbox.x.entities.Recovery</class>
<class>com.blackbox.x.entities.SingleVehicleLicense</class>
<class>com.blackbox.x.entities.MultiVehicleLicense</class>
<class>com.blackbox.x.entities.License</class>
<class>com.blackbox.x.entities.LicenseGroupMaster</class>
<class>com.blackbox.x.entities.LicenseGroup</class>
<class>com.blackbox.x.entities.FunctionGroup</class>
<class>com.blackbox.x.entities.McodeText</class>
<class>com.blackbox.x.entities.CCFParameterMaster</class>
<class>com.blackbox.x.entities.CCFFunctionGroup</class>
<class>com.blackbox.x.entities.CCFParameterOptionUsage</class>
<class>com.blackbox.x.entities.CCFAsBuiltIndex</class>
<class>com.blackbox.x.entities.CCFEditLog</class>
<class>com.blackbox.x.entities.AsBuiltAnalyzerFileTracker</class>
<class>com.blackbox.x.entities.CCFParameterOption</class>
<class>com.blackbox.x.entities.JlrVersionControl</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
<property name="eclipselink.jdbc.user" value="userId"/>
<property name="eclipselink.jdbc.password" value="<elided>"/>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/> -->
</properties>
</persistence-unit>
和项目B;
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="ids2_develop" transaction-type="RESOURCE_LOCAL">
<description>Eclipse</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.blackbox.entities.db.Vw_Ecu</class>
<class>com.blackbox.entities.db.SwimPart</class>
<class>com.blackbox.entities.db.SoftwarePK</class>
<class>com.blackbox.entities.db.Software</class>
<class>com.blackbox.entities.db.ServiceData</class>
<class>com.blackbox.entities.db.PlatformData</class>
<class>com.blackbox.entities.db.Platform</class>
<class>com.blackbox.entities.db.PEcuTextPK</class>
<class>com.blackbox.entities.db.PEcuText</class>
<class>com.blackbox.entities.db.PEcuAcronymPK</class>
<class>com.blackbox.entities.db.PEcuAcronym</class>
<class>com.blackbox.entities.db.PEcu</class>
<class>com.blackbox.entities.db.PBusPK</class>
<class>com.blackbox.entities.db.PBus</class>
<class>com.blackbox.entities.db.Manufacturer</class>
<class>com.blackbox.entities.db.HardwarePK</class>
<class>com.blackbox.entities.db.Hardware</class>
<class>com.blackbox.entities.db.CusCom</class>
<class>com.blackbox.entities.db.CCFParameter</class>
<class>com.blackbox.entities.db.CCFGroup</class>
<class>com.blackbox.entities.db.Bus</class>
<class>com.blackbox.entities.db.BBoxCom</class>
<class>com.blackbox.entities.db.AssemblyPK</class>
<class>com.blackbox.entities.db.Assembly</class>
<class>com.blackbox.entities.db.McodeLookupKey</class>
<properties>
<property name="eclipselink.jdbc.password" value="<elided>"/>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="eclipselink.jdbc.user" value="ids2dbuser"/>
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost:3306/ids2"/>
<property name="eclipselink.logging.level" value="WARNING"/>
<property name="eclipselink.jdbc.cache-statements" value="true"/>
<property name="eclipselink.jdbc.native-sql" value="false"/>
<property name="eclipselink.cache.type.Vw_Ecu" value="NONE"/>
</properties>
</persistence-unit>