<div dir="ltr">Hi<div>it&#39;s a long time i&#39;m trying to make jbosstools-hibernate work with Java.</div><div>The main problem is the class loader: <a href="https://github.com/jbosstools/jbosstools-hibernate/blob/b3826209cae7327a91615e0c088006e54a4b5447/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/console/common/HibernateExtension.java#L58">https://github.com/jbosstools/jbosstools-hibernate/blob/b3826209cae7327a91615e0c088006e54a4b5447/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/console/common/HibernateExtension.java#L58</a>.</div><div><br></div><div><b>sub-problem #1 (getResource) method </b>(solved)</div><div>If you google how to load resources in Java 9, then you find that now you should do <i>classloader.getUnnamedModule().getResourceAsStream()</i> instead of previous <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><i>classloader</i><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><i>.getResourceAsStream(). </i>But we want, that our code could be built inside Java 7 Execution Environment (see MANIFEST.MF). So what i did for the <i><a href="https://github.com/jbosstools/jbosstools-hibernate/blob/b3826209cae7327a91615e0c088006e54a4b5447/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/console/common/HibernateExtension.java#L88">getResource</a></i> method. If we have null for <i>super.getResource(name)</i>, then i manually 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.</span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><b>sub-problem #2 (findClass)</b></span><span style="font-weight:400;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> method (HELP NEEDED)</span></span></div><div>After the resource is found (and in hibernate usually it&#39;s a mapping xml file) using the solution above, we try to associate it with the class and load it with the classloader. However, the current <i><a href="https://github.com/jbosstools/jbosstools-hibernate/blob/b3826209cae7327a91615e0c088006e54a4b5447/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/console/common/HibernateExtension.java#L63">classloader.findClass</a></i> doesn&#39;t find anything (ClassNotFoundException). I tried to <i>HibernatePlugin.getDefault().getBundle().loadClass(name)</i>, because i found that this loading classes stuff is fixed in core Eclipse and bundles must load classes without problems, but it doesn&#39;t work either.</div><div><br></div><div>So my main questions are:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>1) This code is rather old, and i suppose that it must be refactored in general. If you have any thoughts of how to do it better, i&#39;d be glad if you share them :)</div><div>2) How to load user classes correctly now in Java 9 in Eclipse?</div><div>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 <i style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">classloader.getUnnamedModule().getResourceAsStream() </i><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">there? And switching between them using extension points mechanism. Is it possible? Does it worth it? If yes, then it&#39;ll require quite big work, in my opinion.</span></div><div><br></div></blockquote><br><div>Looking forward to any help.</div><div>Thanks in advance!</div><div>Bocharov Dmitrii</div></div>