File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes how to run the AdviceClient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to run the AdviceClient" Watch "how to run the AdviceClient" New topic
Author

how to run the AdviceClient

alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi Guys,

I have successfully created a bean and deployed it in J2EE server. My next step according to the head first ejb is to create a client. I compiled AdviceClient successfully (Thanks to Vijitha). However when I try to run the compiled class I get the following error:



C:\projects\advice>java AdviceClient
javax.naming.CommunicationException: Can't find SerialContextProvider
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
a:63)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120
)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at AdviceClient.go(AdviceClient.java:16)
at AdviceClient.main(AdviceClient.java:10)



Could you please tell me what is going on?

The following is the class AdviceClient:

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

public class AdviceClient{

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

Context ic=new InitialContext();
Object o=ic.lookup("Advisor");

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

Advice advisor=home.create();
System.out.println(advisor.getAdvice());
}catch (Exception ex){
ex.printStackTrace();
}
}
}

Kind regards
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Do you have the ApplicationClient.jar returned by the J2EE server in the classpath? (and of course j2ee.jar etc..) What is the J2EE server you are using? Provide some information to come up with an idea.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
I use j2sdkee1.3.1. The followings are my classpath and path. I put AdviceAppClient.jar and j2ee.jar in the classpath manually.

CLASSPATH= .;C:\jdk1.3.0_02\bin;C:\j2sdkee1.3.1\bin;C:\jboss-4.2.2.GA\jboss-4.2.2.GA\bin;C:\j2sdkee1.3.1\lib\j2ee.jar;C:\j2sdkee1.3.1\lib\locale;C:\projects\advice\AdviceAppClient.jar

PATH= C:\jdk1.3.0_02\bin;C:\j2sdkee1.3.1\bin;C:\j2sdkee1.3.1\doc\api\javax;

Many thanks,

Al
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi Guys,

I have found an answer to my problem. However I do not have a clear understanding as to what I need to do. The following is the advice:

javax.naming.CommunicationException: Can't find SerialContextProvider

This exception usually means the JNDI Server is not running, or possibly the JNDI properties for the server are incorrect.
javax.naming.NoInitialContextException:

Need to specify class name in environment or system property,
or as an applet parameter,
or in an application resource file:
java.naming.factory.initial



Could you please tell me what I need to do?

Kind regards,

Al
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

try the following code fragment when initialzing the Context.



iiop port and the com.sun.jndi.cosnaming.CNCtxFactory class may vary depending your J2EE Server.
Regards,
[ July 22, 2008: Message edited by: Vijitha Kumara ]
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi Vijitha,

Do you mean placing the peice of code in your previous post in the AdviceClient.java after TRY and comiling and running it? if yes, I did it and it produces two error messages as followings:

C:\projects\advice>javac AdviceClient.java
AdviceClient.java:15: cannot resolve symbol
symbol : class Properties
location: class AdviceClient
Properties env = new Properties();
^
AdviceClient.java:15: cannot resolve symbol
symbol : class Properties
location: class AdviceClient
Properties env = new Properties();
^
2 errors

I need to confess I am a begginer and that was my understanding. Could you please advice me as to what is wrong that I am doing?

Kind regards,

Al
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
@
import java.util.*;

add proper jndi name for your bean component,i am going through same problem,i didn't find how and where to enter jndi name in either deployment tool or in
application server
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Thank you so much for your reply.

I am still unable to get rid of the errors. To be honest I dont get what you meant.

Regards,

Al
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
this is the running version but it din't lookup into jndi

alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Thank you very much for your reply.

I have used the verified version, however I face the following errors:


C:\projects\advice>java AdviceClient
javax.naming.CommunicationException: Cannot connect to ORB. Root exception is o
rg.omg.CORBA.COMM_FAILURE: minor code: 1398079490 completed: No
at com.sun.corba.se.internal.iiop.IIOPConnection.writeLock(IIOPConnectio
n.java:919)
at com.sun.corba.se.internal.iiop.IIOPConnection.send(IIOPConnection.jav
a:980)
at com.sun.corba.se.internal.iiop.IIOPOutputStream.invoke(IIOPOutputStre
am.java:76)
at com.sun.corba.se.internal.iiop.ClientRequestImpl.invoke(ClientRequest
Impl.java:74)
at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.
java:152)
at com.sun.corba.se.internal.corba.InitialNamingClient.resolve(InitialNa
mingClient.java:200)
at com.sun.corba.se.internal.corba.InitialNamingClient.cachedInitialRefe
rences(InitialNamingClient.java:265)
at com.sun.corba.se.internal.corba.InitialNamingClient.resolve_initial_r
eferences(InitialNamingClient.java:188)
at com.sun.corba.se.internal.corba.ORB.resolve_initial_references(ORB.ja
va:1393)
at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:254)
at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:229)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:187)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:71)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.ja
va:35)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
68)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
at javax.naming.InitialContext.init(InitialContext.java:222)


What do you think the problem is?

Kind regards,

Al
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
@

have you set for AdviceBean the jndi name in the deployment tool you are using
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Im so sorry I do not know how to do it. Can you give me some instructions plese?

Regards,

Al
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
@
go to deployment descriptor, and click the Advicebean icon and click sun specification under that add your jndi names
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Did you set the iiop port correctly? (That may be one of the reasons) And When you are deploying the bean it ask you for a JNDI name (I think in J2EE RI 1.3), But if you are using SJSAS you have to do that in one of those tabs(can't remember what exactly,probably in the sun-specific-settings configuration in the deployment tool) after you have create the bean (before you actually deploy it).

Regards,
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi,

I went to deployment tool GUI. The JNDI name for my bean is advisor which I entered when deploying before. But the problem still remains.

Regards,

Al
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Originally posted by Vijitha Kumara:
Did you set the iiop port correctly? (That may be one of the reasons) And When you are deploying the bean it ask you for a JNDI name (I think in J2EE RI 1.3), But if you are using SJSAS you have to do that in one of those tabs(can't remember what exactly,probably in the sun-specific-settings configuration in the deployment tool) after you have create the bean (before you actually deploy it).

Regards,


I set the bean JNDI name to advisor according to head first EJB. I do not know how to set the iiop port. Could you please give me some instruction?

Kind regards,

Al
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi,

When running client, in my previous attempts, the j2ee server was not running. However when I run the server the following error messages appear:


C:\projects\advice>java AdviceClient
javax.naming.CommunicationException: java.rmi.MarshalException: CORBA MARSHAL 13
98079699 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Custom marshaling of RMI:java.lang.Throwable:F8678B4F4D2EB705 5C635273977B8CB not
compatible with local class (local class not custom marshal capable) minor code
: 1398079699 completed: Maybe
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Custom mars
haling of RMI:java.lang.Throwable:F8678B4F4D2EB705 5C635273977B8CB not compatible with local class (local class not custom marshal capable) minor code: 139807
9699 completed: Maybe
at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInput
Stream_1_0.java:1083)
at com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStre
am.java:296)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lo
okup(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120
)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at AdviceClient.go(AdviceClient.java:16)
at AdviceClient.main(AdviceClient.java:10)

at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:138
)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at AdviceClient.go(AdviceClient.java:16)
at AdviceClient.main(AdviceClient.java:10)


I appreciate any attempts to solve this problem.

Kind regards,


Al
alex mueer
Greenhorn

Joined: Jul 17, 2008
Posts: 15
Hi Guys,

I managed eventually and that is a big relief.

The problem? Well, A combination of a bug, my silliness :roll: and a wrong version of software.

I chose j2sdk1.4.1_06 and j2sdkee1.3.1. To your horror, I did not let the server run while running the client ( I know you say: �how stupid!�) That is why I got wrong error messages. At last, I noticed there is a bug in RI implementation according to �Jayant Kulkarni�. (http://www.coderanch.com/t/158675/java-EJB-SCBCD/certification/HeadFirst-EJB-java-rmi-RemoteException)

A complete explanation of the bug can be found at http://www.wickedlysmart.com/HeadFirst/HeadFirstEJB/HeadFirstEJBNotes.html.

I would like to thank you who spend some of your valuable time to advice guys like me.

Best regards,

Al
 
wood burning stoves
 
subject: how to run the AdviceClient