tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alltomee <>
Subject EJB remote access (WAR to WAR) throws java.lang.ClassCastException: com.sun.proxy.$Proxy*** cannot be cast to ***
Date Sat, 17 Dec 2016 23:45:51 GMT
Good night. I'm struggling with this problem forever, so I resolved to put
this question here. Any help will be welcome 

I'm migrating from Glassfish to TomEE. By now, all WARs has been moved and
working by default at TomEE, except one. I have two WARs, one called
EJBSERVER and another called EJBCLIENTS. The EJBSERVER has a EJB called
Hello, that has a method called sayHello, like below:

*package ejbs;

import javax.ejb.*;
import javax.annotation.*;

import interfaces.*;

public class Hello implements HelloJNDI, Serializable{

  private String message = "Hello ";

  public String sayHello(String name) {

    return message + name + "!";


The class HelloJNDI is a interface inside the same WAR but at package
interfaces, like follow:

*package interfaces;

import javax.ejb.*;

public interface HelloJNDI{
  String sayHello(String name);

As you can see, it's very simple, like that examples we find at Internet. 

So, now I have another WAR called EJBCLIENTS, who will be client of Hello
class through it's interface HelloJNDI.

The class ClientJNDI is a servlet that does this:

import java.util.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import javax.inject.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;

import interfaces.*;

public class ClientJNDI extends HttpServlet{

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws

    res.setContentType("text/html; charset=UTF-8");

    PrintWriter writer = res.getWriter();

      InitialContext ctx = new InitialContext();
      HelloJNDI hello = (HelloJNDI)
    catch(NamingException e){
      System.out.println("JNDI error");




So, before anything, let me say that this example works perfectly at
Glassfish. At TomEE and OpenEJB, the following error is shown at browser:

*java.lang.ClassCastException: com.sun.proxy.$Proxy182 cannot be cast to

What's wrong?

View this message in context:
Sent from the TomEE Users mailing list archive at

View raw message