This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

NameNotfoundexception

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple problem which has kept me completely flustered
A very simple Helloworld EJB gives me NameNotFoundException on deployment to WL10.x.

THere are no errors on deployment;but a standalone client simply cant find it.
Also,shouldnt the jndi appear somewhere under the JNDI tree - it doesnt in this case.

Any help will be much appreciated - just cant figure what is wron?


Remote:
======
package com.webservice;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Hello extends EJBObject {
public String hello(String message) throws RemoteException;
}

Home:
======
package com.webservice;
public interface HelloHome extends javax.ejb.EJBHome
{
Hello create() throws java.rmi.RemoteException,javax.ejb.CreateException;
}

Bean:
=====
package com.webservice;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public class HelloBean implements javax.ejb.SessionBean{
private javax.ejb.SessionContext ctx;
public void ejbCreate()
{
System.out.println("Inside ejbCreate");
}
public void ejbRemove()
{
System.out.println("Inside ejbRemove");
}
public void ejbActivate()
{
System.out.println("Inside ejbActivate");
}
public void ejbPassivate()
{
System.out.println("Inside ejbPassivate");
}
public String hello(String message)
{
System.out.println("The message received : " + message);
return "Responding Back";
}
public void setSessionContext(javax.ejb.SessionContext ctx)
{
this.ctx=ctx;
}
}

ejb-jar
======

<?xml version="1.0"?>
<!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>com.webservice.HelloHome</home>
<remote>com.webservice.Hello</remote>
<ejb-class>com.webservice.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

weblogic-ejb-jar
==========
<?xml version="1.0"?>

<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN"
"http://www.bea.com/servers/wls810/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>


Client
========
package com.webservice.client;
.....
.....import com.webservice.HelloHome;
import com.webservice.Hello;


public class HelloClient{

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


Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
env.put(Context.SECURITY_PRINCIPAL,"weblogic");
env.put(Context.SECURITY_CREDENTIALS,"weblogic");
Context ctx=new InitialContext(env);
Object obj=ctx.lookup("HelloHome");
HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello=home.create();
System.out.println(hello.hello("EJB is fun"));
hello.remove();

}

}
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!