[jboss-user] [EJB 3.0] - (debian, eclipse) javax.naming.NameNotFoundException: Custome

lolveley do-not-reply at jboss.com
Mon Mar 2 10:43:26 EST 2009


hello,

I can"t access to a EJB via JNDI.
here is the stuff I use : eclipse ganymède JEE, JBOSS 4.2.2 (modified to be used with MySQL).
I have created an EAR project (enterprise application project), names petstore_ear, which contains several projects: an EJB project which contains many EJBs, a JPA project which contains manu entities, and a java project which contains a java class with a main class (it is the client class).

when I launch firefox with the address "localhost:8080" and I select the jndi view, I see that the project is well deployed : 

anonymous wrote : Global JNDI Namespace
  | 
  |   +- petstore_ear (class: org.jnp.interfaces.NamingContext)
  |   |   +- CustomerBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- local (proxy: $Proxy109 implements interface ejb.customer.CustomerLocal,interface org.jboss.ejb3.JBossProxy)
  |   |   |   +- remote (proxy: $Proxy108 implements interface ejb.customer.CustomerRemote,interface org.jboss.ejb3.JBossProxy)
  |   |   +- OrderSB (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- local (proxy: $Proxy113 implements interface ejb.order.OrderLocal,interface org.jboss.ejb3.JBossProxy)
  |   |   |   +- remote (proxy: $Proxy112 implements interface ejb.order.OrderRemote,interface org.jboss.ejb3.JBossProxy)
  |   |   +- CatalogSB (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- local (proxy: $Proxy105 implements interface ejb.catalog.CatalogLocal,interface org.jboss.ejb3.JBossProxy)
  |   |   |   +- remote (proxy: $Proxy104 implements interface ejb.catalog.CatalogRemote,interface org.jboss.ejb3.JBossProxy)
  | 

but when I try to access to in within the following java class I have the error:"javax.naming.NameNotFoundException: CustomerBean not bound".

client:

  | public static void main(String[] args) {
  | 		
  | 		try {
  | 			Context ctx=new InitialContext();			
  | 			
  | 			ejb.customer.CustomerRemote rem=(ejb.customer.CustomerRemote) ctx.lookup("CustomerBean/remote");
  | 			rem.createCustomer(new Customer(1L,"jambon","rose","jean","bonrause","0018654118","jeanroi at gmail.com",new java.util.Date(1978,02,10),19,null),new source.Address(1,"4 rue des roses","","METZ","Moselle","57000","FRANCE"));
  | 			
  | 			
  | 			System.out.println ("--- Hello, clients ---");
  | 			for (source.customer.Customer client : rem.findCustomers()) {
  | 				System.out.println ("client : "+client);
  | 			}
  | 
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  | 	}

I use a jndi.properties file to configure JNDI : 

  | java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
  | java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
  | java.naming.provider.url=jnp://localhost:1099
  | jnp.disableDiscovery=true 

here is the ejb-jar.xml file in the EJB project:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
  |   <display-name> 
  | petstore_ejb </display-name>
  |   <ejb-client-jar>petstore_ejbClient.jar</ejb-client-jar>
  | </ejb-jar>

and I added a persistence.xml file always in the META-INF directory of my EJB project:

  | <persistence>
  | 	<persistence-unit name="petstorePU">
  | 		<jta-data-source>java:/MySqlDS</jta-data-source>
  | 		<properties>
  | 			<property name="hibernate.hbm2ddl.auto" value="update"/>
  | 			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
  |       		<property name="hibernate.show_sql" value="true"/>
  | 			<property name="hibernate.connection.password" value="petstorepwd"/>
  | 			<property name="hibernate.connection.username" value="petstorelg"/> 
  | 		</properties>
  | 	</persistence-unit>
  | </persistence>
  | 

if you want some other stuff, tell me it.

olivier.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214219#4214219

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214219




More information about the jboss-user mailing list