Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

JNDI name not found error!!

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hii guyz,

I've started preparing for SCBCD exam, n i'm facing problems at each step n that's makin the progress real slow. Somehow i managed to solve to the AdviceGuy problem. Now the next prob is when i'm making local interfaces for my bean class.

Here's the component interface:
package headfirst;
import javax.ejb.*;
public interface AdviceLocal extends EJBLocalObject{
public String getTheMessage();
}

The home Interface:

package headfirst;
import javax.ejb.*;

public interface AdviceHomeLocal extends EJBLocalHome{
public AdviceLocal create() throws CreateException;
}

The bean class
package headfirst;

import javax.ejb.*;

public class AdviceBeanLocal implements SessionBean{
private String[] adviceStrings = {"One word in appropriate.","You might want to rethink that haircut.","Your boss will repect you if you tell him what you really think of him.","Visualize yourself with better clothes.","Ofcourse you dont have to go to work today","Do you really think you should be leaving the hose like that?","Read a book, once a year whether you need to or not"};

public void ejbActivate(){
System.out.println("Ejb Activate");
}

public void ejbPassivate(){
System.out.println("Ejb Passivate");
}
public void ejbRemove(){
System.out.println("Ejb Remove");
}
public void setSessionContext(SessionContext ctx){
System.out.println("Session Context");
}

public String getTheMessage(){
System.out.println("In Get Advice");
int random = (int)(Math.random() * adviceStrings.length);
return adviceStrings[random];
}
public void ejbCreate(){
System.out.println("In Ejb Create");
}

}

and finally the Client :
import javax.naming.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClientLocal{
public static void main(String args[]){
new AdviceClientLocal().go();
}

public void go(){
Object ob = null;

try{
Context ic = new InitialContext();
ob = ic.lookup("local");
}
catch(NamingException nex){
nex.printStackTrace();
}

AdviceHomeLocal home = (AdviceHomeLocal) ob;
AdviceLocal advisor = null;

try{
advisor = home.create();
}
catch(CreateException ce){
ce.printStackTrace();
}

System.out.println(advisor.getTheMessage());
}
}

now when i deploy and run this code i'm getting this error

javax.naming.NameNotFoundException: local not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.
java:174)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.ja
va:146)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialCont
extProviderImpl.java:63)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProviderImpl_Tie
._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegat
e.java:355)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProces
sor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadP
ool.java:99)
Exception in thread "main" java.lang.NullPointerException
at AdviceClientLocal.go(AdviceClientLocal.java:25)
at AdviceClientLocal.main(AdviceClientLocal.java:7)






Please help somebody!!. i dont know y i'm gettin all these errors, n this is really frustatin me boz i've already worked a lot to get the AdviceGuy example running. And now when AdviceGuy didnt have any problems in looking up the JNDI name, how come this crop up with this application..


Plz,plz help me out somebody.

Thankz,
Puneet

SCJP 1.4 (95%)
 
Ranch Hand
Posts: 41
Java ME Spring Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm facing the same pbm.

Here's the trace. I'm using JBoss 4.0.

--------------------------------------------------------------------
10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Section: 7.10.5
Warning: The remote interface must extend the javax.ejb.EJBObject interface.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract String getAdvice() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract void remove() throws RemoveException, EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract boolean isIdentical(EJBLocalObject) throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract EJBLocalHome getEJBLocalHome() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract Object getPrimaryKey() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 ERROR [MainDeployer] Could not create deployment: file:/D:/App/jboss-4.0.3SP1/server/default/tmp/deploy/tmp47314HeadFirstEAR.ear-content
/headfirst-ejb.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:575)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

--------------------------------------------------------------------

Thanks

Sylvain
------------------------------
SCJP 1.4
SCWCD 1.3
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure that while deploying you are using JNDI name "local".
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sylvain, It looks like you are trying to deploye your local interface as remote interface. Make sure while deployign you are using correct fields to enter your interface names.

Hope it helps.

Originally posted by Sylvain Bouchard:
I'm facing the same pbm.

Here's the trace. I'm using JBoss 4.0.

