JBoss RESTEasy 无法扫描 WEB-INF 中的 JAX-RS 注释

发布于 2024-11-05 08:21:49 字数 3510 浏览 3 评论 0原文

我刚刚将 JAX-RS Web 服务添加到 MyEclipse 中的项目中,并将导出/部署到 jboss 6/jdk 1.6,但我不断收到此错误,并且不知道为什么会出现该错误。这是该堆栈跟踪的前几行:

2011-05-03 21:33:46,716 INFO  [org.jboss.resteasy.integration.deployers.ResteasyIntegrationDeployer] (HDScanner) *** Adding JAX-RS resource classes: com.mycompany.CategoriesResource
2011-05-03 21:33:47,180 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/mypath
2011-05-03 21:33:47,330 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mypath]] (HDScanner) Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap: java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

以前有人遇到过这个问题吗?如果有帮助的话,该项目是在 MyEclipse 中使用 Struts 和 Web 服务功能创建的。老实说,考虑到我最近刚刚部署了类似的配置,没有任何问题,我真的不知道还能尝试什么。

谢谢!

这是我的 web.xml

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 行动 org.apache.struts.action.ActionServlet 配置 /WEB-INF/struts-config.xml 调试 3 细节 3 0

<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
    <display-name>API</display-name>
    <servlet-name>API</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>API</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/api</param-value>
</context-param>
<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<jsp-config>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-tiles</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
</jsp-config>

I just added JAX-RS web services to my project in MyEclipse and did my export/deploy to jboss 6/jdk 1.6, but I keep getting this error and I have no clue why it comes up. Here's the first few lines of this stack trace:

2011-05-03 21:33:46,716 INFO  [org.jboss.resteasy.integration.deployers.ResteasyIntegrationDeployer] (HDScanner) *** Adding JAX-RS resource classes: com.mycompany.CategoriesResource
2011-05-03 21:33:47,180 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/mypath
2011-05-03 21:33:47,330 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mypath]] (HDScanner) Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap: java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

Has anyone had trouble with this before? The project was created in MyEclipse with Struts and Web Service Capabilities if that helps. I honestly don't know what else I can try considering I just recently deployed a similar configuration without any problems.

Thanks!

Here is my web.xml

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

action
org.apache.struts.action.ActionServlet

config
/WEB-INF/struts-config.xml

debug
3

detail
3

0

<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
    <display-name>API</display-name>
    <servlet-name>API</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>API</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/api</param-value>
</context-param>
<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<jsp-config>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-tiles</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
</jsp-config>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烟沫凡尘 2024-11-12 08:21:49

这意味着 RESTEasy 在尝试扫描 WEB-INF 目录时收到 IOException。我要检查的第一件事是您的文件系统权限 - 运行 JBoss 进程的用户是否可以读取 WEB-INF 及其中的所有文件?

编辑:

响应您的评论:您的类路径包含 Scannotation 无法理解的条目。它看起来像jndi://。您可以检查类路径并找出该条目是什么吗?

This means that RESTEasy received an IOException when trying to scan the WEB-INF directory. The first thing I would check is your file system permisions - can the user running the JBoss process read WEB-INF and all the files within it?

EDIT:

In response to your comment: Your classpath includes an entry that Scannotation doesn't understand. It looks like jndi://. Can you check the classpath and find out what this entry is?

农村范ル 2024-11-12 08:21:49

Resteasy 也应该是受害者。问题出在 scannotation-1.0.3.jar 处。

DirectoryIteratorFactory factory = registry.get(url.getProtocol());
if (factory == null) throw new IOException("Unable to scan directory of protocol: " + url.getProtocol());
return factory.create(url, filter);

看来当 url.getProtocol() 返回“jdni”时,就会发生此问题。我仍在调查什么 url 将返回协议作为 jndi。

我从 lib 文件夹中删除了 scannotation-1.0.3.jar,然后下载了源代码,打印了错误的 url。结果是: jndi:/localhost/Enoch2/WEB-INF/lib/.svn/

然后我尝试从部署中删除所有 .svn 文件夹。有用。
<代码>
寻找 。 -名称 .svn | xargs rm -Rf

Resteasy should be the victim, too. The problem is at scannotation-1.0.3.jar.

DirectoryIteratorFactory factory = registry.get(url.getProtocol());
if (factory == null) throw new IOException("Unable to scan directory of protocol: " + url.getProtocol());
return factory.create(url, filter);

It seems when the url.getProtocol() returns "jdni", this problem happens. I'm still investigating what url will return protocol as jndi.

I deleted the scannotation-1.0.3.jar from my lib folder, and downloaded the source code, printed the bad url. It turned out to be: jndi:/localhost/Enoch2/WEB-INF/lib/.svn/

Then I tried to remove all .svn folders from the deployment. It works.

find . -name .svn | xargs rm -Rf

北陌 2024-11-12 08:21:49

当我将我的 Maven 项目从 java 6 移动到 java 8 时,我遇到了同样的问题。原因是我的项目中的一些依赖性保留了 javassit 3.12,并且它与 java 8 不兼容。在我将 javassist 升级到 3.20 后,它开始工作美好的。
因此,如果您遇到此问题,请检查使用的 javassist jar 并根据需要进行升级。

I faced the same issue when I moved my maven project from java 6 to java 8. The cause was some dependancy in my project was holding on to javassit 3.12 and it was not compatible with java 8. After I upgraded javassist to 3.20 it started working fine.
So if you face this issue please check the javassist jar used and upgrade if needed.

a√萤火虫的光℡ 2024-11-12 08:21:49

我最近遇到了这个问题。
Java 8 更改不支持 javassist 版本。所以我已经从该依赖项中排除了这个 jar 并添加了外部 javassist 依赖项(具有更高版本)。

LOG:
SEVERE: Exception sending context initialized event to listener instance of class [org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap]

java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

    at org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap.createDeployment(ConfigurationBootstrap.java:177)

    at org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap.createDeployment(ListenerBootstrap.java:32)

    at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:27)

我的解决方案:

更新了我的 pom.xml 文件

<dependency>
    <groupId>com.xyz</groupId>
    <artifactId>abc</artifactId>
    <version>${abc.version}</version>
    <exclusions>
        <exclusion>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
        </exclusion>
    </exclusions>
</dependency>

并添加了依赖项

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.18.2-GA</version>
</dependency>

I have faced this issue recently.

javassist version was not supported with Java 8 changes. So I have excluded this jar from that dependency and added externally javassist dependency(with higer version).

LOG:
SEVERE: Exception sending context initialized event to listener instance of class [org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap]

java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

    at org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap.createDeployment(ConfigurationBootstrap.java:177)

    at org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap.createDeployment(ListenerBootstrap.java:32)

    at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:27)

My Solution:

Updated my pom.xml file

<dependency>
    <groupId>com.xyz</groupId>
    <artifactId>abc</artifactId>
    <version>${abc.version}</version>
    <exclusions>
        <exclusion>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
        </exclusion>
    </exclusions>
</dependency>

and added dependency

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.18.2-GA</version>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文