aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to find home Interface? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to find home Interface?" Watch "How to find home Interface?" New topic
Author

How to find home Interface?

Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
Im running the examples of Enterprise Java Beans from Monson-Haefel book in WebLogic 6.0 and I?m havin the error:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError: com.titan.cabin.CabinHome
java.lang.NoClassDefFoundError: com.titan.cabin.CabinHome
I was debuggin it and I discovered tha the error occurs right after I get a remote reference to the bean with
Object ref = ctx.lookup("java:comp/env/ejb/Cabin");
I got the reference but then when I try to do:
CabinHome home = (CabinHome)(javax.rmi.PortableRemoteObject.narrow(ref, CabinHome.class));
the error occurs.
Any help will be wellcome.
txs in advance.
Andrew Jahchand
Greenhorn

Joined: Jul 09, 2001
Posts: 7
I get something very similar on J2EE. Did you manage to solve the problem?
Originally posted by Marcos Maia:
Hi,
Im running the examples of Enterprise Java Beans from Monson-Haefel book in WebLogic 6.0 and I?m havin the error:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError: com.titan.cabin.CabinHome
java.lang.NoClassDefFoundError: com.titan.cabin.CabinHome
I was debuggin it and I discovered tha the error occurs right after I get a remote reference to the bean with
Object ref = ctx.lookup("java:comp/env/ejb/Cabin");
I got the reference but then when I try to do:
CabinHome home = (CabinHome)(javax.rmi.PortableRemoteObject.narrow(ref, CabinHome.class));
the error occurs.
Any help will be wellcome.
txs in advance.

Suresh Ramu
Greenhorn

Joined: Jul 11, 2001
Posts: 5
hi guys,
It probably is as small as the incorrect home object name.
Try this syntax for getting the home object:
Object obj = (Object) ctx.lookup("Cabin"); //JNDI name
/***** Getting Home object ******/
CabinHome objCabinhome = (CabinHome) PortableRemoteObject.narrow((org.omg.CORBA.Object) obj, CabinHome.class);
Also, you may probably need to specify the the full class path for your home object.
[This message has been edited by Suresh Ramu (edited July 11, 2001).]
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Also, you may probably need to specify the the full class path for your home object.
You mean that I need to set the classpath in the startWebLogic.cmd for the Home interface to find it from another EJB?
Suresh Ramu
Greenhorn

Joined: Jul 11, 2001
Posts: 5
No. In the code for getting the home object(mention the full package name). This is just a possibility. I am considering this possiblity because in your code, the client is to able to create an initial context( meaning it can recognize the existance of the bean) but fails while trying to invoke the home object.
Hope this helps. Try this out.
Andrew Jahchand
Greenhorn

Joined: Jul 09, 2001
Posts: 7
Hi,
I was wondering do I need additional software for jndi. I have jdk1.2.2 and j2sdkee1.2.1.
I don't seem to get any deployment problems and everything compiles... but I do get the following error when trying to run the client:
When trying to run my stateful session bean as a J2EE client I get the following error:
Initiating login ...
Looking up authenticator...
Binding name:`java:comp/env/ejb/FibonacciSeQuence`
Application threw an exception:java.lang.NoClassDefFoundError: FibonacciHome
Unbinding name:`java:comp/env/ejb/FibonacciSeQuence
I get a similar error when trying to use servlets and ejbs:
java.lang.NoSuchMethodError: javax.servlet.ServletRequest: method isSecure()Z not found
at
at com.sun.web.security.SecurityInterceptor.preInvoke(SecurityInterceptor.java:83)
at org.apache.tomcat.core.ServiceInvocationHandler.preInvoke(ServletWrapper.java:615)
at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:531)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
at org.apache.tomcat.core.Context.handleRequest(Context.java:644)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:310)
at java.lang.Thread.run(Thread.java:479)
I don't get any problems when I use a standalone client
Also may be I should mention that I am using windows 98
Thanks for your help
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Here it�s a piece of my code
CabinHome home;
//Properties p = new Properties();
//p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//javax.naming.Context ctx = new InitialContext(p);
javax.naming.Context ctx = new InitialContext();
System.out.println("tentando recuperar ref � CabinHome");// prints this line
Object ref = (CabinHome)ctx.lookup("Cabin");
//Object ref = ctx.lookup("java:comp/env/ejb/Cabin");
System.out.println("recuperei referencia " + ref.getClass().toString());// this line prints: recuperei referencia class com.titan.cabin.CabinEJBHomeImpl_WLStub
home = (CabinHome)(javax.rmi.PortableRemoteObject.narrow(ref, CabinHome.class));
System.out.println("recuperei CabinHome");// this line doesn�t print
I�ve tryied a lot of things and still doesn�t work
any Ideas will be wellcome.
txs in advance.
[This message has been edited by Marcos Maia (edited July 11, 2001).]
Andrew Jahchand
Greenhorn

Joined: Jul 09, 2001
Posts: 7
Just a thought...(probably a stupid one)
but have you checked to see if the server is running at 100%
I can deploy etc see earlier messages but I have noticed that when I try to get the index page of the server (i.e http://localhost:8000)I get a servlet error regardless
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
I�ve found something about it in the WL documentation
Here it goes:
Diagnosing ClassNotFoundException Errors
A less common problem when deploying and using EJBs is the ClassNotFoundException. ClassNotFoundExceptions occur when a given class cannot be loaded by a given classloader or any of its parent classloaders. Because WebLogic Server uses a hierarchy of classloaders, diagnosing ClassnotFoundExceptions can sometimes be difficult. The following describes a potential class loading problem:

An EJB provider uses a support class, "Class1," in an EJB implementation class. Upon deployment, the EJB classloader loads and maintains the EJB implementation class, which references "Class1." "Class1" is not exported to the WebLogic classloader, because it is not used in any of the EJB's public interfaces.
A second EJB (or servlet) accesses the newly-deployed EJB and attempts to create an instance of class "Class1."
The classloader for the second EJB (or servlet) attempts to find "Class1" in its local cache. If it cannot find "Class1," the parent classloader (the WebLogic classloader) attempts to find the class. Because "Class1" was not exported at deployment time, the next parent classloader (the system classloader) attempts to find the class.
If "Class1" cannot be loaded using any of the classloaders in this hierarchy, the client receives a ClassNotFoundException. This error occurs even though "Class1" resides in the EJBs classloader.
To avoid class loading problems, always ensure that all support classes that must be available to internal clients of the EJB are referenced in the EJB's public interfaces, or are themselves implemented as Java interfaces. Doing so ensures that the EJB's classloader exports the required classes to the WebLogic classloader, where they are publicly available to WebLogic Server clients.
Classloading between WebLogic Servers
WebLogic Server cannot load classes "over the network" for RMI objects that reside on a remote WebLogic Server system. If an EJB or servlet on one, WebLogic Server acts as a client to another EJB or RMI object on a second server, you must ensure that the stub classes for the remote EJB or RMI object reside in the local server's CLASSPATH.
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Ok, I�ve tryied everything and nothing. Than I set the classpath to point to my Cabin.jar in the startWebLogic.cmd and I�t worked.
I�m crazy about it cause I think tha this is not the right way to do it.
Still waiting for some explanation.
Txs a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find home Interface?
 
Similar Threads
Problem while running the client
inconvertible types attempting to cast ejb JNDI lookup to home interface
Can�t find home interface
Can�t find Home Interface.
running Richard Monson-Haefel book example