最近我将我的开发从Glassfish 4.1迁移到Payara-4.1.1.161.1。
今天我重新开放了几个月未触及的项目。 当我尝试编译并运行项目时,我在控制台日志中看到以下内容
Severe: WebModule[/EstoreAdmin]StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/rs/exceptions/ClassNotFoundExceptionMapper
at com.app.service.ApplicationConfig.addRestResourceClasses(ApplicationConfig.java:27)
at com.app.service.ApplicationConfig.getClasses(ApplicationConfig.java:16)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig$3.run(ResourceConfig.java:1234)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.registerComponentsOf(ResourceConfig.java:1216)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1190)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1178)
at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1174)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:345)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:390)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:172)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:364)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5732)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5977)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:353)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.rs.exceptions.ClassNotFoundExceptionMapper
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1795)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
... 70 more
我花了很多时间试图找出正在发生的事情,将项目恢复到第一阶段,但我仍然无法启动它。
在绝望的举动中,我决定尝试在旧的Glassfish 4.1上发布这个项目(它仍然在我的硬盘上)。 它开始没有任何问题。
我不知道问题的根源是什么。 它与ide生成的部分
有某种关联@javax.ws.rs.ApplicationPath("webresources")
public class ApplicationConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new java.util.HashSet<>();
addRestResourceClasses(resources);
return resources;
}
/**
* Do not modify addRestResourceClasses() method.
* It is automatically populated with
* all resources defined in the project.
* If required, comment out calling this method in getClasses().
*/
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(org.eclipse.persistence.jpa.rs.exceptions.ClassNotFoundExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.ConversionExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.DatabaseExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.EntityExistsExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.EntityNotFoundExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.IOExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.IllegalAccessExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.IllegalArgumentExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.IllegalStateExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.InvocationTargetExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.JAXBExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.JPARSConfigurationExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.JPARSExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.MalformedURLExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.NamingExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.NoResultExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.NoSuchMethodExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.NonUniqueResultExceptionExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.OptimisticLockExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.PersistenceExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.PessimisticLockExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.QueryTimeoutExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.RollbackExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.TransactionRequiredExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.exceptions.UnsupportedMediaTypeExceptionMapper.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.EntityResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.PersistenceResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.PersistenceUnitResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.QueryResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.SingleResultQueryResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.unversioned.EntityResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.unversioned.PersistenceResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.unversioned.PersistenceUnitResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.unversioned.QueryResource.class);
resources.add(org.eclipse.persistence.jpa.rs.resources.unversioned.SingleResultQueryResource.class);
}
我尝试过切换JDK。 JDK 1.8.77和1.8.91的行为方式相同。 我也尝试过pre relase payara build,同样的。
你能否给我一些建议,以便与Payara合作,如何追踪错误。
我认为这种行为与我的应用程序使用持久性模块中定义的2个连接这一事实有某种联系。
如果我禁用了行
addRestResourceClasses(resources);
然后应用程序启动(但我的登录控制器没有工作,应用程序在登录尝试时遇到异常)。
所以我再次启用该行,但在登录控制器中,我用@Named替换了@ManagedBean并略微调整了控制器。 在此之后,我再也看不到错误了。我不知道为什么这会有所帮助。
答案 0 :(得分:2)
原始错误是:
java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/rs/exceptions/ClassNotFoundExceptionMapper
原因是ClassNotFoundExceptionMapper类已在Payara使用的Eclipselink版本中重构。
GlassFish 4.1
使用&lt; 2.5.2
(Payara 4.1.144
- 源自该版本的GlassFish - 集成2.5.2-RC1
)which still contains that class
The class has been replaced by the AbstractExceptionMapper,因此您需要重构您的应用以适应。
使用Eclipselink版本的最新版Payara&lt; 2.6
版本4.1.151
现已超过一年,因此推荐的选项是更改代码而不是降级服务器。