当只有weblogic 8.1服务器在运行时,我不得不在服务器上运行简单的定期任务,所以要求在weblogic上运行该任务。
我从创建最简单的ear开始,它将运行一个类。我在其他项目中发现了weblogic-application.xml中启动类的调用:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-application
PUBLIC "-//BEA Systems, Inc.//DTD WebLogic Application 8.1.0//EN"
"http://www.bea.com/servers/wls810/dtd/weblogic-application_2_0.dtd">
<weblogic-application>
<startup>
<startup-class>myStartupClass</startup-class>
<startup-uri>my-ejb.jar</startup-uri>
</startup>
</weblogic-application>
正如我所理解的,java代码必须在单独的EJB项目中,所以我创建了只包含myStartupClass的项目,并将其添加为EJB类型的maven依赖项。我正在使用maven ear插件构建ear:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
最后,耳朵建成了,我正在部署它,没有任何信息:
[Deployer:149233]An unexpected error was encountered during the deployment process.
[Deployer:149033]preparing application finder-ear-1 on myserver
[Deployer:149033]failed application finder-ear-1 on myserver
[Deployer:149034]An exception occurred for task [Deployer:149026]Deploy application finder-ear-1 on myserver.: [Deployer:149233]An unexpected error was encountered during the deployment process..
我检查了日志以找到一些细节,但不幸的是,它们没有给我任何weblogic想要我做什么的提示:
####<2012-02-23 13:41:00 GMT> <Warning> <DRS> <PA-STK-074> <myserver> <ExecuteThread: '3' for queue: 'weblogic.kernel.System'> <<WLS Kernel>> <> <BEA-002506> <The current version 2 for DataIdentifier DataIdentifierID: 1 does not match with incoming version 6 for a one-phase update.>
####<2012-02-23 13:41:00 GMT> <Warning> <Deployer> <PA-STK-074> <myserver> <ExecuteThread: '3' for queue: 'weblogic.kernel.System'> <<WLS Kernel>> <> <BEA-149004> <Failures were detected while initiating Deploy task for application finder-ear-1.>
####<2012-02-23 13:41:00 GMT> <Error> <Deployer> <PA-STK-074> <myserver> <ExecuteThread: '3' for queue: 'weblogic.kernel.System'> <<WLS Kernel>> <> <BEA-149201> <Failed to complete the deployment task with ID 4 for the application finder-ear-1.
java.lang.Throwable:
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare()V(SlaveDeployer.java:2413)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(Lweblogic/management/deploy/OamVersion;Lweblogic/management/runtime/DeploymentTaskRuntimeMBean;Z)V(SlaveDeployer.java:883)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(Lweblogic/management/deploy/OamDelta;Lweblogic/management/deploy/OamVersion;ZLjava/lang/StringBuffer;)Z(SlaveDeployer.java:591)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(Ljava/util/ArrayList;Z)V(SlaveDeployer.java:500)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(Lweblogic/kernel/ExecuteThread;)V(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(Lweblogic/kernel/ExecuteRequest;)V(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:183)
at java.lang.Thread.startThreadFromVM(Ljava/lang/Thread;)V(Unknown Source)
>
你能给我一个提示吗?我做错了什么?从哪里开始?我试图为类似于我的案例找到一些教程(没有web应用程序,没有远程EJB服务,只有简单的定期任务,使用maven构建),但我找不到任何匹配的东西。。。如有任何提示,不胜感激。
我认为,由于启动类的目的是在部署某个EAR之前执行,因此需要将该类放在EAR文件之外。因此,您可以尝试将所有这些内容保留在weblogic-application.xml文件中,但将启动类打包在一个标准jar文件中,该文件部署在weblogic的类路径dir(%WL_HOME%\server\lib)中