2

我在 Glassfish 3.1 上使用 JSF2 和 JPA Eclipse Link。

我在本地环境中开发了一个应用程序,在那里我没有任何问题。现在我试图将它部署在公共服务器上,但我最终遇到了一些奇怪的行为。

尝试部署应用程序时出现以下错误:

java.lang.UnsupportedOperationException

堆栈跟踪如下所示:

Critical error during deployment: java.lang.ExceptionInInitializerError
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at     java.lang.Class.newInstance0(Class.java:355) 
java.lang.Class.newInstance(Class.java:308)
com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:256)
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:255)
    org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
com.sun.enterprise.web.WebModule.start(WebModule.java:500)
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDe    ploymentFacility.java:143)
org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:406)
org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:100)
org.glassfish.admingui.common.util.DeployUtil.deploy(DeployUtil.java:76)
org.glassfish.admingui.common.handlers.DeploymentHandler.deploy(DeploymentHandler.java:191)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420) 
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394) 
at com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150) 
at com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98) 
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) 
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769) 
at javax.faces.component.UICommand.broadcast(UICommand.java:300) 
at com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166) 
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) 
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) 
at     com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) 
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409) 
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:223) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 
at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600) 
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96) 
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228) 
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
at java.lang.Thread.run(Thread.java:662) Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader (delegate=true; repositories=WEB-INF/classes/) Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [Maze] failed. Internal Exception: Exception [EclipseLink-7333] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException Exception Description: The reference column name [id] mapped on the element [field country] does not correspond to a valid field on the mapping reference. 
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126) 
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:105) 
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) 
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) 
at com.maze.factory.EMFactory.initComplete(EMFactory.java:30) 
at com.maze.factory.EMFactory.getInstance(EMFactory.java:23) 
at com.maze.service.BaseService.<init>(BaseService.java:12) 
at com.maze.service.CountryService.<init>(CountryService.java:14) 
at com.maze.service.factory.ServiceFactory.getCountryService(ServiceFactory.java:47) 
at com.maze.util.Constants.<clinit>(Constants.java:175) ... 88 more Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [Maze] failed. Internal Exception: Exception [EclipseLink-7333] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException Exception Description: The reference column name [id] mapped on the element [field country] does not correspond to a valid field on the mapping reference. 
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1127) 
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:101) 
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:96) ... 96 more Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [Maze] failed. Internal Exception: Exception [EclipseLink-7333] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException Exception Description: The reference column name [id] mapped on the element [field country] does not correspond to a valid field on the mapping reference. 
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 99 more Caused by: Exception [EclipseLink-7333] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException Exception Description: The reference column name [id] mapped on the element [field country] does not correspond to a valid field on the mapping reference. 
at org.eclipse.persistence.exceptions.ValidationException.invalidReferenceColumnName(ValidationException.java:1793) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:437) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:386) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processOneToOneForeignKeyRelationship(MappingAccessor.java:1574) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOneToOneForeignKeyRelationship(ObjectAccessor.java:614) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:667) 
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:110) 
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1350) 
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1572) 
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:486) 
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:454) 
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1081) ... 98 more

** 映射在元素 [field country] 上的引用列名称 [id] 与映射引用上的有效字段不对应。**

现在我是否理解涉及 Country 实体和 Id 字段的映射以某种方式涉及?依靠这一点,我删除了所有涉及 Country 实体的 JPA 映射,但我仍然收到此错误。

我错过了什么?

4

1 回答 1

0

只是一个疯狂的猜测。您是否已经有了要通过 jpa 创建或插入值的表。

看起来表架构和数据库与您的 java 应用程序不匹配。

于 2012-05-07T08:54:05.763 回答