• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to run the AdviceClient

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
alex mueer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the running version but it din't lookup into jndi

 
alex mueer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@

have you set for AdviceBean the jndi name in the deployment tool you are using
 
alex mueer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@
go to deployment descriptor, and click the Advicebean icon and click sun specification under that add your jndi names
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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�. (https://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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic