Hi

is openejb-client in client classpath/classloader?

Side note the default ejb endpoint is http://localhost:8082/tomee/ejb
and not just /ejb
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-02 13:28 GMT+02:00 ttran <[email protected]>:
> Hello,
>
> I don't know if it's the right forum to ask my question here, so if it's
> not, please let me know.
> I am creating an small webapp to test ejb3 api and deployint it with tomee
> server.
>
> *Here is what i have in the ejb entity:*
> @Entity
> @Table(name = "PERSONNE")
>
> @NamedQueries({@NamedQuery(name = "Personne.findById",
>         query = "SELECT p FROM Personne p WHERE p.id = :id"),
> @NamedQuery(name = "Personne.findByNom",
>         query = "SELECT p FROM Personne p WHERE p.nom = :nom"),
> @NamedQuery(name = "Personne.findByPrenom",
>         query = "SELECT p FROM Personne p WHERE p.prenom = :prenom")})
>
> public class Personne implements Serializable {
> private static final long serialVersionUID = 1L;
> @Id
> @Column(name = "ID", nullable = false)
> private Integer id;
>
> @Column(name = "NOM")
> private String nom;
>
> @Column(name = "PRENOM")
> private String prenom;
> // getters and setters
> ...
> }
>
> *Then the interface:*
> @Remote
> public interface PersonneFacadeRemote {
>
>         void create(Personne personne);
>         void edit(Personne personne);
>         void remove(Personne personne);
> }
>
> *and the implementation of the interface:*
>
> @Stateless
> public class PersonneFacadeImpl implements PersonneFacadeLocal,
> PersonneFacadeRemote {
>
>
>         @PersistenceContext
>         private EntityManager em;
>
>         public void create(Personne personne) {
>                 em.persist(personne);
>         }
>
>         public void edit(Personne personne) {
>                 em.merge(personne);
>         }
>
>         public void remove(Personne personne) {
>                 em.remove(em.merge(personne));
>         }
> }
>
> *the META-INF/persistence.xml:*
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
>   <persistence-unit name="Ejb3">
>         <jta-data-source>java:/OracleDS</jta-data-source>
>   </persistence-unit>
> </persistence>
>
> *Datasource configured in the tomee.xml*
>   <Resource id="OraDS" type="DataSource">
>     JdbcDriver=oracle.jdbc.OracleDriver
>     JdbcUrl=jdbc:oracle:thin:@localhost:1521:XE
>     UserName=xeuser
>     Password=xeuse
> </Resource>
>
> *And finally, the test client:*
> public class Main {
>
>         public static void main(String[] args) {
>                 // TODO Auto-generated method stub
>
>         try {
>
>                 Personne personne = new Personne();
>                 personne.setId(1);
>                 personne.setNom("test");
>                 personne.setPrenom("Personne facade remote");
>
>             Properties p = new Properties();
>             p.setProperty("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
>             p.setProperty("java.naming.provider.url",
> "http://localhost:8082/ejb";);
>             InitialContext ic = new InitialContext(p);
>
>             PersonneFacadeRemote pfl = (PersonneFacadeRemote)
> ic.lookup("java:comp/env/PersonneFacadeRemote");
>             pfl.create(personne);
>             System.out.println("Creer une nouvelle personne avec l'interface
> remote");
>         } catch (NamingException ex) {
>             ex.printStackTrace();
>         }
> }
>
> When i debug this test client, i get this error below at *InitialContext ic
> = new InitialContext(p);
>
> NoInitialContextException  (id=28)      Cannot instantiate class:
> org.apache.openejb.client.RemoteInitialContextFactory
>
> all remainingName, resolvedName and resolvedObject are null.*
>
> So, i'd like to know if someone here has succeeded to resolve this problem ?
> Thanks for help!
>
>
>
>
> --
> View this message in context: 
> http://openejb.979440.n4.nabble.com/Problem-to-create-initialContext-tp4668512.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Reply via email to