0

In netbeans versions previous 7.0 was possible to write the following,

@Stateless(mappedName="Soelprotocol")
public class ProtocolFacade implements ProtocolFacadeLocal, ProtocolFacadeRemote {
    @PersistenceContext(unitName = "SOEL-ejbPU")
    private EntityManager em;

    public void create(Protocol protocol) {
        em.persist(protocol);
    }

    public void edit(Protocol protocol) {
        em.merge(protocol);
    }

    public void remove(Protocol protocol) {
        em.remove(em.merge(protocol));
    }

    public Protocol find(Object id) {
        return em.find(Protocol.class, id);
    }

    public List<Protocol> findAll() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Protocol.class));
        return em.createQuery(cq).getResultList();
    }

    public List<Protocol> findRange(int[] range) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Protocol.class));
        Query q = em.createQuery(cq);
        q.setMaxResults(range[1] - range[0]);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }

    public int count() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Protocol> rt = cq.from(Protocol.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }

}

When I try to create a remote session bean for database entity beans the check box label says "Remote in a project" with a message:

There is no suitable project available into which Remote interface could be stored. An open Ant based Java Class Library project is required.

With netbans 7.0 how to create an application client that uses remote session beans that created for database entity beans?

Is somewhere an complete example?

Vivien Barousse
  • 20,555
  • 2
  • 63
  • 64
Giorgos
  • 637
  • 3
  • 13
  • 25

1 Answers1

1

Vivien,

Create your application client as a separate Java application (or class library) project. If this project is open when you create the remote session bean in your EJB Module project, and you check the "create remote interface" option, Netbeans will propose this project for the remote interface. It will then add the remote interface and EJB client container libraries to the client project.

Here's a complete example: http://netbeans.org/kb/docs/javaee/entappclient.html

good luck!

Catweazle
  • 619
  • 12
  • 25
  • The secret is that create the entity beans for database on java class library project first. After create the session beans from entity beans – Giorgos Jul 01 '11 at 10:17