gpt4 book ai didi

java - 部署到 Weblogic 11g 的 Spring Boot 应用程序无法启动

转载 作者:搜寻专家 更新时间:2023-10-31 20:33:53 24 4
gpt4 key购买 nike

我在将 Spring Boot 应用程序部署到 Weblogic 10.3.3 服务器时遇到了一些问题。我拼命地祈祷,希望有人以前见过这个问题。我使用 Weblogic 的管理控制台来执行部署(这似乎很顺利),但是当我尝试启动应用程序时,我从 Weblogic 收到错误消息:

Caused By: java.lang.IllegalArgumentException: Invalid source 'com.example.Application'
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:223)
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:144)
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)
at org.springframework.boot.SpringApplication.load(SpringApplication.java:620)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139)
at org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:61)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1863)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3126)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1512)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:143)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

应用程序使用 spring-boot-legacy 和 web.xml 部署为 WAR 文件。它在 Tomcat 6/7/8 上运行良好。这是我的相关配置文件:

web.xml

<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>contextConfigLocation</param-name>
<param-value>com.example.Application</param-value>
</context-param>

<listener>
<listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>ERROR</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>

<servlet>
<servlet-name>helloWorld</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>helloWorld</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

weblogic.xml

<wls:weblogic-web-app 
xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app
http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">

<wls:context-root>helloWorld</wls:context-root>

<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>

通过堆栈跟踪,似乎 Spring Boot 的 BeanDefinitionLoader 类试图加载源类(在我的例子中,只是 com.example.Application)但失败了,因为它没有看到它作为类、资源或包。在此处查看 BeanDefinitionLoader 类:BeanDefinitionLoader.java (第 187 行),看来我的应用程序类应该作为类加载。就像我提到的,它在 Tomcat 中运行良好,但在 Weblogic 中却不行。

是否缺少某些特定于 Weblogic 的内容?会不会是文件编码问题?我的 web.xml 中是否缺少某些内容?

感谢您的宝贵时间!

更新#1

在用尽 Google 和 StackOverflow 进行尝试后,我将 spring.main.sources: com.example.Application 添加到我的 application.yml 中。它没有效果。

我目前的预感是我的 web.xml 中的 contextAttribute 参数可能与我的问题有关。只是不确定我还能把它改成什么。想法?

最佳答案

检查您构建的 war 是否使用与正在运行的 Weblogic 服务器相同的 Java 版本。例如,如果它是 1.6,则在运行 gradle build 之前将 JAVA_HOME 设置为您的 1.6 JDK。

关于java - 部署到 Weblogic 11g 的 Spring Boot 应用程序无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28571212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com