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

项目结构
...全文
259 4 打赏 收藏 转发到动态 举报
写回复
用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找不到吗?
内容概要:本文提出一种基于鱼鹰优化算法(OOA)优化的CNN-BiGUR-Attention混合模型,用于提升短期风电功率预测的精度与稳定性,采用Matlab实现代码仿真。该模型融合卷积神经网络(CNN)提取输入数据的局部空间特征,利用双向门控循环单元(BiGUR)捕捉风速、功率等时间序列的前后向动态依赖关系,并引入注意力机制自适应强化关键时间步的特征权重,从而增强模型对非平稳风电数据的表征能力;进一步,采用OOA算法对模型超参数进行全局寻优,有效提升模型收敛速度与泛化性能。研究基于实际风电场历史数据开展实验验证,结果表明,该方法相较传统模型在预测精度、鲁棒性和误差抑制方面表现更优,适用于高比例可再生能源接入背景下的电力系统调度需求。; 适合人群:从事新能源发电预测、电力系统优化调度、智能算法与深度学习融合应用等方向的科研人员及工程技术人员,尤其适合具备Matlab编程能力、熟悉时间序列建模与深度学习框架的研究者。; 使用场景及目标:①实现风电场短期功率高精度预测,支撑电网安全稳定调度与能量管理;②为深度学习模型结构设计与智能优化算法联合调参提供实践范例;③推动人工智能技术在可再生能源预测、智能电网运行等领域的落地应用。; 阅读建议:建议结合提供的Matlab代码深入理解CNN-BiGUR-Attention网络架构搭建、注意力机制实现方式及OOA优化流程,重点关注数据预处理、模型训练与参数调优细节,可通过替换不同风电数据集进行对比实验,进一步掌握模型迁移能力与适应性。

67,536

社区成员

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

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