我曾经使用 jboss 4.2.3 GA 并且一切正常(至少从客户端调用远程接口)。现在我尝试使用 Jboss 7.0.1 FINAL 来部署它
我有(在服务器项目上)这个类:
@Remote(ConfigurationHelperRemote.class)
@Local(ConfigurationHelperLocal.class)
@Stateless
public class ConfigurationHelper implements ConfigurationHelperRemote, ConfigurationHelperLocal {
...
}
我有远程接口
@Remote
public interface ConfigurationHelperRemote {
...
}
现在我曾经在这样的上下文的帮助下从客户端调用远程接口:
configurationHelper = (ConfigurationHelperRemote) ctx.lookup("ear-1.0.0/ConfigurationHelper/remote");
但这不再起作用了。现在我收到此错误消息
javax.naming.NameNotFoundException: Name 'ear-1.0.0' not found in context ''
我的 ear 文件叫做ear-1.0.0.ear,里面的客户端叫做client-1.0.0.war,服务器叫做server-1.0.0.jar。
这是ear文件中application.xml的内容
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>ear</display-name>
<module>
<web>
<web-uri>client-1.0.0.war</web-uri>
<context-root>/client</context-root>
</web>
</module>
<module>
<ejb>server-1.0.0.jar</ejb>
</module>
</application>
我需要在哪里配置上下文名称?或者我做错了什么?
非常感谢和问候,豪克
PS.:我只是打印了所有的JNDI Context Information,只有数据库中的数据源。我这样做了:
public static void showJndiContext( Context ctx, String name, String space )
{
if( null == name ) name = "";
if( null == space ) space = "";
try {
NamingEnumeration<NameClassPair> en = ctx.list( name );
while( en != null && en.hasMoreElements() ) {
String delim = ( name.length() > 0 ) ? "/" : "";
NameClassPair ncp = en.next();
System.out.println( space + name + delim + ncp );
if( space.length() < 40 )
showJndiContext( ctx, ncp.getName(), " " + space );
}
} catch( javax.naming.NamingException ex ) {
}
}