Glassfish 无法找到/实例化 Jersey WebApplicationProviderImpl
我正在尝试使用 Glassfish 上的 Jersey(内置)创建 REST 服务。我安装了 GlassFish Server 开源版 3.0.1(内部版本 22)。这是我的 web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
但是,当我尝试部署 WAR 时,我得到以下信息:
java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [com.sun.jersey.server.impl.container.WebApplicationProviderImpl], because it has not yet been started, or was already stopped
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1367)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.jersey.core.reflection.ReflectionHelper.classForNameWithException(ReflectionHelper.java:236)
at com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:851)
那么我能做什么?它看起来像是一个类路径问题,但这都是 glassfish 内部的问题。
我还尝试将 Glassfish 中的 Jersey 组件更新为 1.4,如此处< /a>,但没有变化。
I'm trying to create REST services using Jersey (builtin) on Glassfish. I installed GlassFish Server Open Source Edition 3.0.1 (build 22). This is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
However, when I try to deploy the WAR, I get this:
java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [com.sun.jersey.server.impl.container.WebApplicationProviderImpl], because it has not yet been started, or was already stopped
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1367)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.jersey.core.reflection.ReflectionHelper.classForNameWithException(ReflectionHelper.java:236)
at com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:851)
So what can I do? It looks like a classpath issue, but this is all deep inside glassfish.
I also tried updating the Jersey component in Glassfish to 1.4 as described here, but no change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看我博客中的以下示例,它可能会有所帮助:
我的 web.xml 是:
Check out the following example from my blog, it may help:
My web.xml is:
我自己已经找到了问题的原因。显然,如果您将 JAR 文件部署为 Web 应用程序,即使您明确选择了类型,Glassfish 也会感到非常困惑。我唯一要做的就是将文件后缀更改为 WAR,并且它起作用了(一开始出现了不同的错误,但更容易找到解决方案)。
I've found the cause of the problem myself. Apparently, Glassfish gets deeply confused if you deploy a JAR file as a web app, even if you explicitly select the type. The only thing I had to do is change the file suffix to WAR, and it worked (got a different error at first, but one that was much easier to find a solution for).