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

标签 java rest jboss jax-rs resteasy

我刚刚将 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>

最佳答案

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

编辑:

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

关于java - JBoss RESTEasy 无法扫描 WEB-INF 中的 JAX-RS 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5876130/

相关文章:

wordpress - 路由的处理程序无效 - Wordpress

java - Hibernate 无法使用 JBOSS 检索数据

java - 如何排除 JRebel 故障?

java - 为什么我的数组中的索引 0 出现 stackoverflow 错误

Java : Deploy restful web service without jersey

java - war 适用于 tomcat,但不适用于 jboss 6

java - 使用自定义 xml bean 设置属性后,Spring Boot REST Controller 不起作用

javascript - 未陷入 promise

java - Spring JMS 无法连接到 JBoss EAP 7.1 ActiveMq Artemis

java - 在 setter 中进行修剪是一种好习惯吗?