Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

On running a stand alone client there is no output

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using j2sdk1.4 and j2sdkee RI 1.3. I have tried to develop the EJB code which is provided in Head First EJB in the first chapter. Everything happened accordingly till deployment. When I tried to run the client I received an exception.

For your reference I am posting the classes and the output below:

This is the Remote Interface:

package headfirst;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface Advice extends EJBObject
{
public String getAdvice()throws RemoteException;
}

This is the session bean:

package headfirst;

import javax.ejb.*;
public class AdviceBean implements SessionBean
{
private String[] adviceStrings = {"One word: inappropriate",
"You might want to rethink that haircut",
"You boss will respect you if you tell him what you really think of him",
"Visualize yourself with better clothes",
"Of course you dont have to go to work today",
"Do you really think you should be leaving the house like that",
"Read a book once a year, whether you need it or not."};

public void ejbActivate(){
}

public void ejbPassivate(){
}

public void ejbRemove(){
System.out.println("ejb remove");
}

public void setSessionContext(SessionContext ctx){
System.out.println("session context");
}

public String getAdvice(){
System.out.println("In get advice");
int random = (int)(Math.random() * adviceStrings.length);
System.out.println("In getAdvice method.....in the AdviceBean ");
return adviceStrings[random];
}

public void ejbCreate(){
System.out.println("ejb create");
}

}

This is the home interface:

package headfirst;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface AdviceHome extends EJBHome
{
public Advice create()throws CreateException, RemoteException;
}

and this is the client code:

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import headfirst.*;

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

public void go(){
try{
Context ic = new InitialContext();

System.out.println("******************************");
Object o = ic.lookup("Advisor");

System.out.println("object is " + o);

AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o, AdviceHome.class);

Advice advisor = home.create();
System.out.println(advisor.getAdvice());

}catch(Exception e){
e.getMessage();
//e.printStackTrace();
}
}
}

This is the output which I receive when run the client:

******************************
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/corba/se/inte
rnal/util/JDKBridge
at com.sun.corba.ee.internal.core.IOR$LocalCodeBaseSingletonHolder.<clin
it>(IOR.java:90)
at com.sun.corba.ee.internal.core.IOR.<init>(IOR.java:238)
at com.sun.corba.ee.internal.iiop.messages.LocateReplyMessage_1_2.read(L
ocateReplyMessage_1_2.java:137)
at com.sun.corba.ee.internal.iiop.IIOPInputStream.unmarshalHeader(IIOPIn
putStream.java:126)
at com.sun.corba.ee.internal.iiop.IIOPConnection.getResponse(IIOPConnect
ion.java:671)
at com.sun.corba.ee.internal.iiop.IIOPConnection.send(IIOPConnection.jav
a:778)
at com.sun.corba.ee.internal.corba.InitialNamingClient.locateObject(Init
ialNamingClient.java:786)
at com.sun.corba.ee.internal.corba.InitialNamingClient.getIORUsingHostIn
fo(InitialNamingClient.java:597)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveCorbaloc(I
nitialNamingClient.java:573)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveUsingORBIn
itRef(InitialNamingClient.java:544)
at com.sun.corba.ee.internal.corba.InitialNamingClient.cachedInitialRefe
rences(InitialNamingClient.java:1080)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolve_initial_r
eferences(InitialNamingClient.java:981)
at com.sun.corba.ee.internal.corba.ORB.resolve_initial_references(ORB.ja
va:2425)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
a:52)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120
)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(AdviceClient.java:19)
at AdviceClient.main(AdviceClient.java:11)

I have mentioned Advisor as the JNDI name for the Bean "AdviceBean" in the RI tool.

Please help me as how to fix this error:
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic