java - 我正在 weblogic 12.2.1.2 上部署一个restFull webservice webapp,但它失败了

标签 java rest jersey-2.0 weblogic12c

您好,我有一个 Restfull Web 服务,该服务在 weblogic 12.2.1.2 版本之前部署,但在 weblogic 12.2.1.2 上它没有部署。并抛出以下错误:

<Oct 11, 2017, 8:16:22,462 PM IST> <Warning> <Munger> <BEA-2156203> <A version attribute was not found in element "web-app" in the deployment descriptor /u01/xxx/xxxx/webapps/xx/WEB-INF/web.xml. A version attribute is required, but this version of the WebLogic Server will assume that the latest version is used. Future versions of WebLogic Server will reject descriptors that do not specify the Java EE version. To eliminate this warning, add an appropriate "version=" to element "web-app" in the deployment descriptor.>
<Oct 11, 2017, 8:16:22,620 PM IST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.xxx.xx.xx.xxx.JerseyConfig because ApplicationPath annotation is not set on it.>
<Oct 11, 2017, 8:16:22,621 PM IST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig because ApplicationPath annotation is not set on it.>
<Oct 11, 2017, 8:16:22,624 PM IST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig because ApplicationPath annotation is not set on it.>
<Oct 11, 2017, 8:16:22,624 PM IST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig$RuntimeConfig because ApplicationPath annotation is not set on it.>
<Oct 11, 2017, 8:21:37,36 PM IST> <Error> <org.glassfish.jersey.server.spring.SpringComponentProvider> <BEA-000000> <[failed to localize] none.or.multiple.beans.available(class com.xxx.xx.xx.JerseyConfig)>

我尝试过使用 web.xml 中的 version 属性,但没有成功。并抛出同样的错误。

环境。详情:

Java-1.7 & 1.8
weblogic-12.2.1.2
Servlet-api-2.4

任何帮助将不胜感激..

更新:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


    <display-name>xxx</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/applicationContext.xml
            WEB-INF/classes/configs/*.xml
        </param-value>
    </context-param>
    <!--<context-param>
        <param-name>contextClass</param-name>
        <param-value>com.javaetmoi.core.spring.JBoss5XmlWebApplicationContext</param-value>
    </context-param>--> 
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>jerseyServlet</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer
        </servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.xx.xx.xx.JerseyConfig</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jerseyServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>localFilesBasePath</param-name>
        <param-value>configs</param-value>
    </context-param>
    <context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>resteasy.scan.providers</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>resteasy.scan.resources</param-name>
        <param-value>false</param-value>
    </context-param>
    <resource-ref>
        <res-ref-name>jdbc/xxx</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <resource-ref>
        <res-ref-name>jdbc/xxx</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

</web-app>

最佳答案

这是来自 Jersey Examples 的 web.xml 示例,请注意有一个初始化参数指向 Jersey 应用程序类

<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">

    <filter>
        <filter-name>org.glassfish.jersey.examples.bookstore.webapp.MyApplication</filter-name>
        <filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>org.glassfish.jersey.examples.bookstore.webapp.MyApplication</param-value>
        </init-param>
        <!-- pass to next filter if Jersey/App returns 404 -->
        <init-param>
            <param-name>jersey.config.servlet.filter.forwardOn404</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>org.glassfish.jersey.examples.bookstore.webapp.MyApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

这是应用程序类:

public class MyApplication extends ResourceConfig {
    public MyApplication() {
        // Resources.
        packages(Bookstore.class.getPackage().getName());

        // MVC.
        register(JspMvcFeature.class);

        // Logging.
        register(LoggingFilter.class);

        // Tracing support.
        property(ServerProperties.TRACING, TracingConfig.ON_DEMAND.name());
    }
} 

关于java - 我正在 weblogic 12.2.1.2 上部署一个restFull webservice webapp,但它失败了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46692294/

相关文章:

java - 如何在 Google Ads API 中查询最近停用的广告系列

java - 如何在较新版本的 Android 3.1 及更高版本中实现 Firebase Recycler Adapter?

rest - 应该使用什么 URL 来更新集合中所有成员的属性

java - 无法显示 Jersey 的 JSP : MessageBodyWriter not found for media type=text/html

java - Wicket 和 Jersey2 位于同一 web.xml 中

java - CDI bean 的 Servlet 和范围

java - 无效的未知请求错误 : Cannot determine request type. 这个广告单元 ID 是否正确?

json - 使用 Apache CXF 且不使用 Spring 的具有 JSON 表示形式的 REST API

php - REST API 安全设计

java.lang.NoSuchMethodError : org. glassfish.hk2.api.ServiceLocatorFactory.create