<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal"><br><p dir="auto">Are you using jbosstools/hibernate tools hibernate bundle  to access hibernate user classes, i.e. NOT for the tooling related usecases ? </p>
<p dir="auto">Then I would say you should not be doing that ever. Use hibernate directly and packaged/configured for your app instead.</p>
<p dir="auto">Hibernate now supports osgi based persistence providers and you might want to look into that at <a href="https://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch17.html" style="color:#3983C4">https://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch17.html</a></p>
<p dir="auto">We never used that as it wouldn't allow the flexibility needed for the tools to isolate it self from users class loaders.</p>
<p dir="auto">/max<br>
<a href="http://about.me/maxandersen" style="color:#3983C4">http://about.me/maxandersen</a></p>
<p dir="auto">On 16 Mar 2018, at 14:34, Dmitrii Bocharov wrote:</p>
</div>
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div dir="ltr">Yes, this classloader is loading classes from the user&#39;s Eclipse project. Yes, it extends java.net.URLClassLoader.<div>It doesn&#39;t work because class loading and resource loading is different in Java 9. Especially in eclipse. </div><div><br></div><div><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=497287">https://bugs.eclipse.org/bugs/show_bug.cgi?id=497287</a><br></div><div><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=507417">https://bugs.eclipse.org/bugs/show_bug.cgi?id=507417</a><br></div><div><br></div><div>At least classLoader.getPlatformClassLoader() must be used.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 16, 2018 at 1:21 PM, Jean-Francois Maury <span dir="ltr">&lt;<a href="mailto:jmaury@redhat.com" target="_blank">jmaury@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Not sure to understand #2: are you creating a classloader that is loading classes from the user&#39;s Eclipse project ? Is it based on URL classloader ? I don&#39;t why it is not working ?</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Mar 16, 2018 at 10:12 AM, Dmitrii Bocharov <span dir="ltr">&lt;<a href="mailto:dbocharo@redhat.com" target="_blank">dbocharo@redhat.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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" target="_blank">https://github.com/jbo<wbr>sstools/jbosstools-hibernate/<wbr>blob/b3826209cae7327a91615e0c0<wbr>88006e54a4b5447/plugins/org.hi<wbr>bernate.eclipse/src/org/hibern<wbr>ate/eclipse/console/common/<wbr>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.getUnnamedModul<wbr>e().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>.getResour<wbr>ceAsStream(). </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" target="_blank">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.walk<wbr>FileTree. 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" target="_blank">classloader.findClass</a></i> doesn&#39;t find anything (ClassNotFoundException). I tried to <i>HibernatePlugin.getDefault(<wbr>).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.getUnnamedMod<wbr>ule().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><span class="m_5322961800920310805HOEnZb"><font color="#888888"><div>Bocharov Dmitrii</div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
jbosstools-dev mailing list<br>
<a href="mailto:jbosstools-dev@lists.jboss.org" target="_blank">jbosstools-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/jbosstools-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/jbosstools-dev</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_5322961800920310805gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase"><span>JEFF</span> <span>MAURY</span></p><p style="font-family:overpass,sans-serif;margin:0px;font-size:10px;color:rgb(153,153,153)"><a href="https://www.redhat.com/" style="color:rgb(0,136,206);margin:0px;text-decoration:none" target="_blank">Red Hat <span><br><br></span></a></p><p style="font-family:overpass,sans-serif;margin:0px 0px 6px;font-size:10px;color:rgb(153,153,153)"><span style="margin:0px;padding:0px"><a href="mailto:jmaury@redhat.com" style="color:rgb(0,136,206);margin:0px;text-decoration:none" target="_blank">jmaury@redhat.com</a>   </span></p><table border="0" style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><tbody><tr><td width="100px"><a href="https://red.ht/sig" target="_blank"><img src="https://www.redhat.com/files/brand/email/sig-redhat.png" width="90" height="auto"></a></td><td style="font-size:10px"><div><a href="https://redhat.com/summit" style="text-decoration:none" target="_blank"><img width="70px" height="auto" src="https://www.redhat.com/files/brand/email/sig-summit.png" style="outline:0px"></a></div></td></tr></tbody></table><div style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px"><div style="color:rgb(153,153,153)"><a href="https://twitter.com/redhatjobs" title="twitter" style="background-image:url(&quot;https://www.redhat.com/files/brand/email/sm-twitter.png&quot;);height:20px;text-decoration:none;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px;background-repeat:no-repeat;background-position:0px 50%" target="_blank">@redhatjobs</a>   <a href="https://www.facebook.com/redhatjobs/" title="facebook" style="background-image:url(&quot;https://www.redhat.com/files/brand/email/sm-facebook.png&quot;);height:20px;text-decoration:none;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px;background-repeat:no-repeat;background-position:0px 50%" target="_blank">redhatjobs</a>   <a href="https://instagram.com/redhatjobs" title="instagram" style="background-image:url(&quot;https://www.redhat.com/files/brand/email/sm-instagram.png&quot;);height:20px;text-decoration:none;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px;background-repeat:no-repeat;background-position:0px 50%" target="_blank">@<wbr>redhatjobs</a>  </div></div></div></div>
</font></span></div>
</blockquote></div><br></div></blockquote>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px">
</blockquote><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">_______________________________________________<br>
jbosstools-dev mailing list<br>
jbosstools-dev@lists.jboss.org<br>
<a href="https://lists.jboss.org/mailman/listinfo/jbosstools-dev" style="color:#777">https://lists.jboss.org/mailman/listinfo/jbosstools-dev</a></p>
</blockquote></div>
</div>
</body>
</html>