1

谁能帮助我在 jboss 服务器/我的客户端应用程序上发生了什么...?
我只是为了这个测试而坚持了最后 10天。我的 EJB 部署在 Jboss AS 7.1.1 上,客户端 Web 应用程序部署在 tomcat 7.0.42 上。
我按照以下教程设置无状态会话 bean 和我的 servlet 客户端。
[使用 JNDI 从远程客户端调用 EJB]:https : //docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
我可以访问远程对象一次但是当我刷新页面时,它给了我以下错误:

java.lang.IllegalStateException: No EJB receiver available for handling
[appName:DPlacementEAR,modulename:DPlacementEJB,distinctname:] combination for 
invocation context org.jboss.ejb.client.EJBClientInvocationContext@18b5012
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)  

这是我的项目结构: -在
Jboss 7.1.1 服务器上我部署了 DPlacementEAR,其中包含:-DPlacementEJB,其中包含实体类 Rule 和会话 bean RuleBL 和 -DPlacementLib,其中包含远程接口 IRuleBL 和 DTO RuleDO -DPlacementUI 是一个客户端 Web 应用程序部署在包含 RuleServlet 的 tomcat 7.0.42 服务器上
是我使用的代码和配置:
RuleBL:

@Stateless
@Remote(IRuleBL.class)
public class RuleBL implements IRuleBL{
    @PersistenceContext(unitName = "PLACEMENTDB")
    private EntityManager entityManager;
    @Override
    public RuleDO get(int id) {
    try {
    Rule rule = entityManager.find(Rule.class, id);
    RuleDO rdo = new RuleDO();
    rdo.setId(rule.getId());
    rdo.setCutPoint(rule.getCutPoint());
    rdo.setDisabilityPercentage(rule.getDisabilityPercentage());
    rdo.setFemalePercentage(rule.getFemalePercentage());
    rdo.setTopPercentage(rule.getTopPercentage());
    return rdo;
    } catch (Exception e) {
    e.printStackTrace();
    return null;
    }
    }   
}

和 RuleServlet:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try{
    PrintWriter out = response.getWriter();
    IRuleBL rulebl = ObjectLookupFactory.lookupRuleBL();
    RuleDO r = rulebl.get(1);
    if(r!=null)
    out.println("percent: "+ r.getTopPercentage());
    else
    out.println("null");
    }catch(Exception e){
    e.printStackTrace();
    }
...
public class ObjectLookupFactory {  
    public static IRuleBL lookupRuleBL(){
    Context context = null;
    IRuleBL bean = null;
    try {
    context = JNDILookupClass.getInitialContext();
    String appName = "DPlacementEAR";
    String moduleName = "DPlacementEJB";
    String distinctName = "";
    String beanName = "RuleBL";
    final String interfaceName = "com.placement.business.IRuleBL";
    String name = "ejb:" + appName + "/" + moduleName + "/" + distinctName    + "/" + beanName + "!" + interfaceName;           
    bean = (IRuleBL) context.lookup(name);   
    } catch (NamingException e) {
    e.printStackTrace();
    }
    return bean;
    }
    .......
public class JNDILookupClass {
    private static Context initialContext;
    public static Context getInitialContext() throws NamingException {
    if (initialContext == null) {
    Properties properties = new Properties();                  
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
    properties.put(Context.SECURITY_PRINCIPAL, "appuser");
    properties.put(Context.SECURITY_CREDENTIALS, "123"); //
    properties.put("jboss.naming.client.ejb.context", true);
    properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    initialContext = new InitialContext(properties);
    }
    return initialContext;
    }
    }

Jboss部署:

16:14:52,777 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) JBAS011401: Read     
persistence.xml for PLACEMENTDB
16:14:52,792 INFO      
[org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named RuleBL in deployment unit     subdeployment "DPlacementEJB.jar" of deployment "DPlacementEAR.ear" are as follows:

    java:global/DPlacementEAR/DPlacementEJB/RuleBL!com.placement.business.IRuleBL
    java:app/DPlacementEJB/RuleBL!com.placement.business.IRuleBL
    java:module/RuleBL!com.placement.business.IRuleBL
    java:jboss/exported/DPlacementEAR/DPlacementEJB/RuleBL!com.placement.business.IRuleBL
    java:global/DPlacementEAR/DPlacementEJB/RuleBL
    java:app/DPlacementEJB/RuleBL
    java:module/RuleBL
16:14:52,814 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011402: Starting  
Persistence Unit Service 'DPlacementEAR.ear/DPlacementEJB.jar#PLACEMENTDB'
16:14:52,816 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-1)    
HHH000204: Processing PersistenceUnitInfo [
name: PLACEMENTDB
...]

在我在 tomcat 7.042 上运行 DPlacementUI 后,它给了我

percent:60.0

但是当我刷新页面时,它一直显示以下错误:

java.lang.IllegalStateException: No EJB receiver available for handling 
[appName:DPlacementEAR,modulename:DPlacementEJB,distinctname:] combination for invocation
context org.jboss.ejb.client.EJBClientInvocationContext@17c3215
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
at com.sun.proxy.$Proxy5.get(Unknown Source)
at com.servlet.RuleServlet.doGet(RuleServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
4

1 回答 1

0

试着看看这里的解释

用于 web 的 java:在 jboss 上访问远程 ejb

如果您的 Jboss 部署在与托管 Tomcat 的机器不同的机器上,这也会对您有所帮助。

于 2013-08-05T07:45:56.170 回答