1 Reply Latest reply on Dec 16, 2005 2:25 AM by Jonn Beames

    Installer default+ejb3: ClassCastException on Session Bean L

    Jonn Beames Newbie

      Greetings JBoss EJB3 community,

      I've got a JSF/EJB3 based project underway. As I've been developing I've been deploying into a JBoss AS that I put together by downloading the 4.0.3SP1 package, unpacking, and adding the EJB3_RC3 files to the "all" server per the instructions. Everything has been working as expected. As I've said before, this stuff is truly a joy to work with.

      But I stumbled onto a problem last night. It looks like a configuration issue, but I'm not sure how to solve it.

      The Problem:

      I set up another AS instance by using the JBoss AS installer: I chose the EJB3 option and took all the defaults which set up a "default" server with EJB3 support. But when I drop the same EAR that works in my all+ejb3 into this new AS and start up the "default" server, the EAR appears to deploy correctly, but when I try to interact with the app I get a java.lang.ClassCastException when it tries to look up a stateless session bean:

      10:00:58,287 INFO [STDOUT] java.lang.ClassCastException: $Proxy66
      10:00:58,289 INFO [STDOUT] at com.saynow.mediamanager.web.Utils.getAudioFileManager(Utils.java:11)
      10:00:58,289 INFO [STDOUT] at com.saynow.mediamanager.web.MediaManagerBean.<init>(MediaManagerBean.java:10)
      10:00:58,290 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      10:00:58,290 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      10:00:58,291 INFO [STDOUT] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      10:00:58,291 INFO [STDOUT] at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      10:00:58,292 INFO [STDOUT] at java.lang.Class.newInstance0(Class.java:350)
      10:00:58,292 INFO [STDOUT] at java.lang.Class.newInstance(Class.java:303)
      ...etc.

      Line 10 & 11 of Utils being:
      InitialContext ctx = new InitialContext();
      return (AudioFileManager) ctx.lookup(AudioFileManager.class.getName());

      The only thing I notice as unexpectedly different in the server start-up console output are these two lines, which show up in the installer default+ejb3 but not in the manually installed all+ejb3:
      09:58:26,421 INFO [NamingService] Started jndi bootstrap jnpPort=1099, rmiPort=1098, backlog=50, bindAddress=/0.0.0.0, Client SocketFactory=null, Server SocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076
      09:58:26,852 WARN [NamingService] Context.PROVIDER_URL in server jndi.properties, url=localhost:1099

      Has anyone encountered anything like this before? Or know what I am doing wrong? I do not have copies of the session beans in WEB-INF/lib or WEB-INF/classes. I am loading the datasource and connector jar, along with tomahawk and some other commonly used libs via a sar, but it does not include any of the session or entity beans either.

      Any help greatly appreciated,
      Jonn

        • 1. Re: Installer default+ejb3: ClassCastException on Session Be
          Jonn Beames Newbie

          More info on this...

          A colleague had reworked our ant script so that the war file has no WEB-INF/lib or WEB-INF/classes directories. Instead the classes and lib jars are referenced from the file system via a jboss-service.xml file in the above mentioned sar (the one that also provides the datasourse config/lib). This is his solution for class loading memory problems he has experienced in the past when doing multiple redeployments into JBoss without restarting.

          I modified the build script to put the compiled web classes in WEB-INF/classes and this caused the ear to work correctly in the default+ejb3 server. This makes me happy and I am almost satisfied. But the question regarding the configuration remains...

          The ear file built with a war that does not contain WEB-INF/classes works in the manually set up all+ejb3 but does not work in the installer set up default+ejb3 (jndi session bean lookup class cast problem). So there is probably some simple configuration change I can make to the default+ejb3 server to get a similar working behavior as in the all+ejb3 server.

          Anyone know what it might be?

          Thanks again,
          Jonn