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 2010/02/01 17:59:08 UTC

Re: Changing to use log4j logging causes error about missing Java agent

Hi David,

I'm sure some Spring users monitor this email list, but you might get better
hits on one of the Spring centric lists. It looks like the error originates
in Spring, not OpenJPA.

It's worth checking your compiled classes to make sure they're enhanced
though. Do you have any simple junit style tests (no Spring involved) that
use the entities? If you have runtimeUnenhancedClasses=unsupported and the
entities work in junit then you know they've been enhanced correctly at
build time.

If they aren't enhanced maybe running the enhancer (again?) will help with
the loadtime agent issue..

-mike


On Sun, Jan 31, 2010 at 3:49 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:

> > -----Original Message-----
> > From: KARR, DAVID (ATTCINW)
> > Sent: Sunday, January 31, 2010 12:30 PM
> > To: users@openjpa.apache.org
> > Subject: RE: Changing to use log4j logging causes error about missing
> > Java agent
> >
> > > -----Original Message-----
> > > From: KARR, DAVID (ATTCINW)
> > > Sent: Sunday, January 31, 2010 12:17 PM
> > > To: users@openjpa.apache.org
> > > Subject: Changing to use log4j logging causes error about missing
> > Java
> > > agent
> > >
> > > I've been working ok with my OpenJPA 1.2.2 app for a while.  I'm
> > using
> > > build-time enhancement, and "openjpa.RuntimeUnenhancedClasses" is
> set
> > > to
> > > "unsupported".  I had my "openjpa.Log" property set with the "basic"
> > > strategy, not using log4j or commons-logging.  It was working fine.
> > I
> > > then decided since I was using log4j with other components, I wanted
> > > openjpa to use that also.  I changed the value to "log4j", then
> added
> > a
> > > "logger" element in my log4j.xml for openjpa.  I started up the
> > server,
> > > and got the exception that follows this.
> > >
> > > I don't see why it suddenly thinks I need to use a -javaagent.  I'd
> > > prefer not to do this.  I certainly don't need "load-time class
> > > transformation", if that's what the build-time enhancer does.
> >
> > Additional information:
> >
> > It appears it isn't just happening when I try to use log4j.  If I have
> > any "openjpa.Log" setting that enables logging, I get this error.  If
> I
> > turn off logging completely, the app starts up and works fine.
> >
> > I had logging on all the time when I was developing the app with
> > OpenJPA
> > 1.2.1.  I recently upgraded to 1.2.2, and about that time I turned off
> > logging.  It seems like now that I'm using 1.2.2, I'm getting this new
> > error if I try to use logging.
>
> I just tried backing up to 1.2.1, and I'm still getting the error.
>
> After I went back to 1.2.2, I managed to find a very trivial change that
> causes the error to occur.  Changing it back makes it stop.  The change
> appears to have something to do with the interaction with Spring, but
> it's part of the OpenJPA integration with it.
>
> I have the following bean defined in my Spring context:
>
>    <bean id="catalogEntityManagerFactory"
>
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBea
> n"
>          p:dataSource-ref="catalogDataSource">
>        <property name="loadTimeWeaver">
>            <bean
> class="org.springframework.instrument.classloading.InstrumentationLoadTi
> meWeaver" />
>        </property>
>        <property name="jpaVendorAdapter">
>            <bean
> class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
>                  p:showSql="${jpa.showSql}"/>
>        </property>
>    </bean>
>
> In my properties file, I have a property setting for "jpa.showSql".  In
> the current state of the application, if I have that property set to
> "true" in the properties file, the application deploys and runs fine,
> and is showing the SQL output.
>
> If I instead set that property to "false", I get the "javaagent"
> exception at load time.
>
> I currently have no explicit setting for "openjpa.Log".
>
> I noticed the following block of code in "OpenJpaVendorAdapter":
>
> /*  77 */     if (isShowSql())
> /*     */     {
> /*  79 */       jpaProperties.setProperty("openjpa.Log",
> "DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE");
> /*     */     }
>
> So, I decided to set an initial "benign" value for "openjpa.Log"
> explicitly (similar to this code block).  Now I'm back to not getting
> the error.  I presently don't have a log4j appender that matches
> openjpa, and my "openjpa.Log" isn't set to "log4j".  it appears that any
> logging strategy I use that results in either no value being set for
> "openjpa.Log" or a value of "log4j", gives me that "javaagent"
> exception.
>
> I am mystified.
>

RE: Changing to use log4j logging causes error about missing Java agent

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Michael Dick [mailto:michael.d.dick@gmail.com]
> Sent: Monday, February 01, 2010 8:59 AM
> To: users@openjpa.apache.org
> Subject: Re: Changing to use log4j logging causes error about missing
> Java agent
> 
> Hi David,
> 
> I'm sure some Spring users monitor this email list, but you might get
> better
> hits on one of the Spring centric lists. It looks like the error
> originates
> in Spring, not OpenJPA.
> 
> It's worth checking your compiled classes to make sure they're
enhanced
> though. Do you have any simple junit style tests (no Spring involved)
> that
> use the entities? If you have runtimeUnenhancedClasses=unsupported and
> the
> entities work in junit then you know they've been enhanced correctly
at
> build time.
> 
> If they aren't enhanced maybe running the enhancer (again?) will help
> with
> the loadtime agent issue..

