• Post Reply Bookmark Topic Watch Topic
  • New Topic

not able to execute the ejb plz help!  RSS feed

 
gaurav singhal
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am a newbee to EJB and strugling to get started with EJB 3.0. As I am not able to run my client in Sun one.

I have followed the following steps to write my first ejb:

1) I have written the business interface,bean class and client.
2) Packaged them using jar -cvf command into a jar file
3) Deploy it by pasting them into deploy directory.
4) Now when i try to execute the client i am getting the following error.


C:\Documents and Settings\singhag>java -classpath C:\Sun\SDK\domains\domain1\autodeploy\test.jar Client.HelloClient
about to create initialcontext
Exception Occuredjavax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterp
rise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundE
xception: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client.HelloClient.main(HelloClient.java:16)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialIni
tContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more

I will appreciate any help in this regard, is there anything I am doing wrong,and the above steps are correct or not. Is it mandatory to use the Ant for packaging and building the ejb.

Thanks
Gaurav
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are not pointing to JNDI server which provided by your application server to access the bean.

Post Client Code to get better suggestion.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory


The jar containing the above class is not present in the client's classpath. Make sure you place that jar in the classpath

Is it mandatory to use the Ant for packaging and building the ejb.


No, its not mandatory.
 
gaurav singhal
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response. I am posting my client code.

Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory


Can you please suggest me which jar file to add in the classpath as I already have javaee.jar in my path. To find SerialInitCotextFactory class.

 
gaurav singhal
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After this post i tried and surfed in google what i can i find is

env.put("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");

i have to use for sun one server
env.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");

But still I am not able to make out what shoul i use for

[B]env.put("java.naming.provider.url", " ");


because without this line it is giving me the following error [/B]
F:\>java -classpath C:\Sun\SDK\domains\domain1\autodeploy\test.jar Client.HelloC
lient
about to create initialcontext
Dec 11, 2006 5:43:01 PM com.sun.corba.se.impl.transport.SocketOrChannelConnectio
nImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR
_TEXT; hostname: 10.114.2.64; port: 900"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
nknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
nknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.create
Connection(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.begin
Request(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknow
n Source)
at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(Unknown S
ource)
at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown
Source)
at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.<init>(Unknown Source)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(Unknown Source)

at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client.HelloClient.main(HelloClient.java:24)
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at java.nio.channels.SocketChannel.open(Unknown Source)
at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket
(Unknown Source)
... 20 more
Exception Occuredjavax.naming.CommunicationException: Cannot connect to ORB [Roo
t exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 comple
ted: No]
javax.naming.CommunicationException: Cannot connect to ORB [Root exception is or
g.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No]
at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.<init>(Unknown Source)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(Unknown Source)

at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client.HelloClient.main(HelloClient.java:24)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed:
No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
nknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
nknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.create
Connection(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.begin
Request(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknow
n Source)
at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(Unknown S
ource)
at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown
Source)
at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown
Source)
... 9 more
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at java.nio.channels.SocketChannel.open(Unknown Source)
at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket
(Unknown Source)
... 20 more

Please suggest. I am using Sun one server and what is default java.naming.provider.url
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:



Not sure whether this is the default port for Sun One App server Naming service, but this is what i found in one of the google results
 
gaurav singhal
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jaikiran for your suggestion but it does not help. Though I gotrid of that errors still my Client is not getting properly executed, location now i am getting error at different

My client Code


I am gettin the following error

F:\practice>java -classpath . Client.HelloClient1
about to create initialcontext
Got initial context ... yeah
Got list...
Entry is ... SerialContextProvider -- com.sun.corba.se.impl.corba.CORBAObjectImp
l
Entry is ... pkg.Hello__3_x_Internal_RemoteBusinessHome__ -- com.sun.corba.se.im
pl.corba.CORBAObjectImpl
Entry is ... examples.session\.stateless\.Hello__3_x_Internal_RemoteBusinessHome
__ -- com.sun.corba.se.impl.corba.CORBAObjectImpl
Entry is ... ejb -- com.sun.jndi.cosnaming.CNCtx
I am Out
Exception in thread "main" javax.naming.NameNotFoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingCo
ntext/NotFound:1.0]
at com.sun.jndi.cosnaming.ExceptionMapper.mapException(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.callResolve(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.lookup(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at Client.HelloClient1.main(HelloClient1.java:54)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNamin
g/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(Unknown So
urce)
at org.omg.CosNaming._NamingContextExtStub.resolve(Unknown Source)
... 5 more


I am sorry for posting such a huge code....but I am not able to make it work.
 
Rashi Gulati
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
env.put("java.naming.provider.url", "iiop://localhost:3700");

Make sure 3700 is the RMI port.

let's assume your default page is CheckLogin

By this your URL will be http://localhost:3700/CheckLogin.hello

But as CheckLogin is in a "EAR" under some package suppose it is "Default" then

env.put("java.naming.provider.url", "iiop://localhost:3700/Default");

and hence the url will be http://localhost:3700/Default/CheckLogin.hello

Hope this will help

Regards
Rashi
 
gaurav singhal
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally phew after around 3 days of struggle I am able to run my client. By putting some jar files on my path. Thanks to everone who helped me in solving my problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!