在Weblogic中部署Spring Boot应用程序

我在webLogic 12C中部署Spring启动应用程序时遇到了麻烦。

10.4.4 403禁止服务器理解请求,但拒绝履行请求。 授权无效,请求不应重复。 如果请求方法不是HEAD并且服务器希望公开为什么请求没有得到满足,那么它应该描述实体中拒绝的原因。 当服务器不希望确切地说明请求被拒绝的原因,或者没有其他响应适用时,通常会使用此状态代码。

我想知道是否有人可以提供帮助。

我查看了您的代码并在此类代码中看到了一个问题: https : //github.com/purrox/Spring-example/blob/master/src/main/java/hello/Application.java

你正确地做了(正如SpringBoot文档中所定义的那样),但似乎Weblogic12C存在一个错误(或者可能是对标准的解释)。 似乎Weblogic12C搜索直接实现WebApplicationInitializer的类。 请注意您的代码如何扩展SpringBootServletInitializer(实现WebApplicationInitializer)。 Weblogic12C似乎并不喜欢它。 因此,最简单的方法是让Application类实现WebApplicationInitializer。 所以,改变这一行:

public class Application extends SpringBootServletInitializer { 

对此:

 public class Application extends SpringBootServletInitializer implements WebApplicationInitializer { 

注意:一旦修复了上述内容,您将遇到另一个Weblogic12C部署问题:“java.lang.IllegalArgumentException:LoggerFactory不是Logback LoggerContext,但Logback在类路径上”。 要解决其他问题,请创建一个新文件src / main / webapp / WEB-INF / weblogic.xml并将此内容放入其中:

    12.1.1 helloApp   org.slf4j.*    

如果您要使用multipart文件请求,您仍可能在部署战争时遇到问题。

问题的根源是OrderedCharacterEncodingFilter在HiddenHttpMethodFilter之后运行。 HiddenHttpMethodFilter在请求上调用getParameter时触发请求体的处理。 OrderedCharacterEncodingFilter然后运行并设置请求的编码。 在处理主体之后设置请求的编码是不好的,并且在WebLogic上,导致请求失去对其所有多部分数据的跟踪。

解决方法是在application.properties中禁用字符编码filter:

 spring.http.encoding.enabled: false 

您需要在hello.Application中添加“implements WebApplicationInitializer”。

这是多余的,因为它扩展了SpringBootServletInitializer,它本身实现了WebApplicationInitializer,但是,正如@Pierre指出的那样,weblogic需要一个类来直接实现它。

我上次遇到这个问题。 应用此post中的所有提案后,我仍然收到错误403.在我的情况下,问题出在web.xml文件中。 我使用的是2.5版而不是3.0版而没有将其配置为通过DispatcherServlet加载ApplicationContext

post: 网络应用版本究竟是什么? 它有什么影响? 。

 Versioning refers to XML schema version that syntax of your web.xml file must obey. More important, it also indicates the version of Servlet specification that your application implements. 

从Spring文档http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html :

 Older Servlet containers don't have support for the ServletContextInitializer bootstrap process used in Servlet 3.0. You can still use Spring and Spring Boot in these containers but you are going to need to add a web.xml to your application and configure it to load an ApplicationContext via a DispatcherServlet. 

最后我将web.xml文件的版本更改为3.0并开始工作。