1 Reply Latest reply on Sep 20, 2002 8:00 PM by ldandersen

    ClassCastException upon EAR Redeploy!

    ldandersen

      Hi,
      I hate to bring up another ClassCastException problem, but I'm really stumped. I have a servlet (actually a Struts action) that needs to look up EJBs. My code works great until I redeploy my EAR file (which contains an EJB Jar and a WAR file). Once JBoss redeploys it, any subsequent requests to the servlet yield the following exception:

      java.lang.ClassCastException
      at com.sun.corba.se.internal.javax.rmi.PortableR
      emoteObject.narrow(PortableRemoteObject.java:293)
      at javax.rmi.PortableRemoteObject.narrow(Portabl
      eRemoteObject.java:134)

      I am using JBoss 3.0/Jetty on Windows. Here is the code in question:

      public UserManager getUserManager () {
      try {
      if (manager == null) {
      initUserManager();
      }

      return manager;
      }
      catch (RemoteException e) {
      e.printStackTrace();
      }
      catch (CreateException e) {
      e.printStackTrace();
      }
      catch (NamingException e) {
      e.printStackTrace();
      }

      return null;
      }

      public void initUserManager () throws NamingException, RemoteException, CreateException {
      if (managerHome == null) {
      managerHome = (UserManagerHome) PortableRemoteObject.narrow(lookup("loanapps/UserManager"), UserManagerHome.class);
      manager = managerHome.create();
      }
      }

      public Object lookup (String jndiName) throws NamingException, MissingResourceException {
      if (jndiContext == null) {
      ResourceBundle resource = ResourceBundle.getBundle("com.megastar.loanapps.jndi");
      Properties properties = new Properties();
      properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, resource.getString(Context.INITIAL_CONTEXT_FACTORY));
      properties.setProperty(Context.PROVIDER_URL, resource.getString(Context.PROVIDER_URL));
      properties.setProperty(Context.URL_PKG_PREFIXES, resource.getString(Context.URL_PKG_PREFIXES));
      jndiContext = new InitialContext(properties);
      }

      return (jndiContext.lookup(jndiName));
      }

      Also, it should be mentioned that I have tried this with and without including my EJB classes in my WAR (in addition to my EJB jar).

      Does anyone have any ideas what I could do to alleviate this problem? Perhaps a different way to package my app? Any help would be *greatly* appreciated!

      Thanks in advance!

      Buzz Andersen