8 Replies Latest reply on Jun 25, 2003 3:10 PM by warrenc5

    Scheduler and ClassCastException

    bloid

      Hi there jboss experts :-)

      I have a problem... I have a scheduler task, which runs every hour, to import some data into an auxilliary database. This Scheduler task has to get a reference to one of my EJBs. This works fine the first time I run it, but if I redeploy my EJB jar, I keep getting the following exception:

      2003-06-06 16:27:30,055 ERROR [STDERR] java.lang.ClassCastException
      2003-06-06 16:27:30,056 ERROR [STDERR] at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
      2003-06-06 16:27:30,056 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
      2003-06-06 16:27:30,056 ERROR [STDERR] at org.picr.vice.mbean.SQLImporterScheduler.fetchImagehome(SQLImporterScheduler.java:47)
      2003-06-06 16:27:30,056 ERROR [STDERR] at org.picr.vice.mbean.SQLImporterScheduler.perform(SQLImporterScheduler.java:110)
      2003-06-06 16:27:30,056 ERROR [STDERR] at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1046)
      2003-06-06 16:27:30,057 ERROR [STDERR] at org.jboss.mx.server.NotificationListenerProxy.handleNotification(NotificationListenerProxy.java:71)
      2003-06-06 16:27:30,057 ERROR [STDERR] at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:84)
      2003-06-06 16:27:30,057 ERROR [STDERR] at javax.management.timer.Timer.sendNotifications(Timer.java:441)
      2003-06-06 16:27:30,057 ERROR [STDERR] at javax.management.timer.Timer.access$000(Timer.java:31)
      2003-06-06 16:27:30,057 ERROR [STDERR] at javax.management.timer.Timer$RegisteredNotification.doRun(Timer.java:612)
      2003-06-06 16:27:30,057 ERROR [STDERR] at org.jboss.mx.util.SchedulableRunnable.run(SchedulableRunnable.java:164)
      2003-06-06 16:27:30,058 ERROR [STDERR] at org.jboss.mx.util.ThreadPool$Worker.run(ThreadPool.java:225)

      No matter what I try to do to get the proper class;

      ImageHome.class ;
      Class.forName( "ImageHome" ) ;
      Class.forName( "ImageHome" ).newInstance().getClass() ;

      I still get the ClassCastException until I restart JBoss, then it all seems to work properly again... It's as if the classpath is getting "stuck" with the old version of ImageHome... But then again, even if I don't change the Image EJB, and just redeploy I still get the same problem :-(

      Hope someone can help me :-)

      Thanks!

      Tim Yates

        • 1. Re: Scheduler and ClassCastException
          bloid

          Oooops... forgot to mention that I am using JBoss 3.0.7 :-)

          Thanks again for *any* help :-)

          Tim

          • 2. Re: Scheduler and ClassCastException
            bloid

            I just upgraded to jboss 3.0.8

            The problem still exists :-(

            • 3. Re: Scheduler and ClassCastException
              jonlee

              Haven't tried this, but can't you redeploy your scheduler task by making it dependent on your EJB jar (by creating a SAR)?

              The problem will be that the class image has bounced from being unloaded and reloaded but probably your scheduler task is referencing the invalidated copy.

              • 4. Re: Scheduler and ClassCastException
                bloid

                > Haven't tried this, but can't you redeploy your scheduler task by making it dependent on your EJB jar (by creating a SAR)?

                Errr... are there any tutorials on making a sar directory out there?

                I take it SARs are Service Archives? How would I go about combining my Sheduler and EJB jar into one?

                Thanks for the response!! Each one makes my heart feel less heavy :-)

                Tim.

                • 5. Re: Scheduler and ClassCastException
                  genman


                  I suggest you look in the JBoss directories themselves ($JBOSS/server/all/deploy) -- you can see several ".sar"s there.

                  You can bundle .sars and EJB .jars into a single EAR. The dynamic deployment feature makes it easy to test.

                  • 6. Re: Scheduler and ClassCastException
                    bloid

                    Yay! Got that working! :-)

                    It's cool now, that it doesn't try to access the EJBs before deployment, or during redeployment...

                    Still get a classcastexception when the scheduler tries to access the EJBs after a redeploy, but I managed to *squeeze* round this problem by catching the exception on the PortableRemoteObject.narrow, and if it does get caught, I use JMX to redeploy the scheduler ;-)

                    Ahhh... hack tastic ;-)

                    Would still like to know why this happens... I am confused as to whether it is a JBoss or JDK 1.4.2 on linux bug... There seems to be different stories from different sources...

                    I guess time will tell...I'll have to be proud of my hack till then ;-)

                    Thanks all :-)

                    Tim.

                    • 7. Re: Scheduler and ClassCastException
                      nusa

                      Hi Tim,

                      Would that possible to share your code, or at least tell us how your SAR 'talk' to EJB ?

                      Thanks,
                      Ben.

                      • 8. Re: Scheduler and ClassCastException
                        warrenc5

                        hi,

                        i get a very similar error when i switched from sun javac to using the ibm jikes compiler. I am about to throw in some serial UIDs into my classes.

                        well actually as I have 16 million ejbs I'm going to use jalopy.

                        regards,

                        warren crossing