EJBException: Invalid invocation, check your deployment packaging creat

如果jsp或servlet调用ejb时报下面的错误:
INFO [STDOUT] java.rmi.ServerException: EJBException:; nested
exception is:
javax.ejb.EJBException: Invalid invocation, check your deployment packaging,
method=public abstract test.ejb.TestEJBInterface test.ejb.TestEJBHome.create()
throws javax.ejb.CreateException,java.rmi.RemoteException


解决办法有三种:
1、编辑%jboss%/server/default/conf/jboss-service.xml
<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">false</attribute>
...
</mbean>
将属性CallByValue的值改为true
2、编辑%jboss%/server/default/deploy/ear-deployer.xml
<mbean code="org.jboss.deployment.EARDeployer"
name="jboss.j2ee:service=EARDeployer">
<attribute name="Isolated">false</attribute>
<attribute name="CallByValue">false</attribute>
<attribute name="EnablelibDirectoryByDefault">true</attribute>
</mbean>
将属性Isolated和CallByValue的值改为true
3、编辑%jboss%/server/default/deploy/jboss-web.deployer/META-INF/jboss-service.x
ml
<attribute name="Java2ClassLoadingCompliance">false</attribute>
<attribute name="UseJBossWebLoader">false</attribute>
将属性Java2ClassLoadingCompliance和UseJBossWebLoader的值改为false,这里默认值一
般都是false
一般情况下,使用第二种方式就可以解决该问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的 EJB2 示例: 1. 创建一个接口 MyRemoteInterface,定义一个方法 sayHello: ```java import java.rmi.RemoteException; import javax.ejb.EJBObject; public interface MyRemoteInterface extends EJBObject { public String sayHello() throws RemoteException; } ``` 2. 创建一个实现 MyRemoteInterface 接口的 bean MyBean: ```java import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; public class MyBean implements SessionBean, MyRemoteInterface { private static final long serialVersionUID = 1L; public void ejbCreate() throws CreateException { } public String sayHello() throws RemoteException { return "Hello World!"; } public void ejbRemove() throws EJBException, RemoteException { } public void ejbActivate() throws EJBException, RemoteException { } public void ejbPassivate() throws EJBException, RemoteException { } public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException { } } ``` 3. 在 ejb-jar.xml 文件中声明 MyBean: ```xml <?xml version="1.0"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar> <enterprise-beans> <session> <ejb-name>MyBean</ejb-name> <home>MyRemoteInterface</home> <remote>MyRemoteInterface</remote> <ejb-class>MyBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar> ``` 4. 部署到服务器上,可以通过 JNDI 查找 MyBean 并调用 sayHello 方法: ```java import javax.naming.InitialContext; import javax.naming.NamingException; public class MyClient { public static void main(String[] args) throws NamingException, RemoteException { InitialContext ctx = new InitialContext(); MyRemoteInterface myBean = (MyRemoteInterface) ctx.lookup("MyBean/remote"); System.out.println(myBean.sayHello()); } } ``` 以上就是一个简单的 EJB2 示例,它展示了如何创建一个远程 EJB,并在客户端调用它的方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值