远程客户端的奇怪行为。当我调用ejb facade方法计数时,它是工作并返回用户数。但是当我通过物体时,却失败了! 有错误
EJBCLIENT000025:没有可用于处理[appName:writer-ear,moduleName:writer-ejb-1.0,distinctName:]组合的EJB接收器,用于调用上下文org.jboss.ejb.client.EJBClientInvocationContext@331e965f
我配置了所有可能的方法,但仍然远程客户端失败。
例如
/////////////////////////////
// The "standard" JNDI lookup
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
//jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); // needed for a login module that requires the password in plaintext
jndiProperties.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
// jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
jndiProperties.put(Context.SECURITY_PRINCIPAL, "user");
jndiProperties.put(Context.SECURITY_CREDENTIALS, "pass");
jndiProperties.put("jboss.naming.client.ejb.context", true);
final Context context = new InitialContext(jndiProperties);
traverseJndiNode("/", context);
final UserFacadeRemote helloWorld = (UserFacadeRemote) context.lookup("writer-ear/writer-ejb-1.0/userFacade!" + UserFacadeRemote.class.getName());
System.out.println("count " + helloWorld.count());
UserDTO user = new UserDTO();
user.setEmail("mail.google@gmail.com");
user.setFirstname("Nina");
user.setLastname("Ben");
user.setPassword("Password");
user.setRegisteredDate(new Date(System.currentTimeMillis()));
helloWorld.save(user);
context.close();
实际上save方法是假方法
@Override
public void save(UserDTO user) {
System.out.println("Received object " + user.getFirstname());
try {
System.out.println("Saving object ");
} catch (Exception e) {
e.printStackTrace();
}
}
在第二次查找中相同
// Using the proprietary JBoss EJB Client API
final Properties ejbProperties = new Properties();
ejbProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
ejbProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
ejbProperties.put("remote.connections", "1");
ejbProperties.put("remote.connection.1.host", "localhost");
ejbProperties.put("remote.connection.1.port", 8080);
//ejbProperties.put("remote.connection.1.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER"); // needed for forcing authentication over remoting (i.e. if you have a custom login module)
//ejbProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); // needed for a login module that requires the password in plaintext
ejbProperties.put("remote.connection.1.username", "user");
ejbProperties.put("remote.connection.1.password", "pass");
ejbProperties.put("org.jboss.ejb.client.scoped.context", "true"); // Not needed when EJBClientContext.setSelector is called programatically. ATTENTION: Client-Interceptor registration below does not work with this property! BUG?
final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(ejbProperties);
final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(selector);
EJBClientContext.getCurrent().registerInterceptor(0, new ClientInterceptor());
final Context ejbContext = new InitialContext(ejbProperties);
final UserFacadeRemote ejbHelloWorld = (UserFacadeRemote) ejbContext.lookup("ejb:writer-ear/writer-ejb-1.0/userFacade!" + UserFacadeRemote.class.getName());
// UserDTO user = new UserDTO();
// user.setEmail("mail.google@gmail.com");
// user.setFirstname("Nina");
// user.setLastname("Ben");
// user.setPassword("Password");
// user.setRegisteredDate(new Date(System.currentTimeMillis()));
// ejbHelloWorld.save(user);
System.out.println("second count " + ejbHelloWorld.count());
我的客户端应用程序在tomcat下运行,所以什么错了?为什么我甚至可以从数据库中获取数据,但是当通过DTO时,客户端会失败。我探索了很多,旧版本的JBoss我没有做过同样的事情。
答案 0 :(得分:1)
哦,我忘了设置我的DTO实现Serializable接口:(
public class UserDTO implements Serializable{
private static final long serialVersionUID = 1L;
private Long id;