0

我在使用 netbeans 从我的实体类创建 Web 服务时遇到问题。实际上,我有一个 javaee 项目,它适用于 weblogic 10g、oracle 数据库 10g,并使用带有 primefaces 的 JSF 2.1。它工作得很好。

但是当涉及到向我的项目添加 Web 服务时,我遇到了

部署失败。消息是:java.lang.NoClassDefFoundError: com/sun/jersey/spi/container/ContainerListener C:\Users\Developer\Documents\NetBeansProjects\IBB_Projeler\nbproject\build-impl.xml:294:模块尚未部署.

当我添加 Web 服务时,我的 web.xml 变为:

    <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>ServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <description>Multiple packages, separated by semicolon(;), can be specified in param-value</description>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>Resources</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ServletAdaptor</servlet-name>
        <url-pattern>/webresources/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            3000
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsf</welcome-file>
    </welcome-file-list>
    <ejb-local-ref>
        <ejb-ref-name>ProjectsFacade</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local>com.ibb.entity.facades.ProjectsFacadeLocal</local>
        <ejb-link>projetakip-ejb.jar#ProjectsFacade</ejb-link>
    </ejb-local-ref>
    <mime-mapping>
        <extension>jpeg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <ejb-local-ref>
        <ejb-ref-name>ProjectsFacade1</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local>com.ibb.entity.facades.ProjectsFacadeLocal</local>
        <ejb-link>projetakip-ejb.jar#ProjectsFacade</ejb-link>
    </ejb-local-ref>
    <ejb-local-ref>
        <ejb-ref-name>ProjectsFacade2</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local>com.ibb.entity.facades.ProjectsFacadeLocal</local>
        <ejb-link>projetakip-ejb.jar#ProjectsFacade</ejb-link>
    </ejb-local-ref>
    <persistence-unit-ref>
        <persistence-unit-ref-name>persistence-factory</persistence-unit-ref-name>
        <persistence-unit-name>projetakip-warPU</persistence-unit-name>
    </persistence-unit-ref>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/index.jsf</location>
    </error-page>
</web-app>

基本上它添加了以下内容:

<servlet-mapping>
    <servlet-name>ServletAdaptor</servlet-name>
    <url-pattern>/webresources/*</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>ServletAdaptor</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <description>Multiple packages, separated by semicolon(;), can be specified in param-value</description>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>Resources</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

我搜索了一下,在一些论坛上他们说要添加相关的罐子。我添加了 jersey-server、jsr311-api、asm3.1、jersey-gf-server 和 jersey-servlet。

但是问题仍然存在,如果有人可以帮助我,我将不胜感激。

4

0 回答 0