• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB Client code Error : NameNotFoundException

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I am very much new to EJB and this is my first application.
I am using weblogic server 7 . I have deploied the EJB on the server, and now for the client code I am getting the error as :


javax.naming.NameNotFoundException: Unable to resolve 'com.ejb.examples.HelloHome' Resolved: '' Un
resolved:'com' ; remaining name 'com.ejb.examples.HelloHome'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:263)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:230)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
at javax.naming.InitialContext.lookup(InitialContext.java:345)
at com.ejb.examples.HelloClient.main(HelloClient.java:44)


My client code is as below :

----------------------------------------------------------------------------------------
package com.ejb.examples;

import com.ejb.examples.*;
import java.rmi.Remote;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.*;
import java.util.Properties;

/***
* This class is an example of client code that invokes method on a simple stateless session bean.
*/

public class HelloClient
{
public static void main(String[] args) throws Exception
{


try
{
/**
* Setup properties for JNDI initialization.
*/

Properties props = System.getProperties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL,"t3://localhost:7001");

/**
* Obtain JNDI initial context.
*/

System.out.println("1");
Context ctx = new InitialContext(props);
System.out.println("2");

/**
* Get a reference to home object
*/

HelloHome obj = (HelloHome) ctx.lookup("com.ejb.examples.HelloHome");
System.out.println("3");



/**
* Home objects are RMI-IIOP objects and so they must be cast into RMI-IIOP objects.
*/

HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(obj, com.ejb.examples.HelloHome.class);

/**
* Use factory to create hello EJB Object.
*/

Hello hello = home.create();

/**
* Call the hello() method.
*/

System.out.println(hello.hello());

hello.remove();
}
catch(Exception e)
{
e.printStackTrace();
}

}
};

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


If possible please help me as early as possible.
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What IDE are you using? There should be some place where you specify the JNDI bindings for your bean. In this, you have to provide the JNDI name for your EJB.
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
I am using the weblogic-jar.xml file having code as below:
------------------------------
<?xml version="1.0"?>
<!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>
<reference-descriptor>
<resource-description>
<res-ref-name>com/ejb/examples</res-ref-name>
<jndi-name>HelloHome</jndi-name>
</resource-description>
</reference-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
-------------
Is this correct method?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
means that you should doinstead of
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Lasse Koskela
you are absolutely right.
Its working with that name.
Thanks for your reply.

But now I have one more problem:
If I undeply any ejb object and then shutdown the server and after restarting the server I am seeing the same ejb object which I had undeploy previously as it is. Is there any way to deploy it completely. or server stores its reference somewhere?
 
Men call me Jim. Women look past me to this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic