1

can anyone help me what is happening on jboss server/my client app...? i stuck for last 10
days just for this test. My EJB is deployed on Jboss AS 7.1.1 and client web app is deployed on tomcat 7.0.42.
i follow the following tutorial and set up stateless session bean and my servlet client.
[EJB invocations from a remote client using JNDI]:https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI and
i can access the remote object once but when i refresh the page it gives me the following error:

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)  

here is my project structure:
-on Jboss 7.1.1 server i deployed DPlacementEAR, which contains: -DPlacementEJB which contains entity class Rule and session bean RuleBL and -DPlacementLib which contains remote interface IRuleBL and DTO RuleDO -DPlacementUI is a Client web app is deployed on tomcat 7.0.42 server which contains RuleServlet
here are the codes and configs i used:
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;
    }
    }   
}

and 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 deployment:

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
...]

After i run DPlacementUI on tomcat 7.042 it gives me

percent:60.0

but when i refresh the page it keeps showing the following error:

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)
keme686
  • 46
  • 4

1 Answers1

0

try to look here at the explanation

java for the web: accessing remote ejb on jboss.

This helps you also in case your Jboss is deployed on a different machine than the one that hosts Tomcat.

LMG
  • 966
  • 1
  • 12
  • 28
  • thanks, but i tried that way even if the two servers are in the same machine. no luck. I add the WAR file to EAR and deployed to Jboss (in just one server) works fine. When i separate the war and try to deploy on tomcat it gives me java.lang.IllegalStateException: No EJB receiver available for handling – keme686 Aug 09 '13 at 17:15
  • It means that you have probelm in the lookup, did you add the jboss-client.jar from joss to the client performing the lookup? A well as adding the interface in the jboss standalone.xml?? You can try reachability of your jboss from another machine just trying from the browser to access the administration panel of jboss, and see what happens.. – LMG Aug 09 '13 at 20:45
  • yes i add jboss-client.jar from my web client. but its the same. – keme686 Aug 12 '13 at 01:42
  • I don't know what more to suggest :( – LMG Aug 14 '13 at 07:19
  • ok thanks for your help till here, i am still searching for the solution :'( – keme686 Aug 30 '13 at 10:04
  • @user2627589 Did u found the solution?? – Stunner Apr 29 '15 at 14:47