我想在Eclipse中的JBOSS 4.2上開發一個基本的EJB3應用程序我已經在eclipse中創建了一個EJB項目。如何獲取EJB?
以下是我的遠程和本地接口。
package com.test;
import javax.ejb.Local;
@Local
public interface HelloWorldLocal
{
public String getGreeting();
}
package com.test;
import javax.ejb.Remote;
@Remote
public interface HelloWorldRemote
{
public String getGreeting();
}
和我的EJB實現
package com.test;
import javax.ejb.Stateless;
@Stateless
public class HelloWorld implements HelloWorldRemote, HelloWorldLocal {
public HelloWorld() {
// TODO Auto-generated constructor stub
}
public String getGreeting() {
// TODO Auto-generated method stub
return "First EJB People";
}
}
我已經部署了本作中的JBoss的分解JAR,它運行良好。
我的第一個問題是:
還有什麼我已經加入到這個罐子爆炸?
其次我創建了一個獨立的客戶端和加入上述罐子其類路徑
客戶端代碼如下
包com.testejb;
import java.io.FileInputStream; import java.util.Properties;
import javax.naming.InitialContext;
public class TestBean {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
HelloWorldRemote getMess = null;
try {
Properties props = new Properties();
Properties props = new Properties();
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
props.setProperty("java.naming.provider.url", "localhost:1099");
InitialContext ic = new InitialContext(props);
//
getMess = (HelloWorldRemote) ic.lookup("HelloWorldRemote/remote");
System.out.println(getMess.getGreeting());
} catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
}
}
罐子的名稱是FirstEJB。 我已經嘗試查找FirstEJB/HelloWorldRemote/remote。
但是當我運行程序出現錯誤
javax.naming.NameNotFoundException: HelloWorldRemote not bound
如果我鍵入查詢作爲的HelloWorld /遠程I得到錯誤
Caused by: java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = 1126421850898582900, local class serialVersionUID = -2711693270411201590