LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1287|回复: 1

JBOSS下开发部署EJB问题!!!

[复制链接]
发表于 2005-6-11 20:17:55 | 显示全部楼层 |阅读模式
大家好,我按照网上和书上的一些例子,编写了一个STATELESS SESSION EJB,想把它部署到jboss上,
我用的是JDK1.5 JBOSS4.0.2 RHAS4.0
我把程序编写好,编译,打包成Helloworld.jar并部署到$JBOSS_HOME$/server/default/deploy下,该EJB能被自动部署执行,但是我的测试程序却不能运行,请大家帮忙看一下程序和错误,还有,如果我把JDK换成1.4版本的,该EJB在JBOSS下就不能被部署,但是我把<精通JBOSS>中的一个例子拿来部署到jdk1.4版本下运行的JBOSS中,却能被部署,请问这是为什么啊?
还有一个问题,在WINDOWS下,打开JBOSS的WEB-CONSOLE,能看到左边的APPLET,但是在LINUX下却看不到,而且WEB-CONSOLE左侧显示的JVM ENVIRONMENT中的MEMORY,在WINDOWS中的也比LINUX的大

ejb-remote:

public interface Hello extends javax.ejb.EJBObject{
public String hello() throws java.rmi.RemoteException;
}

ejb-home:

public interface HelloHome extends javax.ejb.EJBHome{
Hello create() throws java.rmi.RemoteException,javax.ejb.CreateException;
}


ejb-localremote:

public interface HelloLocal extends javax.ejb.EJBLocalObject{
public String hello();
}

ejb-localhome:

public interface HelloLocalHome extends javax.ejb.EJBLocalHome{
HelloLocal create() throws javax.ejb.CreateException;
}

ejb-bean:

import javax.ejb.*;
public class HelloBean implements javax.ejb.SessionBean{
private javax.ejb.SessionContext ctx;
public void ejbCreate(){
System.out.println("ejbCreate");
}
public void ejbRemove(){
System.out.println("ejbRemove");
}
public void ejbActivate(){
System.out.println("ejbActivate");
}
public void ejbPassivate(){
System.out.println("ejbPassivate");
}
public void setSessionContext(javax.ejb.SessionContext ctx){
this.ctx=ctx;
}
public String hello(){
System.out.println("hello()");
return "hello.world!";
}
}


客户端测试程序:

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
import java.rmi.RemoteException;
import java.util.Hashtable;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
public class HelloClient{
public static void main(String args[])throws Exception{
Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"localhost");
Context ctx=new InitialContext(props);
Object obj=ctx.lookup("HelloBeanHomeRemote");
HelloHome Home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello=Home.create();
System.out.println(hello.hello());
hello.remove();
}
}

ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!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>Hello</ejb-name>
<remote>Hello</remote>
<home>HelloHome</home>
<local-home>HelloLocalHome</local-home>
<local>HelloLocal</local>
<ejb-class>HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

jboss.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>HelloBeanHomeRemote</jndi-name>
<method-attributes>
</method-attributes>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>

linux-console:

20:24:58,028 INFO  [DLQ] Bound to JNDI name: queue/DLQ
20:24:58,766 INFO  [ConnectionFactoryBindingService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA to JNDI name 'java:JmsXA'
20:25:01,324 INFO  [EjbModule] Deploying Hello
20:25:02,589 INFO  [EJBDeployer] Deployed: file:/opt/programmes/jboss-4.0.2/server/default/deploy/HelloWorld1.jar

JBUILDER2005中CONSOLE中显示的错误:

Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: HelloHome (no security manager: RMI class loader disabled)]
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at jboss1.HelloClient.main(HelloClient.java:18)
Caused by: java.lang.ClassNotFoundException: HelloHome (no security manager: RMI class loader disabled)
        at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:531)
        at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:639)
        at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:309)
        at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:241)
        at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1469)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1432)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
        at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
        at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
        ... 3 more
发表于 2005-6-22 14:23:10 | 显示全部楼层
你的类库路径问题系统找不到所需要的类,编译出错Root exception is java.lang.ClassNotFoundException:
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表