【问题标题】:JNDI jboss 7 client on tomcat throws java.lang.IllegalStateException: No EJB receiver available for handlingTomcat 上的 JNDI jboss 7 客户端抛出 java.lang.IllegalStateException:没有可用于处理的 EJB 接收器
【发布时间】:2013-08-02 15:36:07
【问题描述】:

谁能帮助我在 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 服务器上 这是我使用的代码和配置:
规则BL:

@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)

【问题讨论】:

  • 我也有同样的问题..你有什么解决办法吗???如果你解决了,请告诉我。

标签: tomcat7 ejb-3.0 jboss7.x jndi remote-client


【解决方案1】:

试着看这里的解释

java for the web: accessing remote ejb on jboss.

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

【讨论】:

  • 谢谢,但即使两台服务器在同一台机器上,我也尝试过这种方式。没运气。我将 WAR 文件添加到 EAR 并部署到 Jboss(仅在一台服务器中)工作正常。当我将战争分开并尝试在 tomcat 上部署时,它给了我 java.lang.IllegalStateException: No EJB receiver available for handling
  • 这意味着您在查找中有问题,您是否将joss中的jboss-client.jar添加到执行查找的客户端?在 jboss Standalone.xml 中添加接口以及添加接口?您可以尝试从另一台机器访问您的 jboss,只是尝试从浏览器访问 jboss 的管理面板,然后看看会发生什么..
  • 是的,我从我的 Web 客户端添加了 jboss-client.jar。但它是一样的。
  • 我不知道还有什么建议:(
  • 好的,感谢您的帮助,直到这里,我仍在寻找解决方案:'(
猜你喜欢
  • 2013-02-28
  • 2016-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-05
  • 2017-04-19
  • 2012-09-08
  • 1970-01-01
相关资源
最近更新 更多