创建了一个版本为 3.0.9 的 grails 应用程序,并使用插件 jaxrs-jersey1:3.0.0 来创建休息服务。当作为 grails run-app 运行时,我在本地创建了资源并测试了休息服务。当我创建战争并部署在外部 tomcat 服务器中时,它会抛出异常。
我第一次使用 jaxrs-jersey1 并且不确定我是否缺少任何其他配置。
build.gradle 依赖项
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
compile ("org.postgresql:postgresql:9.4-1206-jdbc41"){
exclude group: 'org.slf4j'
}
//compile "org.grails.plugins:jaxrs:0.12"
compile "org.grails.plugins:jaxrs-jersey1:3.0.0"
}
grailsVersion=3.0.9
gradleWrapperVersion=2.3
Tomcat 版本:9.0.0.M1
异常日志
ERROR grails.boot.GrailsApp - Application startup failed
java.lang.NullPointerException: null
at
com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.lookupInServletContext(CDIComponentProviderFactoryInitializer.java:13
0) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.lookup(CDIComponentProviderFactoryInitializer.java:89) ~[jersey-servl
et-1.19.jar:1.19]
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:70) ~[jersey-s
ervlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332) ~[jersey-servlet-1.19.jar:1
.19]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) ~[jersey-servlet-1.19.jar:1.19]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[servlet-api.jar:4.0.EDR-b01]
at javax.servlet.Servlet$init.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-2.4.5.jar:2.4.5]
at org.grails.plugins.jaxrs.core.JaxrsContext.init(JaxrsContext.groovy:102) ~[jaxrs-core-3.0.0.jar:na]
at org.grails.plugins.jaxrs.core.JaxrsContext$init.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) ~[groovy-2.4.5.jar:2.4.5]
at org.grails.plugins.jaxrs.JaxrsGrailsPlugin.doWithApplicationContext(JaxrsGrailsPlugin.groovy:196) ~[jaxrs-core-3.0.0.jar:na]
at org.grails.plugins.DefaultGrailsPlugin.doWithApplicationContext(DefaultGrailsPlugin.java:524) ~[grails-core-3.0.9.jar:3.0.9]
at org.grails.plugins.AbstractGrailsPluginManager.doPostProcessing(AbstractGrailsPluginManager.java:229) ~[grails-core-3.0.9.jar:3.0.9]
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:220) ~[grails-core-3.0.9.jar:3.0
.9]
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy) ~[grails-core-3.0.9.jar:3.0.9]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151) ~[spring-con
text-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128) ~[spring-con
text-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) ~[spring-context-4.1.7.REL
EASE.jar:4.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773) ~[spring-context-4.1.7.RE
LEASE.jar:4.1.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140) ~[spring-boot
-1.2.6.RELEASE.jar:1.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) ~[spring-context-4.1.7.RELEASE.
jar:4.1.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.6
.RELEASE.jar:1.2.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
at grails.boot.GrailsApp.run(GrailsApp.groovy:52) [grails-core-3.0.9.jar:3.0.9]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133) [spring-boot-1.2.6.RELEASE.jar
:1.2.6.RELEASE]
at org.grails.boot.context.web.GrailsAppServletInitializer.createRootApplicationContext(GrailsAppServletInitializer.groovy:57) [grails-web-boo
t-3.0.9.jar:3.0.9]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81) [spring-boot-1.2.6.RELEAS
E.jar:1.2.6.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) [spring-web-4.1.7.RELEASE.j
ar:4.1.7.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5186) [catalina.jar:9.0.0.M1]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155) [catalina.jar:9.0.0.M1]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) [catalina.jar:9.0.0.M1]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) [catalina.jar:9.0.0.M1]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:718) [catalina.jar:9.0.0.M1]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:941) [catalina.jar:9.0.0.M1]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1780) [catalina.jar:9.0.0.M1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]