背景: 使用weblogic开发ejb服务组件,开发完成后,部署到weblogic上,然后在eclipse中使用main函数访问没有问题。
但是如果将使用weblogic开发的ejb client打成war包,部署到weblogic总是部署不成功,报如下错误:
eblogic.application.ModuleException: [HTTP:101216]Servlet: "weblogic.wsee.jaxws.client.async.AsyncTransportProvider" failed to preload on startup in Web application: "ilucky-ejb-3.0-weblogic-client-0.0.1-SNAPSHOT.war".
javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider
at weblogic.wsee.jaxws.WLSInstanceResolver.getSingleton(WLSInstanceResolver.java:36)
at weblogic.wsee.jaxws.WLSInstanceResolver.start(WLSInstanceResolver.java:55)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.start(WLSInstanceResolver.java:82)
at com.sun.xml.ws.server.InvokerTube.setEndpoint(InvokerTube.java:85)
at weblogic.wsee.jaxws.EndpointAwareLateInitTube.postCreateEndpoint(EndpointAwareLateInitTube.java:48)
at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:158)
at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:68)
at weblogic.wsee.jaxws.JAXWSDeployedServlet.init(JAXWSDeployedServlet.java:54)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1981)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1955)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1874)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
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:52)
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:671)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44)
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:149)
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:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.xml.ws.WebServiceException: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider
at weblogic.wsee.jaxws.WLSServletInstanceResolver.create(WLSServletInstanceResolver.java:37)
at weblogic.wsee.jaxws.WLSInstanceResolver.getSingleton(WLSInstanceResolver.java:34)
... 51 more
Caused by: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:325)
at weblogic.wsee.jaxws.injection.WSEEComponentContributor.newInstance(WSEEComponentContributor.java:54)
at weblogic.wsee.jaxws.injection.WSEEComponentContributor.newInstance(WSEEComponentContributor.java:42)
at weblogic.wsee.jaxws.WLSServletInstanceResolver.create(WLSServletInstanceResolver.java:35)
... 52 more
解决方案如下,即将weblogic可以提供的jar设置scope为provided,这样就解决了!说白了,就是jar包冲突了。。。。provided是什么意思,百度自行搜索 maven scope provided吧!
<dependency>
<groupId>com.ilucky.ejb</groupId>
<artifactId>ilucky-ejb-3.0-weblogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.weblogic</groupId>
<artifactId>weblogic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.wlfullclient</groupId>
<artifactId>wlfullclient</artifactId>
<version>10.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>10.3</version>
<scope>provided</scope>
</dependency>
详细的pom如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ilucky.ejb</groupId>
<artifactId>ilucky-ejb-3.0-weblogic-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ilucky-ejb-3.0-weblogic-client</name>
<url>http://maven.apache.org</url>
<properties>
<!-- Explicitly declaring the source encoding eliminates the following
message: -->
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- other plugin versions -->
<version.compiler.plugin>2.3.1</version.compiler.plugin>
<version.exec.plugin>1.2.1</version.exec.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- ADD -->
<!-- We depend on the EJB remote business interfaces of this application -->
<dependency>
<groupId>com.ilucky.ejb</groupId>
<artifactId>ilucky-ejb-3.0-weblogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.weblogic</groupId>
<artifactId>weblogic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.wlfullclient</groupId>
<artifactId>wlfullclient</artifactId>
<version>10.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>10.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Enforce Java 1.6 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<!-- Add the maven exec plugin to allow us to run a java program via maven -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec.plugin}</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}/exec-working-directory</workingDirectory>
<arguments>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<argument>-classpath</argument>
<classpath>
</classpath>
<argument>com.ilucky.ejb.Client</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ilucky.ejb.EJBDemoTest</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
截图如下: