aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes On running a stand alone client there is no output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "On running a stand alone client there is no output " Watch "On running a stand alone client there is no output " New topic
Author

On running a stand alone client there is no output

Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
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:


Ken Sampson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On running a stand alone client there is no output
 
Similar Threads
How to resolve NoInitialContextException?
Problem witth NoInitialContextException
Head First EJB Chapter 1 : Advice Application Problem, Please Help
AdviceClient again!!
running EJB gives exception in 'main' of Client