Class loader problem by invoking EJB from Axis2-AAR with Spring
---------------------------------------------------------------
Key: AXIS2-3886
URL: https://issues.apache.org/jira/browse/AXIS2-3886
Project: Axis 2.0 (Axis2)
Issue Type: Bug
Affects Versions: 1.4
Environment: JDK 1.4, Axis2 1.4, Spring 2.0.8, Weblogic 8.1 SP6
Reporter: Mirwais Turjalei
As described in http://ws.apache.org/axis2/1_4/spring.html the
"ServiceLifeCycle" was configured like this:
ClassLoader classLoader = service.getClassLoader();
ClassPathXmlApplicationContext appCtx = new
ClassPathXmlApplicationContext(new String[] {
"my-application-context.xml"}, false);
appCtx.setClassLoader(classLoader);
appCtx.refresh();
In "my-application-context.xml" we add a Spring-Bean to access the ejb:
<bean id="someService" class="org.springframework.jndi.JndiObjectFactoryB ean"
lazy-init="true">
<property name="proxyInterface" value="org.SomeService" />
<property name="lookupOnStartup" value="false" />
<property name="jndiName" value="SomeService"/>
<property name="jndiTemplate">
<bean class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WL
InitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:7001</prop>
<prop key="java.naming.security.principal">username</prop>
<prop key="java.naming.security.credentials">password</prop>
</props>
</property>
</bean>
</property>
</bean>
By starting weblogic we get this exception:
... bean with name 'someService' defined in class path resource
[my-application-context.xml]: Invocation of init method failed; nested
exception is java.lang.IllegalArgumentException: interface org.SomeService is
not visible from class loader
at org.apache.axis2.deployment.repository.util.Archiv
eReader.processServiceGroup(ArchiveReader.java:151 )
at org.apache.axis2.deployment.ServiceDeployer.deploy (ServiceDeployer.java:81)
at org.apache.axis2.deployment.repository.util.Deploy
mentFileData.deploy(DeploymentFileData.java:136)
at org.apache.axis2.deployment.DeploymentEngine.doDep
loy(DeploymentEngine.java:597)
at org.apache.axis2.deployment.repository.util.WSInfo
List.update(WSInfoList.java:144)
at org.apache.axis2.deployment.RepositoryListener.upd
ate(RepositoryListener.java:330)
at org.apache.axis2.deployment.RepositoryListener.che
ckServices(RepositoryListener.java:227)
at org.apache.axis2.deployment.DeploymentEngine.loadS
ervices(DeploymentEngine.java:131)
at org.apache.axis2.deployment.WarBasedAxisConfigurat
or.loadServices(WarBasedAxisConfigurator.java:284)
at org.apache.axis2.context.ConfigurationContextFacto
ry.createConfigurationContext(ConfigurationContext Factory.java:82)
at org.apache.axis2.transport.http.AxisServlet.initCo
nfigContext(AxisServlet.java:511)
at org.apache.axis2.transport.http.AxisServlet.init(A xisServlet.java:431)
at weblogic.servlet.internal.ServletStubImpl$ServletI
nitAction.run(ServletStubImpl.java:1099)
at weblogic.security.acl.internal.AuthenticatedSubjec
t.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:121)
at weblogic.servlet.internal.ServletStubImpl.createSe
rvlet(ServletStubImpl.java:975)
at weblogic.servlet.internal.ServletStubImpl.createIn
stances(ServletStubImpl.java:954)
at weblogic.servlet.internal.ServletStubImpl.prepareS
ervlet(ServletStubImpl.java:893)
at weblogic.servlet.internal.WebAppServletContext.pre
loadServlet(WebAppServletContext.java:3456)
at weblogic.servlet.internal.WebAppServletContext.pre
loadServlets(WebAppServletContext.java:3401)
at weblogic.servlet.internal.WebAppServletContext.pre
loadResources(WebAppServletContext.java:3382)
at weblogic.servlet.internal.WebAppServletContext.set
Started(WebAppServletContext.java:6262)
at weblogic.servlet.internal.WebAppModule.start(WebAp pModule.java:892)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEA
pplicationContainer.java:2181)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2
EEApplicationContainer.java:2222)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2
EEApplicationContainer.java:2169)
at weblogic.management.deploy.slave.SlaveDeployer$App
lication.setActivation(SlaveDeployer.java:3111)
at weblogic.management.deploy.slave.SlaveDeployer.set
ActivationStateForAllApplications(SlaveDeployer.ja va:1769)
at weblogic.management.deploy.slave.SlaveDeployer.res
ume(SlaveDeployer.java:352)
at weblogic.management.deploy.DeploymentManagerServer
LifeCycleImpl.resume(DeploymentManagerServerLifeCy cleImpl.java:229)
at weblogic.t3.srvr.SubsystemManager.resume(Subsystem Manager.java:136)
at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:965)
By moving the Jar with the EJB-Interface "org.SomeService" into
"axis2.war/WEB-INF/lib", OR changing
the "ServiceLifeCycle" to the following the error above is gone and it seems
that all spring-beans are configured correctly:
ClassLoader contextCl = Thread.currentThread().getContextClassLoader();
ClassLoader classLoader = service.getClassLoader();
Thread.currentThread().setContextClassLoader(class Loader);
ClassPathXmlApplicationContext appCtx =
new ClassPathXmlApplicationContext(
new String[]{"my-application-context.xml"}, false);
appCtx.setClassLoader(classLoader);
appCtx.refresh();
Thread.currentThread().setContextClassLoader(conte xtCl);
But by calling the EJB from wihthin the Web-Service we get an
IllegaleArgumentException with "type mismatch":
org.springframework.remoting.RemoteProxyFailureExc eption: Invocation of RMI
stub method failed: public abstract org.SomeOutputObject
org.SomeService.someEjbMethode(org.SomeInputObject ); nested exception is
java.lang.IllegalArgumentException: argument type mismatch
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(
Ljava.lang.Object;[Ljava.lang.ObjectLjava.lang.Object;(Unknown Source)
at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source)
at org.springframework.remoting.rmi.RmiClientIntercep
torUtils.doInvoke(RmiClientInterceptorUtils.java:1 03)
at org.springframework.ejb.access.SimpleRemoteSlsbInv
okerInterceptor.doInvoke(SimpleRemoteSlsbInvokerIn terceptor.java:75)
...
Is this a generel class loader problem?
It seems that the Axis2 class loader is in conflict with Spring class loader.
To put the EJB-Interfaces Jar to System-Classpath can help, because both Axis2
and Spring uses the System class loader first.
But this is be problematicly if the accessed EJBs are also deployed in the same
weblogic instance.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]