Remote client : which library ?
mustaghattack Aug 17, 2005 11:51 AMThis is a transfert from the "Design EJB 3" forum ...
"mustaghattack" wrote:
Hi,
I have a problem with creating a remote client :
I put in my build path the following library :
- jbossall-client.jar
- myejb.jar (which is my ejb interface)
When I launch my client (JBoss 4.0.2 with EJB 3.0 RC1 is running and my ejb are well deployed) I get this :javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb3.JBossProxy (no security manager: RMI class loader disabled)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at Client.main(Client.java:17)
My ejb are pretty simple :
package org.wiskee.bd;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
@Entity
public class Massif {
private int massifId;
private String nom;
@Id(generate = GeneratorType.AUTO)
@Column(name = "MASSIF_ID")
public int getMassifId() {
return massifId;
}
public void setMassifId(int id) {
this.massifId = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
}
And the stateless session bean which manage this entity bean is :
package org.wiskee.bd;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
public @Stateless class MassifsBean implements Massifs {
@PersistenceContext
private EntityManager manager;
public List<Massif> getAllMassif() {
ArrayList< Massif > massifs = new ArrayList< Massif>();
Query q = manager.createQuery( "from Massif");
for( Object o : q.getResultList()) {
massifs.add( (Massif)o);
}
return massifs;
}
public Massif addMassif(String nom) {
Massif massif = new Massif();
massif.setNom( nom );
manager.persist( massif );
return massif;
}
}
My client look like this :
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.wiskee.bd.Massifs;
import org.wiskee.bd.Massif;
public class Client {
/**
* @param args
*/
public static void main(String[] args) {
try {
System.out.println( "CLIENT" );
Context context = new InitialContext();
Massifs massifs = (Massifs) context.lookup(Massifs.class.getName());
massifs.addMassif( "Pyrenees" );
for( Massif m : massifs.getAllMassif() ) {
System.out.println( m.getMassifId() + " : " + m.getNom() );
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}
I would like to know which library I have to put on my client build path ?
Is there something wrong with my EJB or my client ?
Thank you