EJB3+JBoss eap 6客户端报错,大神帮忙解决一下

hao_chenhh 2014-05-07 04:03:14
服务端接口
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

项目结构
...全文
135 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinhe22 2014-05-08
  • 打赏
  • 举报
回复
这个问题应该出现在你配置文件 .properties 上 自己去网上找找 配置文件规范的配置 ,然后试试 我用的是7版本的没那么多的文件配
hao_chenhh 2014-05-07
  • 打赏
  • 举报
回复
Could not obtain connection to any of these urls: 127.0.0.1:4447 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] javax.naming.CommunicationException: Could not obtain connection to any of these urls: 127.0.0.1:4447 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server 127.0.0.1:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 0000000C]] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) at javax.naming.InitialContext.lookup(Unknown Source) at test.EJBTester.testStatelessEjb(EJBTester.java:54) at test.EJBTester.main(EJBTester.java:40) Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server 127.0.0.1:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 0000000C] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:263) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385) ... 5 more Caused by: java.io.StreamCorruptedException: invalid stream header: 0000000C at java.io.ObjectInputStream.readStreamHeader(Unknown Source) at java.io.ObjectInputStream.<init>(Unknown Source) at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:250) ... 6 more 报错信息
xuefeng0707 2014-05-07
  • 打赏
  • 举报
回复
你这都不说什么错的。。
loveunittesting 2014-05-07
  • 打赏
  • 举报
回复
杀错呢?难道是jndi找不到吗?

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