I have "openjpa.RuntimeUnenhancedClasses" set to "unsupported", so I
wouldn't get anywhere if build-time enhancement didn't work.  The
application and my unit tests works fine until I try to use log4j
logging with OpenJPA (other parts of the application are using log4J
with no trouble), and then the OpenJPA interface in Spring complains
about not having a Java agent.

I've posted a note about this on one of the Spring forums.  Perhaps
someone there will have an idea.

> On Sun, Jan 31, 2010 at 3:49 PM, KARR, DAVID (ATTCINW)
> <dk...@att.com>wrote:
> 
> > > -----Original Message-----
> > > From: KARR, DAVID (ATTCINW)
> > > Sent: Sunday, January 31, 2010 12:30 PM
> > > To: users@openjpa.apache.org
> > > Subject: RE: Changing to use log4j logging causes error about
> missing
> > > Java agent
> > >
> > > > -----Original Message-----
> > > > From: KARR, DAVID (ATTCINW)
> > > > Sent: Sunday, January 31, 2010 12:17 PM
> > > > To: users@openjpa.apache.org
> > > > Subject: Changing to use log4j logging causes error about
missing
> > > Java
> > > > agent
> > > >
> > > > I've been working ok with my OpenJPA 1.2.2 app for a while.  I'm
> > > using
> > > > build-time enhancement, and "openjpa.RuntimeUnenhancedClasses"
is
> > set
> > > > to
> > > > "unsupported".  I had my "openjpa.Log" property set with the
> "basic"
> > > > strategy, not using log4j or commons-logging.  It was working
> fine.
> > > I
> > > > then decided since I was using log4j with other components, I
> wanted
> > > > openjpa to use that also.  I changed the value to "log4j", then
> > added
> > > a
> > > > "logger" element in my log4j.xml for openjpa.  I started up the
> > > server,
> > > > and got the exception that follows this.
> > > >
> > > > I don't see why it suddenly thinks I need to use a -javaagent.
> I'd
> > > > prefer not to do this.  I certainly don't need "load-time class
> > > > transformation", if that's what the build-time enhancer does.
> > >
> > > Additional information:
> > >
> > > It appears it isn't just happening when I try to use log4j.  If I
> have
> > > any "openjpa.Log" setting that enables logging, I get this error.
> If
> > I
> > > turn off logging completely, the app starts up and works fine.
> > >
> > > I had logging on all the time when I was developing the app with
> > > OpenJPA
> > > 1.2.1.  I recently upgraded to 1.2.2, and about that time I turned
> off
> > > logging.  It seems like now that I'm using 1.2.2, I'm getting this
> new
> > > error if I try to use logging.
> >
> > I just tried backing up to 1.2.1, and I'm still getting the error.
> >
> > After I went back to 1.2.2, I managed to find a very trivial change
> that
> > causes the error to occur.  Changing it back makes it stop.  The
> change
> > appears to have something to do with the interaction with Spring,
but
> > it's part of the OpenJPA integration with it.
> >
> > I have the following bean defined in my Spring context:
> >
> >    <bean id="catalogEntityManagerFactory"
> >
> >
>
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBe
> a
> > n"
> >          p:dataSource-ref="catalogDataSource">
> >        <property name="loadTimeWeaver">
> >            <bean
> >
>
class="org.springframework.instrument.classloading.InstrumentationLoadT
> i
> > meWeaver" />
> >        </property>
> >        <property name="jpaVendorAdapter">
> >            <bean
> > class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
> >                  p:showSql="${jpa.showSql}"/>
> >        </property>
> >    </bean>
> >
> > In my properties file, I have a property setting for "jpa.showSql".
> In
> > the current state of the application, if I have that property set to
> > "true" in the properties file, the application deploys and runs
fine,
> > and is showing the SQL output.
> >
> > If I instead set that property to "false", I get the "javaagent"
> > exception at load time.
> >
> > I currently have no explicit setting for "openjpa.Log".
> >
> > I noticed the following block of code in "OpenJpaVendorAdapter":
> >
> > /*  77 */     if (isShowSql())
> > /*     */     {
> > /*  79 */       jpaProperties.setProperty("openjpa.Log",
> > "DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE");
> > /*     */     }
> >
> > So, I decided to set an initial "benign" value for "openjpa.Log"
> > explicitly (similar to this code block).  Now I'm back to not
getting
> > the error.  I presently don't have a log4j appender that matches
> > openjpa, and my "openjpa.Log" isn't set to "log4j".  it appears that
> any
> > logging strategy I use that results in either no value being set for
> > "openjpa.Log" or a value of "log4j", gives me that "javaagent"
> > exception.
> >
> > I am mystified.
> >