Calling a query on a table with BLOBs (Files in Tables) using the jTDS-Driver I get a class-loader error:

java.lang.IllegalArgumentException: interface org.hibernate.engine.jdbc.WrappedBlob is not visible from class loader

My Solution was to switch to an other classloader:

  public synchronized void method() {

        Thread thread = Thread.currentThread();
        ClassLoader tempLoader = thread.getContextClassLoader();

        entityManager.createNativeQuery("select * from TSRPTBLB where TSBID = 1 ")


Will there be any other, cleaner way than switsching the classloader?

Thank you in advance

asked 09.09.2014 at 14:41

Alexis's gravatar image

accept rate: 66%

Yes there is a better way:

  1. You should explicitly set the correct ClassLoader to a class in the JAR where you run into problems (e.g set the class loader from WrappedBlob.class)
  2. Add a finally statement so that in case of an exception you can still reset the original context ClassLoader or the server will be in a corrupt state

So if you consider both points the code could look as follows:

public synchronized void method() {
    Thread thread = Thread.currentThread();
    java.lang.ClassLoader originalClassLoader = thread.getContextClassLoader();
    try {
                "select * from TSRPTBLB where TSBID = 1 ")
    } finally {

answered 11.09.2014 at 15:44

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
accept rate: 70%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 09.09.2014 at 14:41

Seen: 2,921 times

Last updated: 11.09.2014 at 15:44