wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes EJB problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB problem" Watch "EJB problem" New topic
Author

EJB problem

Marcin Matys
Greenhorn

Joined: Nov 06, 2005
Posts: 2
Hi everyone

I was reding this forum in order to solve my problem, but with no result.

Mayby someone will help me.

I try to do exercise from first hapter from Head First EJB but i have some problems.

I use J2EE 1.4 as a server, not J2EE 1.3 like book advice. (mayby this is the problem)

I compile my client class like this

E:\nauka\J2EE\EJB\projekty\doradca>javac -classpath c:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\lib\appserv-rt.jar;DoradcaAplkClient.jar DoradcaKlient.java


When I call my client application like this:


E:\nauka\J2EE\EJB\projekty\doradca>java -cp c:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\lib\appserv-rt.jar;DoradcaAplkClient.jar;. DoradcaKlient

i see:


2005-11-06 21:41:47 com.sun.corba.ee.spi.logging.LogWrapperBase doLog
INFO: "IOP00710299: (INTERNAL) Successfully created IIOP listener on the specifi
ed host/port: all interfaces/2420"
javax.naming.NameNotFoundException: Doradca not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.
java:185)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.ja
va:157)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialCont
extProviderImpl.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(Reflecti
veTie.java:123)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
tchToServant(CorbaServerRequestDispatcherImpl.java:648)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
tch(CorbaServerRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
Request(CorbaMessageMediatorImpl.java:1709)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
(CorbaMessageMediatorImpl.java:1569)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(C
orbaMessageMediatorImpl.java:951)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.call
back(RequestMessage_1_2.java:181)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
(CorbaMessageMediatorImpl.java:721)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatc
h(SocketOrChannelConnectionImpl.java:469)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(
SocketOrChannelConnectionImpl.java:1258)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.
run(ThreadPoolImpl.java:409)


My client class:

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class DoradcaKlient {

public static void main(String[] args) {
new DoradcaKlient().doDziela();

}

public void doDziela(){

Context ic =null;
DoradcaHome ibaz = null;
Doradca doradca = null;
try{
ic = new InitialContext();
Object o = ic.lookup("Doradca");
ibaz = (DoradcaHome)PortableRemoteObject.narrow(o,DoradcaHome.class);
doradca = ibaz.create();
System.out.println(doradca.getPorada());


}catch(Exception ex){
ex.printStackTrace();
}
}

}


plis help me.

I am going to throw this book through the window
Veshnu Ramakrishnan
Ranch Hand

Joined: Sep 27, 2005
Posts: 44
Hi Marcin Matys
Dont get Tensed
The problem is ur initial context is not initialized properly. you need to send the initialContextFactory class and the location of it as properties to the initialcontext class during instatiation.

I have given u an example for weblogic server. i don't know the class name for ur j2ee 1.4 reference implementation server. it's better to use weblogic server or other servers than that reference impl.
If u couldn't find that class, have a jsp or servlet as ur client so that u need not give these initialization parameters. At that time u can use the empty constructor of the InitialContext to instantiate it.

try{
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://157.227.37.86:7001");

System.out.println("Looking up");
InitialContext ic = new InitialContext();
//your lookup code here
}catch(NamingException ie){
}

about that book.
Dont throw it away. that book doesn't concentrate on any specific server. So u don't get any deployment details in it. But the concept explanation is good.


Veshnu<br />SCBCD<br />SCWCD<br />SCJP
Marcin Matys
Greenhorn

Joined: Nov 06, 2005
Posts: 2
thx for your respond Veshnu Ramakrishnan.

J have found somewhere then properties for J2ee server should be:

props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnamingCNCtxFactory");

props.put(Context.PROVIDER_URL, "iiop://localhost:<port>");

and i change my client class to:

import javax.naming.*;
import java.rmi.*;
import java.util.Properties;

import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class DoradcaKlient {

public static void main(String[] args) {
new DoradcaKlient().doDziela();

}

public void doDziela(){

Context ic =null;
DoradcaHome ibaz = null;
Doradca doradca = null;
try{

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");

props.put(Context.PROVIDER_URL, "iiop://localhost:4848");
//, "com.sun.jndi.cosnaming.CNCtxFactory"
ic = new InitialContext(props);
Object o = ic.lookup("Doradca");
ibaz = (DoradcaHome)PortableRemoteObject.narrow(o,DoradcaHome.class);
doradca = ibaz.create();
System.out.println(doradca.getPorada());


}catch(Exception ex){
ex.printStackTrace();
}
}

}

but now i have another problem:

javax.naming.CommunicationException: Cannot connect to ORB [Root exception is or
g.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe]
at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:362)
at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:289)
at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:245)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:209)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.ja
va:32)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
67)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247
)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at DoradcaKlient.doDziela(DoradcaKlient.java:28)
at DoradcaKlient.main(DoradcaKlient.java:11)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed:
Maybe
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectionAbort(
ORBUtilSystemException.java:2372)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectionAbort(
ORBUtilSystemException.java:2390)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.readBit
s(SocketOrChannelConnectionImpl.java:354)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.handleE
vent(SocketOrChannelConnectionImpl.java:1098)
at com.sun.corba.se.impl.transport.SelectorImpl.run(SelectorImpl.java:28
2)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 211 completed:
No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.ioexceptionWhenR
eadingConnection(ORBUtilSystemException.java:2456)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.ioexceptionWhenR
eadingConnection(ORBUtilSystemException.java:2474)
at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.readGIOPHea
der(MessageBase.java:116)
at com.sun.corba.se.impl.transport.CorbaContactInfoBase.createMessageMed
iator(CorbaContactInfoBase.java:150)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.readBit
s(SocketOrChannelConnectionImpl.java:314)
... 2 more
Caused by: java.io.IOException: End-of-stream
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.readFul
ly(SocketOrChannelConnectionImpl.java:602)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.read(So
cketOrChannelConnectionImpl.java:521)
at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.readGIOPHea
der(MessageBase.java:112)
... 4 more


and i am in the same point
Veshnu Ramakrishnan
Ranch Hand

Joined: Sep 27, 2005
Posts: 44
i don't about that j2ee RI server.

But for ur pleasant reading and practice, you can have ur client as a JSP or a Servlet for that u need not initialize these properties, server will do it for u.
Nadeem Awad
Ranch Hand

Joined: Jan 09, 2005
Posts: 74
Dear Marcin,
Here's what worked with me:


I put the j2ee.jar,appserv-rt.jar - and the returned EJB Client Jar of course - to my classpath, and it works fine.

I've tried the suggested Context Initialization, but it didn't work for me:



But it gives me a ClassCastException

Hope this helps.


Share Knowledge to gain it.<br /> <br />SCJP 1.2, SCDJWS 1.4, SCWCD 1.4, SCBCD 1.3, ICAD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: EJB problem
 
Similar Threads
Not able to start sun app server CLI156 error.
Exception [TOPLINK-8006]
.NameNotFoundException:
Not able to run the Dukes bank application in J2EE 1.4 tutorial
Java NameNotFoundException Error