EJB3+JBoss eap 6客户端报错,大神帮忙解决一下
服务端接口
接口实现类
客户端代码
jboss-ejb-client.properties文件
项目结构

package com.xx.leo;
import javax.ejb.Remote;
@Remote
public interface HelloWorldBusiness {
public String sayHello();
}接口实现类
package com.xx.leo;
import javax.ejb.Stateless;
@Stateless
public class HelloWorldBean implements HelloWorldBusiness {
public String sayHello(){
return "Hello World.";
}
}客户端代码
package test;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.xx.leo.HelloWorldBusiness;
public class HelloWorldTest {
/**
* @param args
*/
public static void main(String[] args) {
Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
try {
Context context = new InitialContext(jndiProperties);
final String appName = "";
final String moduleName = "ejbdemo";
final String distinctName = "";
Object obj = context.lookup("ejb:" + appName + "/" + moduleName
+ "/" + distinctName
+ "/HelloWorldBean!com.xx.leo.HelloWorldBusiness");
HelloWorldBusiness hwr = (HelloWorldBusiness) obj;
String say = hwr.sayHello();
System.out.println(say);
} catch (NamingException e) {
e.printStackTrace();
}
}
}jboss-ejb-client.properties文件
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false项目结构

...全文


