359025439 发表于 2015-8-11 13:38:43

EJB远程(二),web在独立的tomcat或resin容器下调用jboss的ejb

  需要jbossall-client.jar包和相关的ejb接口和类的jar包(或将ejb项目添加为依赖项目)
  修改tomcat端口
  找到Tomcat \conf\server.xml文件,然后找到下面的代码:
    port="8080"               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"   
               enableLookups="false" redirectPort="8443" acceptCount="100"   
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" />
  修改 port="8080" 为你想要的端口就可以了.
  修改tomcat密码:
  conf/tomcat-users.xml
  <?xml version='1.0' encoding='utf-8'?>   
<tomcat-users>   
<role rolename=&quot;manager&quot;/>   
<user username=&quot;admin&quot; password=&quot;admin&quot; roles=&quot;manager&quot;/>   
</tomcat-users>
  添上红色部分。
  访问代码不变
<%
Properties props=new Properties();
props.setProperty(&quot;java.naming.factory.initial&quot;,&quot;org.jnp.interfaces.NamingContextFactory&quot;);
props.setProperty(&quot;java.naming.provider.url&quot;,&quot;localhost:1099&quot;);
props.setProperty(&quot;java.naming.factory.url.pkgs&quot;,&quot;org.jboss.naming&quot;);
InitialContext ctx;
try{
ctx=new InitialContext(props);
IHelloWorld h=(IHelloWorld)ctx.lookup(&quot;HelloWorld/remote&quot;);
out.println(h.sayHello(&quot;persia.&quot;));
}
catch(NamingException e){
out.println(e.getMessage());
}
%>
页: [1]
查看完整版本: EJB远程(二),web在独立的tomcat或resin容器下调用jboss的ejb