3 Replies Latest reply on Nov 15, 2013 6:19 AM by Anders Welen

    Very peculiar ClassCastException (oracle.sql.BLOB cannot be cast to itself...).

    marbled Newbie

      Hi!

       

      We are converting an application that was running on Websphere to JBoss and the latest problem I have (they were quite a few) is this

       

      java.lang.ClassCastException: oracle.sql.BLOB cannot be cast to oracle.sql.BLOB

       

      According to what I read this might be caused by the fact that I have two times a jar that provides oracle.sql.BLOB.

       

      I do have one provided in the EAR that I link against and the other was deployed on the JBoss server (EAP 6.0).

       

      It is the same jar though so I don't quite get why it's complaining (I get it somehows track which jar is used)

       

      How can I fix this problem?

       

      Thank you!

       

      Nick

        • 1. Re: Very peculiar ClassCastException (oracle.sql.BLOB cannot be cast to itself...).
          Anders Welen Apprentice

          That is a classic problem in a multi classloader environment (like JBoss). Even if the exact same class is loaded by two different classloaders they are NOT the same class in Java.

           

          I would suggest that you remove the JDBC driver (I guess that it is what we are talking about here) from your EAR and keep the one in deployed in JBoss.

          • 2. Re: Very peculiar ClassCastException (oracle.sql.BLOB cannot be cast to itself...).
            marbled Newbie

            Hi Anders!

             

            Thank you for confirming that this was indeed the problem.

             

            It did felt like it could indeed make the difference between the two classes but I had never (nor my colleagues) heard of that...

             

            My main problem was making sure it would work once deployed and in in our IDE which is why I had bundle the jar file in the EAR.

             

            What I did to fix this was refer to the jar in the Oracle client the developers have locally for the build and remove the one I had put in the EAR. The developers will have to define a classpath variable that point to their Oracle client for their workspace once and I now no longer have to provide the Oracle jar in the EAR.

             

            For some weird reason we didn't have that problem with WebSphere but nothing surprises me anymore, that (externally developed and now maintained in-house) application had quite a few things that relied on WebSphere's quirks (and even after modifying it to make it works on JBoss it still works on WebSphere..)...

             

            Thank you and have a nice day!

             

            Nick

            • 3. Re: Very peculiar ClassCastException (oracle.sql.BLOB cannot be cast to itself...).
              Anders Welen Apprentice

              Great that the problem is solved.

               

              That it worked on WebSphere may not be weird at all. It all depends on how the application server uses classloaders. Even in older version of JBoss (that using the "Unified Classloader") you "faulty" setup may work in some cases.