users@glassfish.java.net

Re: problem accessing remote ejb and a strange fact

From: <glassfish_at_javadesktop.org>
Date: Thu, 21 Jun 2007 04:03:14 PDT

Dear Ksac,

in order to verify the correctness of my application's architecture I've written two new simple modules.

ALL WORKS FINE. Something in my previous code was uncorrect and made remote bean unavailable.

FIRST QUESTION:
my old ejb used other container resources (other beans and pojos) and these resources used some other resources (as a chain); what happens if some dependency, at a "deep" level, is not resolved properly? Can the verifier tell me something? And if some dependency is not resolved, will the bean be "present" at JNDI level?
I was able to deploy application with no verifier error and when I tried to run application on the same machine, as I told, all worked fine. It seems that, running application on the same app serv, the problem is "bypassed".

SECOND QUESTION:
look at the sample below.
We have a web application and a very simple ejb module. The two modules are deployed on different machines.
The first bean uses a method of the second bean.
Well, in order to make the application work fine, I have to declare a remote interface for the second bean. If not, I'm not able to deploy my web application. This is the error:

---
Deploying application in domain failed; Error loading deployment descriptors for module [WebClient] -- Cannot resolve reference Unresolved Ejb-Ref com.mydomain.beans.MySessionBean/mySecondSessionBean_at_jndi: @null_at_com.mydomain.beans.MySecondSessionLocal_at_Session@null Error loading deployment descriptors for module [WebClient] -- Cannot resolve reference Unresolved Ejb-Ref com.mydomain.beans.MySessionBean/mySecondSessionBean_at_jndi: @null_at_com.mydomain.beans.MySecondSessionLocal_at_Session@null
---
Can the first ejb, used in the servlet, use second ejb through a local interface? If not, why? Why does the servlet care of second ejb?
--> FIRST SIMPLE SESSION BEAN
/*
 * MySessionBean.java
 *
 * Created on June 21, 2007, 9:56 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.mydomain.beans;
import javax.ejb.EJB;
import javax.ejb.Stateless;
/**
 *
 * @author emilio
 */
@Stateless(mappedName="ejb/MySessionBean")
public class MySessionBean implements MySessionRemote {
    @EJB
    private MySecondSessionRemote mySecondSessionBean; // SECOND SESSION BEAN
    
    /** Creates a new instance of MySessionBean */
    public MySessionBean() {
    }
    public String businessMethod() {
        //TODO implement businessMethod
        return "first hello + " + mySecondSessionBean.businessMethodTwo();
    }
}
--> SECOND SIMPLE SESSION BEAN
/*
 * MySecondSessionBean.java
 *
 * Created on June 21, 2007, 10:31 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.mydomain.beans;
import javax.ejb.Stateless;
/**
 *
 * @author emilio
 */
@Stateless
public class MySecondSessionBean implements MySecondSessionRemote {
    
    /** Creates a new instance of MySecondSessionBean */
    public MySecondSessionBean() {
    }
    public String businessMethodTwo() {
        //TODO implement businessMethodTwo
        return "second hello";
    }
}
--> SERVLET CODE (SNIPPET)
...
@EJB(name="aName", mappedName="corbaname:<host>:3700#ejb/MySessionBean") // HARDCODED MAPPING
    private MySessionRemote mySessionBean;
...
out.print(mySessionBean.businessMethod()); // IT PRINTS "first hello + second hello"
...
Thank you!
emilio
[Message sent by forum member 'emilioremogna' (emilioremogna)]
http://forums.java.net/jive/thread.jspa?messageID=223219