在尝试从Swing应用连接到Glassfish v3时,第一次连接非常缓慢,需要4-10秒钟。客户端如下:
public void myMethod(){
NewSessionBeanRemote facade;
try {
InitialContext ic = new InitialContext();
facade = (NewSessionBeanRemote) ic.lookup(NewSessionBeanRemote.class.getName());
target.setText(facade.businessMethod());
} catch (NamingException ex) {
ex.printStackTrace();
}
}
在服务器端:
@Stateless
public class NewSessionBean implements NewSessionBeanRemote {
@Override
public String businessMethod() {
return String.valueOf(Math.random() + 121 + 300);
}
}
@Remote
public interface NewSessionBeanRemote {
String businessMethod();
}
我需要在环境中做出哪些改变?