--------------------------------------------------------------------
10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Section: 7.10.5
Warning: The remote interface must extend the javax.ejb.EJBObject interface.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract String getAdvice() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract void remove() throws RemoveException, EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract boolean isIdentical(EJBLocalObject) throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract EJBLocalHome getEJBLocalHome() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 WARN [verifier] EJB spec violation:
Bean : AdviceBeanLocal
Method : public abstract Object getPrimaryKey() throws EJBException
Section: 7.10.5
Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause.

10:32:09,203 ERROR [MainDeployer] Could not create deployment: file:/D:/App/jboss-4.0.3SP1/server/default/tmp/deploy/tmp47314HeadFirstEAR.ear-content
/headfirst-ejb.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:575)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

--------------------------------------------------------------------

Thanks

Sylvain
------------------------------
SCJP 1.4
SCWCD 1.3

 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Spring Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, Devender

You're absoltly right.
My mistake was in the ejb-jar.xml

I was using this configuration:

<session>
<ejb-name>AdviceBean</ejb-name>
<home>headfirst.AdviceHome</home>
<remote>headfirst.Advice</remote>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
</session>

Instead of:

<session>
<ejb-name>AdviceBean</ejb-name>
<local-home>headfirst.AdviceHome</local-home>
<local>headfirst.Advice</local>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
</session>

You must do the same in the web.xml and in the jboss-web.xml.
<ejb-local-ref>

I'm reading HFEJB, and there's not mention of this subtle change
in the bean's configuration xml file. Maybe it's explain later in the book.

---------------------------------------------------------------------------
After all these change, everything deployed, but I get a
"javax.naming.NameNotFoundException: AdviceBeanLocal not bound".

Did I miss something?



Thanks a lot

Sylvain
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've already crosschecked that the JNDI name is "local", and i'm makin local interfaces for my bean class. Can anybody tell me or give an idea of wat could b the potential problem in this case.
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried Puneet's code and I am getting the same error. Could it be a RI bug?
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankz Devender for tryin this code, but that's exactly my question wat could b the potential error here. i think if v r preparing for a certification, v cant afford to leave everything that vague. so lets work together n find it out wat is the error here.

Plzz help us!!

Puneet
SCJP 1.4
 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Spring Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Puneet,

On which server you're trying to run your code?


Sylvain
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it on SUN's j2EE RI. Used their deploytool to deploy and generate configuration files.
Sylvain, It's the same problem you have reported in Jboss too. Can you try to use Puneet's code. We must be doing something wrong, if the same error happens in Jboss.
[ December 08, 2005: Message edited by: Devender Thareja ]
 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Spring Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Finally, I've tried your code and i got the same pbm as you.
But, I wrote a servlet client, deployed in the same application.
And everthing works well.

After reading a lot, and asking question. I think it's the correct
result.

[B}Possible explanation[\B]:
The local EJB use to run on the same JVM as the client.
Servlet deploy on the same app, run under the same JVM as the EJB.
The local client run under a different JVM. Maybe that explain that
the context lookup didn't find the component.

This is my personal point of view, maybe I'm wrong.

Sylvain
 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii Sylvain,

I agree wid you on this, infact when i got the problem, this is the first thought that came to my mind. Maybe that the context lookup didn't find the component. But then how far are we right about this. Somehow we need to find wats the exact problem. May b wat we may be thinking is just right. In that also v need to know wat to use with a local client instead of lookup.

Thankz,
Puneet
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It makes sense to me. I think Sylvain got it right. Thanks.
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Puneet

Well I have also tried it using RI and this time I ensured the following

1. Made sure that my lookup name is the same as the JNDI name I gave during deploytime.

2. Ensured that my client is running in the same JVM as the local bean.

But still I am not able to get rid of NameNotFoundException while dealing with Local interface. Are you able to come across any solution ?

I have also posted the same question on other forum. Some of them have replied to my questions. You can refer to the following thread for more details that I have tried.

http://www.theserverside.com/tss?service=direct/0/PostDiscussionReply/postReply&sp=l39614&sp=F&sp=l204851

Can you please help me ?

Waiting for your reply

Thanks and Regards
Rohit.
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic