You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Michael Dick <mi...@gmail.com> on 2011/06/16 15:50:33 UTC

Re: Dynamic Enhancement not working on Oracle JDK/Linux

Hi Harald,

I don't think the VirtualMachine class (the class we're looking for in
tools.jar) has moved. I compared 1.6.0_22 and 1.6.0_25 and it's in the same
location - JDK_HOME/lib/tools.jar.

The problem here is that java.home is pointing to the JRE location instead
of the JDK location (which is what we've been doing in developing OpenJPA).

This looks like something we can fix by swizzling the classpath, but the
documentation does indicate that you need a JDK, or SDK to run :
 2.4.  Enhancing Dynamically at Runtime

If a javaagent is not provided via the command line and OpenJPA is running
on the Oracle 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
dynamically load the Enhancer that was mentioned in the previous section.
This support is provided as an ease of use feature and it is not recommended
for use in a production system. Using this method of enhancement has the
following caveats:

<snip>

It doesn't mention the issue about JAVA_HOME though - we'll have to get that
updated.

In the mean time, can you use a javaagent instead?

-mike


On Thu, Jun 16, 2011 at 8:21 AM, Harald Wellmann <Ha...@gmx.de>wrote:

> There's a problem with setting up dynamic enhancement for OpenJPA 2.1.0
> with recent Oracle JDKs on Linux, related to the java.home system property.
>
> org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar()
> attempts to load the tools.jar from ${java.home}/lib/tools.jar.
>
> The problem is that even when running under the JDK, java.home points to
> /usr/lib/jvm/java-6-sun/jre instead of /usr/lib/jvm/java-6-sun.
>
> Just to rule out that Ubuntu's packaging might cause the problem, I
> downloaded the latest JDK 1.6.0_24, installed it in my home folder and
> ran a System.println(System.getProperty("java.home")  both from
> [java_install]/bin/java and [java_install]/jre/bin/java, and in both
> cases, the result was [java_install]/jre.
>
>
> So it appears the special case
>             if (JavaVendors.getCurrentVendor().isIBM()) {
>
> in findToolsJar() is now also required for Oracle's JDK.
>
> This looks like a bug or at least an incompatible change in the JDK to
> me, but then again, the structure of a JDK installation is vendor
> dependent, and I'm not sure that OpenJPA's lookup logic is failsafe.
>
> For now, I just created a symlink in my JDK so that OpenJPA finds
> tools.jar under .../jre/lib.
>
> Are there any better solutions? Should I file an issue in JIRA?
>
> Regards,
> Harald
>
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>

Re: Dynamic Enhancement not working on Oracle JDK/Linux

Posted by Michael Dick <mi...@gmail.com>.
I would have thought that setting JAVA_HOME would have worked. Unfortunately
I haven't done a lot with thy the DynamicEnhancerAgent though. I'm glad the
javaagent is mostly working for you though.

I use the agent when running unit tests in eclipse too. I use a string
substitution to shorten the string I have to type, but I still have to
remember to add it to the run configuration.

-mike

On Thu, Jun 16, 2011 at 9:01 AM, Harald Wellmann <Ha...@gmx.de>wrote:

> Hi Mike,
>
> yes, I had to switch to the agent now, as the Dynamic Enhancer did not work
> for me in all cases even with the symlink workaround (probably because some
> Entity classes were loaded before the EMF was created, but I'm using the
> Spring Test Context, and I can't really control what's going on behind the
> scenes in Spring.)
>
> I need my entity classes to work with multiple providers, so I can't use
> Build Time enhancement.
>
> Using the agent is a bit inconvenient when running JUnit tests from
> Eclipse, and I don't really want to enable it globally.
>
> Regarding, the java.home issue:  I'm really talking about the system
> property java.home, not about the environment variable JAVA_HOME. I tried
> setting both, but that didn't work.
>
> Regards,
> Harald
>
> -------- Original-Nachricht --------
> > Datum: Thu, 16 Jun 2011 08:50:33 -0500
> > Von: Michael Dick <mi...@gmail.com>
> > An: users@openjpa.apache.org
> > Betreff: Re: Dynamic Enhancement not working on Oracle JDK/Linux
>
> > Hi Harald,
> >
> > I don't think the VirtualMachine class (the class we're looking for in
> > tools.jar) has moved. I compared 1.6.0_22 and 1.6.0_25 and it's in the
> > same
> > location - JDK_HOME/lib/tools.jar.
> >
> > The problem here is that java.home is pointing to the JRE location
> instead
> > of the JDK location (which is what we've been doing in developing
> > OpenJPA).
> >
> > This looks like something we can fix by swizzling the classpath, but the
> > documentation does indicate that you need a JDK, or SDK to run :
> >  2.4.  Enhancing Dynamically at Runtime
> >
> > If a javaagent is not provided via the command line and OpenJPA is
> running
> > on the Oracle 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
> > dynamically load the Enhancer that was mentioned in the previous section.
> > This support is provided as an ease of use feature and it is not
> > recommended
> > for use in a production system. Using this method of enhancement has the
> > following caveats:
> >
> > <snip>
> >
> > It doesn't mention the issue about JAVA_HOME though - we'll have to get
> > that
> > updated.
> >
> > In the mean time, can you use a javaagent instead?
> >
> > -mike
> >
> >
>
> --
> NEU: FreePhone - kostenlos mobil telefonieren!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
>

Re: Dynamic Enhancement not working on Oracle JDK/Linux

Posted by Harald Wellmann <Ha...@gmx.de>.
Hi Mike,

yes, I had to switch to the agent now, as the Dynamic Enhancer did not work for me in all cases even with the symlink workaround (probably because some Entity classes were loaded before the EMF was created, but I'm using the Spring Test Context, and I can't really control what's going on behind the scenes in Spring.)

I need my entity classes to work with multiple providers, so I can't use Build Time enhancement.

Using the agent is a bit inconvenient when running JUnit tests from Eclipse, and I don't really want to enable it globally.

Regarding, the java.home issue:  I'm really talking about the system property java.home, not about the environment variable JAVA_HOME. I tried setting both, but that didn't work.

Regards,
Harald

-------- Original-Nachricht --------
> Datum: Thu, 16 Jun 2011 08:50:33 -0500
> Von: Michael Dick <mi...@gmail.com>
> An: users@openjpa.apache.org
> Betreff: Re: Dynamic Enhancement not working on Oracle JDK/Linux

> Hi Harald,
> 
> I don't think the VirtualMachine class (the class we're looking for in
> tools.jar) has moved. I compared 1.6.0_22 and 1.6.0_25 and it's in the
> same
> location - JDK_HOME/lib/tools.jar.
> 
> The problem here is that java.home is pointing to the JRE location instead
> of the JDK location (which is what we've been doing in developing
> OpenJPA).
> 
> This looks like something we can fix by swizzling the classpath, but the
> documentation does indicate that you need a JDK, or SDK to run :
>  2.4.  Enhancing Dynamically at Runtime
> 
> If a javaagent is not provided via the command line and OpenJPA is running
> on the Oracle 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
> dynamically load the Enhancer that was mentioned in the previous section.
> This support is provided as an ease of use feature and it is not
> recommended
> for use in a production system. Using this method of enhancement has the
> following caveats:
> 
> <snip>
> 
> It doesn't mention the issue about JAVA_HOME though - we'll have to get
> that
> updated.
> 
> In the mean time, can you use a javaagent instead?
> 
> -mike
> 
> 

-- 
NEU: FreePhone - kostenlos mobil telefonieren!			
Jetzt informieren: http://www.gmx.net/de/go/freephone