savita_gomatam
asked on
Getting exception while runningthe client program. Root exception is javax.naming.NameNotFoundException...
Hi,
I deployed a simple ejb application on to the weblogic server but when I run the client program, I am getting the following error
before lookup
Exception in thread "main" javax.naming.NameNotFoundE xception: Unable to resolve
'HelloHome'. Resolved '' [Root exception is javax.naming.NameNotFoundE xception:
Unable to resolve 'HelloHome'. Resolved '']; remaining name 'HelloHome'
at weblogic.rjvm.ResponseImpl .unmarshal Return(Res ponseImpl. java:191)
at weblogic.rmi.cluster.Clust erableRemo teRef.invo ke(Cluster ableRemote Ref
.java:315)
at weblogic.rmi.cluster.Clust erableRemo teRef.invo ke(Cluster ableRemote Ref
.java:250)
at weblogic.jndi.internal.Ser verNamingN ode_910_WL Stub.looku p(Unknown Sou
rce)
at weblogic.jndi.internal.WLC ontextImpl .lookup(WL ContextImp l.java:374 )
at weblogic.jndi.internal.WLC ontextImpl .lookup(WL ContextImp l.java:362 )
at javax.naming.InitialContex t.lookup(U nknown Source)
at examples.HelloClient.main( HelloClien t.java:23)
Caused by: javax.naming.NameNotFoundE xception: Unable to resolve 'HelloHome'. Re
solved ''
at weblogic.jndi.internal.Bas icNamingNo de.newName NotFoundEx ception(Ba sic
NamingNode.java:1123)
at weblogic.jndi.internal.Bas icNamingNo de.lookupH ere(BasicN amingNode. jav
a:250)
at weblogic.jndi.internal.Ser verNamingN ode.lookup Here(Serve rNamingNod e.j
ava:171)
at weblogic.jndi.internal.Bas icNamingNo de.lookup( BasicNamin gNode.java :20
4)
at weblogic.jndi.internal.Roo tNamingNod e_WLSkel.i nvoke(Unkn own Source)
at weblogic.rmi.internal.Basi cServerRef .invoke(Ba sicServerR ef.java:51 7)
at weblogic.rmi.cluster.Clust erableServ erRef.invo ke(Cluster ableServer Ref
.java:224)
at weblogic.rmi.internal.Basi cServerRef $1.run(Bas icServerRe f.java:407 )
at weblogic.security.acl.inte rnal.Authe nticatedSu bject.doAs (Authentic ate
dSubject.java:363)
at weblogic.security.service. SecurityMa nager.runA s(Security Manager.ja va:
147)
at weblogic.rmi.internal.Basi cServerRef .handleReq uest(Basic ServerRef. jav
a:403)
at weblogic.rmi.internal.Basi cServerRef .access$30 0(BasicSer verRef.jav a:5
6)
at weblogic.rmi.internal.Basi cServerRef $BasicExec uteRequest .run(Basic Ser
verRef.java:934)
at weblogic.work.ExecuteThrea d.execute( ExecuteThr ead.java:2 07)
at weblogic.work.ExecuteThrea d.run(Exec uteThread. java:179)
-------------------------- ---------- ---------- ---------- -----
I am giving my client program HelloClient.java and deployment descriptors.
package examples;
import javax.naming.Context;
import javax.naming.InitialContex t;
import java.util.Properties;
public class HelloClient {
public static void main(String[] args) throws Exception {
//Properties prop = System.getProperties();
Properties prop = new Properties();
prop.put(Context.INITIAL_C ONTEXT_FAC TORY,"webl ogic.jndi. WLInitialC ontextFact ory");
prop.put(Context.PROVIDER_ URL,"t3:// localhost: 7001");
Context ctx = new InitialContext(prop);
System.out.println("before lookup");
Object obj = ctx.lookup("HelloHome");
System.out.println("after lookup");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteOb ject.narro w(obj, HelloHome.class);
Hello hello = home.create();
System.out.println(hello.h ello());
hello.remove();
}
}
-------------------------- ----
my xml files
ejb-jar.xml
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</ home>
<remote>examples.Hello</re mote>
<local-home>examples.Hello LocalHome< /local-hom e>
<local>examples.HelloLocal </local>
<ejb-class>examples.HelloB ean</ejb-c lass>
<session-type>Stateless</s ession-typ e>
<transaction-type>Containe r</transac tion-type>
</session>
</enterprise-beans>
</ejb-jar>
weblogic-ejb-jar.xml
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Hello</ejb-name>
<jndi-name>HelloHome</jndi -name>
</weblogic-enterprise-bean >
</weblogic-ejb-jar>
-------------------------- ---------- --
After compiling the java files, I created the jar file that includes xml files and classfiles. Then using weblogic.ejbc I created the jar file
which I deployed in the weblogic server. I used weblogic admin console to deploy.
Until this point there was no error but when I run the client, I get the above said error.
My ejb files structure is as follows
my directory/java files
/META-INF/ejb-jar.xml
/weblogic-ejb-jar.xml
/examples/class files
I am new to weblogic. I will be thankful if anybody can tell me where did I go wrong and help me out in solving the problem.
Thanks in Advance.
Regards
Savitha
I deployed a simple ejb application on to the weblogic server but when I run the client program, I am getting the following error
before lookup
Exception in thread "main" javax.naming.NameNotFoundE
'HelloHome'. Resolved '' [Root exception is javax.naming.NameNotFoundE
Unable to resolve 'HelloHome'. Resolved '']; remaining name 'HelloHome'
at weblogic.rjvm.ResponseImpl
at weblogic.rmi.cluster.Clust
.java:315)
at weblogic.rmi.cluster.Clust
.java:250)
at weblogic.jndi.internal.Ser
rce)
at weblogic.jndi.internal.WLC
at weblogic.jndi.internal.WLC
at javax.naming.InitialContex
at examples.HelloClient.main(
Caused by: javax.naming.NameNotFoundE
solved ''
at weblogic.jndi.internal.Bas
NamingNode.java:1123)
at weblogic.jndi.internal.Bas
a:250)
at weblogic.jndi.internal.Ser
ava:171)
at weblogic.jndi.internal.Bas
4)
at weblogic.jndi.internal.Roo
at weblogic.rmi.internal.Basi
at weblogic.rmi.cluster.Clust
.java:224)
at weblogic.rmi.internal.Basi
at weblogic.security.acl.inte
dSubject.java:363)
at weblogic.security.service.
147)
at weblogic.rmi.internal.Basi
a:403)
at weblogic.rmi.internal.Basi
6)
at weblogic.rmi.internal.Basi
verRef.java:934)
at weblogic.work.ExecuteThrea
at weblogic.work.ExecuteThrea
--------------------------
I am giving my client program HelloClient.java and deployment descriptors.
package examples;
import javax.naming.Context;
import javax.naming.InitialContex
import java.util.Properties;
public class HelloClient {
public static void main(String[] args) throws Exception {
//Properties prop = System.getProperties();
Properties prop = new Properties();
prop.put(Context.INITIAL_C
prop.put(Context.PROVIDER_
Context ctx = new InitialContext(prop);
System.out.println("before
Object obj = ctx.lookup("HelloHome");
System.out.println("after lookup");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteOb
Hello hello = home.create();
System.out.println(hello.h
hello.remove();
}
}
--------------------------
my xml files
ejb-jar.xml
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</
<remote>examples.Hello</re
<local-home>examples.Hello
<local>examples.HelloLocal
<ejb-class>examples.HelloB
<session-type>Stateless</s
<transaction-type>Containe
</session>
</enterprise-beans>
</ejb-jar>
weblogic-ejb-jar.xml
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Hello</ejb-name>
<jndi-name>HelloHome</jndi
</weblogic-enterprise-bean
</weblogic-ejb-jar>
--------------------------
After compiling the java files, I created the jar file that includes xml files and classfiles. Then using weblogic.ejbc I created the jar file
which I deployed in the weblogic server. I used weblogic admin console to deploy.
Until this point there was no error but when I run the client, I get the above said error.
My ejb files structure is as follows
my directory/java files
/META-INF/ejb-jar.xml
/weblogic-ejb-jar.xml
/examples/class files
I am new to weblogic. I will be thankful if anybody can tell me where did I go wrong and help me out in solving the problem.
Thanks in Advance.
Regards
Savitha
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the response.
Yes. It is deployed correctly. Now it is working. I didn't start the ejb in the weblogic server.