How to access an EJB that implements a remote interface in a separate web application?

I am using Netbeans 6.8 and Glassfish v3.0.

I created an ejb module and created entity classes from a database, and then created a non-bean session with a remote interface. Say for example.

 @Remote
public interface customerRemote{
    public void add(String name, String address);
    public Customer find(Integer id);
}

@Stateless
public class customerBean implements customerRemote{
    //implementations of methods
}

Then I created a new web application. But now, how can I access remote ejb in my web application. I could find a bean named jndi, but I want to know what type of object it will return? How can I cast it to clientRemote? I do not have a class named customerRemote in my web application. So how do I do this? Also, what about a client class of objects? My web application also does not have such a class called Customer. All ejb and entity classes are in a separate ejb module. Please help me: (

+2
2

customerRemote? customerRemote . , ? , ? Customer -. ejb's ejb .

- , . , . :

  • . , , . - .

  • API . ejb : jar myModule-api , API . customerRemote Customer. jar myModule-impl ( API, ). - API, myModule-api.

+10

Eclipse 3.5.2, EJB 3.0 GlassFish 2.1, , .

, , EJB, EJB- , , -, .

, @EJB , bean:

public class SimlpeServletClient extends HttpServlet {
.
.
.
@EJB(beanInterface=ISimpleJob.class,mappedName="ISimpleJob")
ISimpleJob statelesBean;
.
.
.
protected void doPost(HttpServletRequest ...){...}

.
.
.
}

bean, , :

@Stateless(name="SimpleJobBean", mappedName="ISimpleJob")
@Remote( { ISimpleJob.class })
public class SimpleJobBean implements ISimpleJob {
.
.
.
}

, , , , .

+1

Source: https://habr.com/ru/post/1738871/


All Articles