I've got a pair of web applications hosted on my server, each hosting a
single stateless session bean. The intent of these two is to get two beans
talking between applications. To test this, one bean (Calc) returns the
square of a number passed to it by the other bean (EJBTest).

Using the Calc bean and a standalone client, I've been successful (running
the client on a different machine), but convincing the beans to talk to each
other within separate applications on the same server seems a lot harder. As
an aside, if both beans are hosted within the same application, getting them
to talk is trivial.

Specifics - in my EJBTest bean (the client) is the following code.. (All in
a try clause..)

1   Properties prop = new Properties();
2   prop.put("java.naming.factory.initial",
"com.evermind.server.ApplicationClientInitialContextFactory");
3   prop.put("java.naming.provider.url","ormi://<server-name>/<app-name>");
4   prop.put("java.naming.security.principal","admin");
5   prop.put("java.naming.security.credentials","64vw7qp");
6
7   prop.list(System.err);
8   InitialContext ic = new InitialContext(prop);
9   Object objref2 = ic.lookup("java:comp/env/ejb/Calc");
10  CalcHome ch = (CalcHome) PortableRemoteObject.narrow(objref2,
CalcHome.class);
11
12  Calc ctest = ch.create();
13  result = ctest.calcSqr(5);
14  ctest.remove();

All of this code is fairly standard, and performs as expected until line 10,
where a ClassCastException is thrown. Calling objref2.getClass().getName()
gives the name of the object obtained from the lookup as
CalcHome_StatelessSessionHomeWrapper1

What sort of things could be causing this? I imagine it means that something
is missing from my one of my deployment descriptors, but I can't figure out
what. Given that I can access the bean from a standalone client, I'm led to
believe that the problem is in the deployment of the EJBTest bean.

Any suggestions would be welcome. I haven't posted snippets from my
deployment descriptors here, because this message is getting pretty long as
it is. I can do that though, if someone thinks they could help me find the
problem with them.

Trond.


Reply via email to