从容器外能够正常调用EJB,但是web 应用中spring bean调用EJB出现下面异常 <bean id="secuContainerBo" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"> <property name="jndiName" value="oss.service.security.business.SecuContainerBo"/> <property name="businessInterface" value="oss.service.security.business.ISecuContainerBo"/> <property name="lookupHomeOnStartup" value="false"/> </bean>
RemoteProxyFailureException: No matching RMI stub method found for: public abstract
从JSP页面直接调用EJB <% Hashtable hs = new Hashtable(); hs.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); hs.put("java.naming.provider.url","jnp://localhost:1099"); hs.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); Context iniCtx = new InitialContext(hs); Object ref = iniCtx.lookup("oss.service.security.business.SecuContainerBo"); oss.service.security.business.SecuContainerBoEJBHome ejbHomeObject = (oss.service.security.business.SecuContainerBoEJBHome) PortableRemoteObject.narrow(ref, oss.service.security.business.SecuContainerBoEJBHome.class); out.print((ejbHomeObject.create()).loadAllAuth(new oss.service.security.domain.SysStaffMember())); %> java.rmi.ServerException: EJBException:; nested exception is: javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract
解决办法:
1。修改 conf/jboss-service.xml 中NamingService 的CallByValue 参数值为'true'
<mbean code="org.jboss.naming.NamingService" name="jboss:service=Naming" xmbean-dd="resource:xmdesc/NamingService-xmbean.xml"> <!-- The call by value mode. true if all lookups are unmarshalled using the caller's TCL, false if in VM lookups return the value by reference. --> <attribute name="CallByValue">true</attribute> <!-- The listening port for the bootstrap JNP service. Set this to -1 to run the NamingService without the JNP invoker listening port. -->
2。修改 deploy/ear-deployer.xml,中的Isloated和CallByValue 为 true
<server> <!-- EAR deployer, remove if you are not using ear deployments --> <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"> <!-- A flag indicating if ear deployments should have their own scoped class loader to isolate their classes from other deployments. --> <attribute name="Isolated">true</attribute> <!-- A flag indicating if the ear components should have in VM call optimization disabled. --> <attribute name="CallByValue">true</attribute> <!-- A flag the enables the default behavior of the ee5 library-directory. If true, the lib contents of an ear are assumed to be the default value for library-directory in the absence of an explicit library-directory. If false, there must be an explicit library-directory. --> <attribute name="EnablelibDirectoryByDefault">true</attribute> </mbean> </server>
3。修改 deploy/jboss-web.deployer/META-INF/jboss-service.xml中的Java2ClassLoadingCompilance 和 UseJbossWebLoader为true
<!-- Get the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model. --> <attribute name="Java2ClassLoadingCompliance">true</attribute> <!-- A flag indicating if the JBoss Loader should be used. This loader uses a unified class loader as the class loader rather than the tomcat specific class loader. The default is false to ensure that wars have isolated class loading for duplicate jars and jsp files. --> <attribute name="UseJBossWebLoader">true</attribute>