Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Kundera 2.2 class loading issue #146

Closed
schp opened this Issue · 9 comments

3 participants

@schp

I tried to use Kundera 2.2 under Glassfish 3.1 with MongoDB 2.2. I placed the Kundera jars (along with their dependencies) under the /glassfish/domains/domain1/lib directory, because I did not want to package them inside the application WAR file. Now the problem I have detected is that altough method findResourcesByContextLoader in class ClasspathReader used (correctly) the current thread's class loader to find entitiy classes, method scanClassAndPutMetadata in class MetamodelConfiguration used its own classloader, and therefore it did not find the entity classes in the web application. However, if you change the line

Class<?> clazz = Class.forName(className);

to

Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);

it works correctly.

Thanks,
Peter

@kkmishra

Thanks Peter.
It is fixed as you suggested

commit a2e0153

please verify .

Cheers,
Kuldeep

@schp

Thanks for the fix. I am not very proficient in maven, so it is possible that I have misconfigured something, but with the current 2.3-SNAPSHOT I still get the same error. I suspect that the class loader associated with the PersistenceUnitMetadata class (variable puMetadata) is still the same class loader which loaded the JARs from the Glassfish domain/domain1/lib directory and therefore does not "see" the entity classes present in the web app.

Thanks,
Peter

@mevivs
Collaborator

Planning to fix and test it on glassfish as an external kundera jar. Will be fixed in 2.3

-Vivek

@kkmishra

Hi Peter,
I tried but couldn't replicate your issue. I am attaching image screenshots of /glassfish/domains/domain1/lib and /glassfish/domains/domain1/applications/twitample/WEB-INF/lib folders. (twitample is name of my web application).

This worked for me, Please compare this with your configuration and resolve disrepency (if any)
I will be happy to send you my entire code (which is also available at https://github.com/xamry/twitample)

Screenshot-2
Screenshot-3

Thanks
Kuldeep

@schp

Hi Kuldeep,

The screenshots represent the situation I was dealing with, so if your test project worked for you, the problem was indeed fixed. Unfortunately I could not test the fix with my own project because I did not manage to build Kundera from source. However, if you happen to have a fairly recent version in a publicly accessible maven repo, I will gladly test it myself.

Thanks,
Peter

@mevivs
Collaborator

I guess, mvn clean install -DskipTests should work for you to build Kundera.
2.3 release(releasing soon) will be available on public maven repo.

Cheers,

-Vivek

@mevivs
Collaborator

Any update on this? Shall i mark it close for 2.3(releasing today) ?

@schp

I can confirm that in version 2.3 the problem has been fixed, the issue can be closed.

Thanks,
Peter

@mevivs
Collaborator

Closing..

@mevivs mevivs closed this
@mevivs mevivs reopened this
@mevivs mevivs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.