【问题标题】:Exception after adding JAX-RS facet to Dynamic Web Project in Eclipse将 JAX-RS 方面添加到 Eclipse 中的动态 Web 项目后出现异常
【发布时间】:2012-04-14 06:35:45
【问题描述】:

我是 Oracle Plugin for Eclipse (OEPE) 和 EJB 的新手。我正在关注 http://www.youtube.com/watch?v=on557289GzA&feature=relmfu 上标题为 JavaEE6 and Glassfish with Eclipse 的教程(5 of 5)

在为动态 Web 项目启用 JAX-RS 方面后,我遇到了以下异常。

加载应用程序时出现异常:java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: com.sun.jersey.api .container.ContainerException: ResourceConfig 实例不包含任何根资源类。

我重新创建了一个新环境(Eclipse Indigo、Glassfish 3.0.1),但我对同一点感到震惊。已经有一个关于同一主题的问题。但它被标记为没有答案甚至没有提示的回答!

请帮帮我。

我的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="OpenEducation">
        <jta-data-source>jdbc/ScottConn</jta-data-source>
        <class>model.Course</class>
        <class>model.Customer</class>
        <class>model.Registration</class>
    </persistence-unit>
</persistence>

我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>OpenEducation</display-name>
  <servlet>
    <description>JAX-RS Tools Generated - Do not modify</description>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <url-pattern>/jaxrs/*</url-pattern>
  </servlet-mapping>
</web-app>

提前致谢。

【问题讨论】:

    标签: eclipse rest ejb-3.0 glassfish-3 jax-rs


    【解决方案1】:

    您的项目中必须至少有一个用@Path JAX-RS 注释标记的类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-24
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多