On Jun 5, 2009, at 2:31 PM, Marcelo de Oliveira Dias wrote:
Hi folks.
Let me explain my problem:
I'm using OpenEJB embedded with Jetty. I have created a WebApp that
have a
Servlet which instantiates the OpenEJB, deploy all of its EJBs (just
one in
that case, called Catalogo), and deploy other EJBs from others
WebApps that
are running on Jetty (just one in that case, called CatalogoLivraria).
And it has a service to handle the EJB requests:*
protected void service(HttpServletRequest request,
HttpServletResponse
response) throws ServletException, IOException {
ServletInputStream in = request.getInputStream();
ServletOutputStream out = response.getOutputStream();
try {
ejbServer.service(in, out);
} catch (ServiceException e) {
throw new ServletException("ServerService error: " +
ejbServer.getClass().getName() + " -- " + e.getMessage(), e);
}
}*
The deployment seems that works, I get the Log messages:
*
*For the EJB that belong to my "Embedder openejb webapp"
*INFO - Jndi(name=CatalogoLocal) --> Ejb(deployment-id=Catalogo)
INFO - Jndi(name=CatalogoRemote) --> Ejb(deployment-id=Catalogo)
INFO - Created Ejb(deployment-id=Catalogo, ejb-name=Catalogo,
container=Default Stateless Container)*
For the EJB that belong to another webapp
*INFO - Jndi(name=CatalogoLivrariaLocal) -->
Ejb(deployment-id=CatalogoLivraria)
INFO - Jndi(name=CatalogoLivrariaRemote) -->
Ejb(deployment-id=CatalogoLivraria)
INFO - Created Ejb(deployment-id=CatalogoLivraria,
ejb-name=CatalogoLivraria, container=Default Stateless Container)
*When I run a simple J2SE ejb client that "look up" at "Catalogo" it
works
ok!
But when I run it "looking up" at "CatalogoLivraria" a get this
exception:
*javax.naming.NamingException: Unknown error in container [Root
exception is
java.lang.IllegalArgumentException: interface
org.apache.openejb.core.ivm.IntraVmProxy is not visible from class
loader]
*I guess that my problem is related to how my Servlet deploys the
EJBs.
And how this proxy is instantiated by "Proxy.newProxyInstance()" in
the
class "org.apache.openejb.util.proxy.Jdk13ProxyFactory".
Which is likely a ClassLoader problem.
I'm sure that the *IntraVmProxy *is visible. Taking a look at the
peace of
code that throws that exception in "Proxy.newProxyInstance()" we have:
*String interfaceName = interfaces[i].getName();
367 Class interfaceClass = null;
368 try {
369 interfaceClass = Class.forName(interfaceName,
false, loader);
370 } catch (ClassNotFoundException e) {
** 371 }
372 if (interfaceClass != interfaces[i]) {
373 throw new IllegalArgumentException(
374 interfaces[i] + " is not visible from
class loader");
375 }*
So maybe, if it is visible, it is visible by a wrong ClassLoader.
I know that what I'm trying to do isn't easy. So any thing that
helps me to
understand why I'm having this problem with
"Proxy.newProxyInstance()" will
be very "helpful" :-)
Sounds very tricky indeed. Do you by chance have a copy of the
openejb libraries in each webapp? That would definitely cause some
conflicts when trying to share beans between the webapps.
-David