WebLogic 上的 Spring 启动应用程序部署抛出 404 错误



我已经完成了以下配置并尝试了几乎所有找到的解决方案,但没有任何帮助。当我在战争包中部署春季启动应用程序时。WebLogic 日志中没有记录错误,但应用程序抛出 404 错误。

网络.xml

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:root-context.xml</param-value>
</context-param>
<context-param>  
<param-name>spring.profiles.active</param-name>  
<param-value>dev</param-value>  
</context-param>  
<context-param>  
<param-name>spring.profiles.default</param-name>  
<param-value>dev</param-value>  
</context-param>
<context-param>  
<param-name>spring.liveBeansView.mbeanDomain</param-name>  
<param-value>dev</param-value>  
</context-param>  

网络逻辑.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wls="http://www.bea.com/ns/weblogic/90"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.2.0.0</wls:weblogic-version>
<wls:context-root>/services/userModule/</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.fasterxml</wls:package-name>
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>

应用程序属性

spring.profiles.default=default
spring.profiles.active=default
spring.liveBeansView.mbeanDomain=default
cms.config.monitor.dir=/server/location/application/artifacts
application.messages.file.name=application-messages
application.config.file.name=application-config

根上下文.xml

它包含特定于应用程序的配置。

申请开始.java

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class}) 
public class ApplicationBegin extends SpringBootServletInitializer implements WebApplicationInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApplicationBegin.class);
}
public static void main(String[] args){
SpringApplication.run(ApplicationBegin.class, args);
}

无法从 pom 中排除 tomcat 服务器.xml因为它编译失败。 有没有办法在使用 Spring Boot 启动 Web 时设置雄猫?庞.xml

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<!-- THIS WILL BE EXCLUDE ONLY FOR WEBLOGIC DEPLOYMENT -->
<!--  <exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>  -->
</exclusions>
</dependency>

问题是应用程序在嵌入式tomcat上运行良好,但在weblogic上部署时即使没有抛出任何错误,它也无法正常工作。我应该在哪里看?

你能尝试将类加载作为父级吗?所以 Spring 引导将使用它自己的容器库。

在尝试了我从不同人那里找到的解决方案后,它无法解决我的问题,不知何故,我现在已经解决了它。 我在这个主题和灵魂上看到的所有类似问题,我终于明白没有答案实际上是一个解决方案,因为在大多数情况下,问题的发生是由于WebLogic无法理解的错误配置。 最糟糕的是它甚至不会抛出错误。在我的情况下,除了application.properties文件和root-context.xml之外,我在/WEB-INF位置中显式指定了web.xml文件,并在那里定义了上下文配置位置。一旦我删除了 web.xml并从上到下重构/过滤了项目依赖项,它就解决了这个问题。 然后我意识到,如果您的配置正确,甚至不需要网络上针对此问题的许多方便的解决方案。例如,如果您正确使用 Spring Boot JPA 启动器,则不需要配置 JPAVENDOR 。 所以。。如果您在WebLogic上遇到此类部署问题,您可以按照以下步骤操作-

  1. 仅部署应用程序的最小部分并使其可操作 在网络逻辑上
  2. 然后添加您的关键依赖项/配置,并在WebLogic上逐个部署它们,并检查它是否正常工作
  3. 您应该始终首先将启动应用程序运行到其他本地服务器,以解决主要配置问题。雄猫是 好。

我遇到了同样的问题,但我终于设法解决了它。

问题在于 web.xml 描述符的版本。如果你把web.xml文件放在你的项目中,有<web-app version="2.5">,即使你的Weblogic支持servlet 3.0,弹簧控制器也会抛出404。

这也解释了您的应用程序的行为 - 当您删除 web.xml 文件时它开始工作的原因是什么。

相关内容

最新更新