JBoss AS7(EJB 3.1) + Hibernate
aboutajedyne_ayoub Sep 24, 2013 2:41 AMHello,
I got always this error when i use jBoss client to access to an Stateless EJB deployed(war archive) by an another eclipse project.
Here is the output:
sept. 24, 2013 7:11:19 AM org.xnio.Xnio <clinit> INFO: XNIO Version 3.0.3.GA sept. 24, 2013 7:11:19 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.0.3.GA sept. 24, 2013 7:11:19 AM org.jboss.remoting3.EndpointImpl <clinit> INFO: JBoss Remoting version 3.2.3.GA Looking EJB via JNDI ejb:/EJB_Hibernate_Test1//BookEjb!BookEjbRemote javax.naming.NamingException: Could not load ejb proxy class BookEjbRemote [Root exception is java.lang.ClassNotFoundException: BookEjbRemote] at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:108) at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:96) at javax.naming.InitialContext.lookup(Unknown Source) at org.java.main.Main.main(Main.java:53) Caused by: java.lang.ClassNotFoundException: BookEjbRemote at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:106) ... 3 more sept. 24, 2013 7:11:19 AM org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver handleEnd ERROR: Channel end notification received, closing channel Channel ID a4c09345 (outbound) of Remoting connection 00906563 to null
and this is the structure of my client app project:
finally the Main class looks like:
package org.java.main; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.jee.beans.Book; import org.jee.businesslayer.BookEjbRemote; public class Main { public static void main(String[] args) { final Hashtable<String, String> jndiProperties = new Hashtable<String, String>(); jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory"); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); jndiProperties.put(Context.PROVIDER_URL,"remote://localhost:4447"); jndiProperties.put(Context.SECURITY_PRINCIPAL, "aboutajedyne"); jndiProperties.put(Context.SECURITY_CREDENTIALS, "javaisperfect"); try { final Context context = new InitialContext(jndiProperties); final String appName = ""; final String moduleName = "EJB_Hibernate_Test1"; final String distinctName = ""; final String beanName = "BookEjb"; final String viewClassName = "BookEjbRemote"; BookEjbRemote ejb = (BookEjbRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName); Book book = new Book("livre_java_2", 800); ejb.createBook(book); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
The interface BookEjbRemote:
package org.jee.businesslayer; import javax.ejb.Remote; import org.jee.beans.Book; @Remote public interface BookEjbRemote { public Book createBook(Book book); }
The Ejb Implementation(in another eclipse project [Server-side]):
package org.jee.businesslayer; import javax.ejb.Stateless; import javax.persistence.PersistenceContext; import org.hibernate.Session; import org.jee.beans.Book; @Stateless public class BookEjb implements BookEjbRemote{ @PersistenceContext(unitName="mySession") private Session session; @Override public Book createBook(Book book) { System.out.println(""); System.out.println("The EntityManager is: " + session); System.out.println("Book: " + book); session.persist(book); return book; } }
(NOTE: Know only that in server-side it works perfectly but not when i want to use it in another JVM...)
Please i need help...