【问题标题】:Rest Web Services using Spring are not invoked in weblogic 12.2.1在 weblogic 12.2.1 中未调用使用 Spring 的 Rest Web 服务
【发布时间】:2015-11-06 13:29:58
【问题描述】:

我们正在考虑将我们的应用程序升级到 Weblogic 12.2.1。服务器正常启动。但是我们无法调用任何网络服务。它们是使用 Spring 编写的。我们也在使用 JDK 8。

日志中出现的错误消息是:

org.springframework.web.servlet.PageNotFound 在名称为“dispatcher”的 DispatcherServlet [noHandlerFound:1120 {}] 中找不到具有 URI [/test/components] 的 HTTP 请求的映射

仅当我们使用安装程序安装应用程序时才会出现问题。 当我们在开发环境中部署应用程序时,不会出现问题。我们能够成功调用服务。

我们对比了安装程序和开发程序中的类路径,它们是相同的。

调度程序-servlet.xml

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans     
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.1.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">

<context:component-scan base-package="test" />

<bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean id="mvcConfigurationBeanPostProcessor"
      class="com.jda.webworks.publicapi.common.SpringMvcConfigBeanPostProcessor">
</bean>

<mvc:annotation-driven>
    <mvc:message-converters register-defaults="false">
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
        <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
        <bean class="org.springframework.http.converter.StringHttpMessageConverter" />
    </mvc:message-converters>
</mvc:annotation-driven>

<!-- enable the configuration of app server transactional behavior based on annotations -->
<tx:annotation-driven/>
<tx:jta-transaction-manager/>

<!-- Create instance of transaction template for programmatic transaction manipulation -->
<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="transactionManager"></property>
</bean>

我们也尝试添加&lt;mvc:default-servlet-handler /&gt;。但这并没有帮助。

web.xml

<?xml version="1.0" encoding="UTF-8"?>

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

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>

<!--
<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/config/log4j.xml</param-value>
</context-param>
-->

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!--
<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
-->

<session-config>
    <session-timeout>1</session-timeout>
</session-config>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>WebWORKS RESTful Services</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>POST</http-method>
        <http-method>GET</http-method>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>NetworksUsers</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>default</realm-name>
</login-config>
<security-role>
    <role-name>NetworksUsers</role-name>
</security-role>

请给我们任何指示以帮助解决问题。

【问题讨论】:

  • 可以添加web.xml吗?

标签: spring rest java-8 weblogic12c


【解决方案1】:

我们向 Oracle 提出了一个案例。同时,我们找到了解决上述问题的方法。

如果其余类在WEB-INF/classes 或WEB-INF/lib 下可用,这似乎可行。以前,我们从 ear/lib(通过 application.xml 设置为 lib)从“更高”的类加载器加载类,然后我们看到了问题。
当然,在 WLS 12.1.3 中,我们从未遇到任何问题。包含 REST 类的 .jar 仅在 ear/lib 中,而不在 WAR 的 WEB-INF 中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-26
    • 1970-01-01
    • 2016-05-01
    • 2018-06-27
    • 2016-04-25
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多