Java Wildfly 10.x远程EJB客户端在发送名称中带有CONNECT的枚举值时挂起
我有一个简单的无状态EJB,它有一个将基本枚举作为参数并返回相同枚举的方法Java Wildfly 10.x远程EJB客户端在发送名称中带有CONNECT的枚举值时挂起,java,enums,wildfly-10,Java,Enums,Wildfly 10,我有一个简单的无状态EJB,它有一个将基本枚举作为参数并返回相同枚举的方法 @Stateless @LocalBean public class SerialBean implements RemoteSerial { @Override public Whatever enumTest(Whatever type) { return type; } } 以下是简单的枚举: public enum Whatever { TEST, CON
@Stateless
@LocalBean
public class SerialBean implements RemoteSerial {
@Override
public Whatever enumTest(Whatever type) {
return type;
}
}
以下是简单的枚举:
public enum Whatever {
TEST,
CONNECT_TEST
}
还有一个简单的客户端:
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
jndiProps.put("jboss.naming.client.ejb.context", true);
try {
Context ctx = new InitialContext(jndiProps);
RemoteSerial serial = (RemoteSerial)ctx.lookup("rmi_test/rmi_ejb/SerialBean!test.RemoteSerial");
System.out.println(serial.enumTest(Whatever.TEST));
System.out.println(serial.enumTest(Whatever.CONNECT_TEST));
} catch (NamingException ex) {
ex.printStackTrace();
}
当我运行此代码时,客户端成功连接到WildFly并返回第一个结果(测试)。但是,当执行第二个方法调用(CONNECT\u测试)时,客户端会冻结。没有收到任何答复
如果我将CONNECT_TEST的名称更改为不包含CONNECT的名称,代码就会正常工作。我甚至可以将CONNECT更改为CONNECT,这样就可以了
我已经在Windows 7上的10.0和10.1中使用jdk1.8.0_102和121尝试了这一点
这里可能发生了什么事?我无法重现您的结果。为了比较,这里是我的代码,全部 服务器(ejb模块rmi_测试): TestEnum.java
package com.example.rmitest;
public enum TestEnum {
TEST, CONNECT_TEST
}
SerialBean.java
package com.example.rmitest;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
@Stateless
@LocalBean
public class SerialBean implements RemoteSerial {
@Override
public TestEnum enumTest(TestEnum input) {
return input;
}
}
RemoteSerial.java
package com.example.rmitest;
import javax.ejb.Remote;
@Remote
public interface RemoteSerial {
TestEnum enumTest(TestEnum input);
}
客户端(独立JSE应用程序,类路径上有wildfly-10.1.0.Final/bin/Client/jboss-Client.jar):
Client.java
package com.example.rmitest;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Client {
public static void main(String... args) {
RemoteSerial remoteSerial = lookupRemoteService();
System.out.println(remoteSerial.enumTest(TestEnum.TEST));
System.out.println(remoteSerial.enumTest(TestEnum.CONNECT_TEST));
}
private static RemoteSerial lookupRemoteService() {
try {
return (RemoteSerial) jndiConnect().lookup("/rmi_ejb/SerialBean!com.example.rmitest.RemoteSerial");
} catch (NamingException e) {
throw new RuntimeException("Failed to lookup a remote interface", e);
}
}
private static Context jndiConnect() {
try {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, "http-remoting://localhost:8080");
properties.setProperty("jboss.naming.client.ejb.context", "true");
return new InitialContext(properties);
} catch (NamingException e) {
throw new RuntimeException("Failed to establish a connection", e);
}
}
}
最后,我的控制台输出:
试验
连接测试
我一直在用各种平台进行测试。以下组合已经正常工作:*Linux到Linux*Linux到Win7桌面(我遇到此问题的桌面)*Win10桌面(另一台机器)到Linux*Win10桌面到Win7桌面数据包跟踪显示Win7桌面根本没有发送问题数据。这一切在JBoss 6.1上都可以正常工作,所以我的桌面和WildFly 10客户端的东西显然有些奇怪。我最终弄明白了发生了什么事——卡巴斯基对数据流中的内容感到震惊。我一禁用卡巴斯基,一切都开始按预期工作。事实上,卡巴斯基和WildFly相处得并不特别好。