Are you using jbosstools/hibernate tools hibernate bundle to access
hibernate user classes, i.e. NOT for the tooling related usecases ?
Then I would say you should not be doing that ever. Use hibernate
directly and packaged/configured for your app instead.
Hibernate now supports osgi based persistence providers and you might
want to look into that at
We never used that as it wouldn't allow the flexibility needed for the
tools to isolate it self from users class loaders.
Yes, this classloader is loading classes from the user's Eclipse
Yes, it extends java.net.URLClassLoader.
It doesn't work because class loading and resource loading is
Java 9. Especially in eclipse.
At least classLoader.getPlatformClassLoader() must be used.
On Fri, Mar 16, 2018 at 1:21 PM, Jean-Francois Maury
> Not sure to understand #2: are you creating a classloader that is
> classes from the user's Eclipse project ? Is it based on URL
> classloader ?
> I don't why it is not working ?
> On Fri, Mar 16, 2018 at 10:12 AM, Dmitrii Bocharov
>> it's a long time i'm trying to make jbosstools-hibernate work with
>> The main problem is the class loader: https://github.com/jbo
>> *sub-problem #1 (getResource) method *(solved)
>> If you google how to load resources in Java 9, then you find that
>> now you
>> should do *classloader.getUnnamedModule().getResourceAsStream()*
>> of previous *classloader**.getResourceAsStream(). *But we want, that
>> code could be built inside Java 7 Execution Environment (see
>> So what i did for the *getResource
>> method. If we have null for *super.getResource(name)*, then i
>> search for resources next to hibernate.cfg.xml
>> using java.nio.file.Files.walkFileTree. And it works! It needs to be
>> polished a little bit, but anyway it solves the problem.
>> *sub-problem #2 (findClass)* method (HELP NEEDED)
>> After the resource is found (and in hibernate usually it's a mapping
>> file) using the solution above, we try to associate it with the
>> class and
>> load it with the classloader. However, the current
>> doesn't find anything (ClassNotFoundException). I tried to
>> *HibernatePlugin.getDefault().getBundle().loadClass(name)*, because
>> found that this loading classes stuff is fixed in core Eclipse and
>> must load classes without problems, but it doesn't work either.
>> So my main questions are:
>> 1) This code is rather old, and i suppose that it must be refactored
>> general. If you have any thoughts of how to do it better, i'd be
>> glad if
>> you share them :)
>> 2) How to load user classes correctly now in Java 9 in Eclipse?
>> 3) Maybe the better way is to create a plugin/feature with a minimal
>> Execution Environment set to Java 9, which will be activated only
>> when java
>> 9 is used and implement such things like
>> *there? And switching between them using extension points mechanism.
>> it possible? Does it worth it? If yes, then it'll require quite big
>> in my opinion.
>> Looking forward to any help.
>> Thanks in advance!
>> Bocharov Dmitrii
>> jbosstools-dev mailing list
> JEFF MAURY
> Red Hat
> @redhatjobs <https://twitter.com/redhatjobs>
jbosstools-dev mailing list