gpt4 book ai didi

java - Gretty/Jetty 无法使用 java 11、Jetty 9.4.14、gretty 加载 WebAppContext

转载 作者:太空宇宙 更新时间:2023-11-04 09:33:28 25 4
gpt4 key购买 nike

我尝试使用:

使用以下子项目 build.gradle :

apply plugin: 'war'
apply from: 'https://raw.github.com/gretty-gradle-plugin/gretty/master/pluginScripts/gretty.plugin'

gretty {
jacocoEnabled false
}

war{
archiveName project.name+".war"
}

gretty {
servletContainer = 'jetty9.4'
httpPort = 8081
}

dependencies {
[...]
grettyRunnerJetty94 group: 'org.eclipse.jetty', name: 'jetty-runner', version: '9.4.19.v20190610'
}

但是当我尝试使用: gradlew clean build runApp 运行我的服务器时,出现以下异常:

14:53:16 WARN  org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher defines neither @WebServlet.value nor @WebServlet.urlPatterns
14:53:16 WARN Failed startup of context o.a.g.JettyWebAppContext@26a94fa5{PEPS,/peps-api-server,file:///home/isinc/devel/enercal/peps-api/server/build/inplaceWebapp/,UNAVAILABLE}
java.lang.IncompatibleClassChangeError: class org.jboss.resteasy.specimpl.LinkBuilderImpl can not implement javax.ws.rs.core.Link$Builder, because it is not an interface (javax.ws.rs.core.Link$Builder is in unnamed module of loader org.akhikhl.gretty.FilteringClassLoader @20921b9b)
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[na:na]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[na:na]
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451) ~[na:na]
at org.eclipse.jetty.webapp.WebAppClassLoader.foundClass(WebAppClassLoader.java:670) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.webapp.WebAppClassLoader.loadAsResource(WebAppClassLoader.java:639) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:545) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.akhikhl.gretty.FilteringClassLoader.loadClass(FilteringClassLoader.java:72) ~[gretty-runner-jetty94-2.3.0.jar:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:87) ~[na:na]
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28) ~[na:na]
at org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.contextInitialized(GuiceResteasyBootstrapServletContextListener.java:37) ~[na:na]
at nc.enercal.gcf.peps.ServiceGuiceServletConfig.contextInitialized(ServiceGuiceServletConfig.java:30) ~[na:na]
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:959) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:553) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:924) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:365) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:854) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44) ~[gretty-runner-jetty94-2.3.0.jar:na]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:167) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:119) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:167) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.Server.start(Server.java:418) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.server.Server.doStart(Server.java:382) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-runner-9.4.19.v20190610.jar:9.4.19.v20190610]
at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) ~[groovy-2.4.15.jar:2.4.15]
at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:48) ~[gretty-runner-jetty-2.3.0.jar:na]
at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) ~[groovy-2.4.15.jar:2.4.15]
at org.akhikhl.gretty.Runner.run(Runner.groovy:121) ~[gretty-runner-2.3.0.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-2.4.15.jar:2.4.15]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) ~[groovy-2.4.15.jar:2.4.15]
at org.akhikhl.gretty.Runner.main(Runner.groovy:48) ~[gretty-runner-2.3.0.jar:na]
14:53:16 INFO Jetty 9.4.14.v20181114 started and listening on port 8081


服务器没有加载我的 Servlet...

有人遇到过这个问题并找到解决方案吗?

最佳答案

我在 master build.gradlebuildscript 方法中使用 Getty libs 依赖项:

buildscript {
repositories {
maven {
url mirrorRepoUrl
}
}

dependencies {
classpath 'org.gretty:gretty:+'
}
}

这应该仅为 Gradle CL 添加 Gretty 库,如果您使用的是 grettyRunnerJetty94,则该库在服务器运行时中可用,但它不包含在 WAR 的构建中(这正是我所寻找的,所以我想感谢您)。

关于java - Gretty/Jetty 无法使用 java 11、Jetty 9.4.14、gretty 加载 WebAppContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56800770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com