Well, the short story is that if you comment out the load-time weaver
declaration in your applicationContext.xml, the problem goes away.

When the load-time weaver is specified, I believe that the problem is
caused by the fact that your main class also is your Spring bean. When
the load-time weaver is specified, Spring does a bunch of classloader
/ proxy magic to attempt to put the Spring beans and persistent types
into a separate classloader, so that AOP and JPA weaving can happen.
However, in this situation, since your code is statically referencing
the persistent types as well, the classloaders seem to be conflicting
with each other.

Since you aren't using AOP features of Spring and you've manually
enhanced your persistent types, the load-time weaver is not necessary.

Surprisingly, even if I separate your Main class into a class to run
the program and a separate bean + interface, the problem still
happens.

-Patrick

On 8/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Yep, it's some sort of a classloader issue. Somehow, PersitenceCapable
> is available in two different classloaders. I'll know more later today
> / tomorrow.
>
> -Patrick
>
> On 8/30/07, ben short <[EMAIL PROTECTED]> wrote:
> > My test apps not rocket science so feel free to make a test case for
> > it. But could you alter the packages names please.
> >
> > On a site note, is it possible that the releases could make there way
> > into the main maven 2 repositories? The how to docs can be found here
> > [1] although you might allready know that.
> >
> > Regards
> >
> > Ben Short
> >
> > [1] http://maven.apache.org/guides/mini/guide-central-repository-upload.html
> >
> > On 8/29/07, Patrick Linskey <[EMAIL PROTECTED]> wrote:
> > > > Setting openjpa.RuntimeUnenhancedClasses=2 allows the application to
> > > > run.
> > >
> > > Cool; FTR, 2 corresponds to the 'warn' setting. Sorry about the
> > > incorrect setting earlier.
> > >
> > > > If i change it to the following and comment out the work around
> > > > openjpa.RuntimeUnenhancedClasses then the application complains that i
> > > > need an agent but still runs as the classes are already enhanced.
> > >
> > > In fact, I added the RuntimeUnenhancedClasses property because of a
> > > similar problem that was reported last week that we couldn't narrow
> > > down in time for the release. Hopefully, with the help of your test
> > > project (I got it; thanks!), we can get this resolved properly.
> > >
> > > > I emailed you directly with my test app..
> > >
> > > Do you want me to keep the test app private, or can I create and check
> > > in a test case from it?
> > >
> > > -Patrick
> > >
> > > On 8/29/07, ben short <[EMAIL PROTECTED]> wrote:
> > > > Setting openjpa.RuntimeUnenhancedClasses=2 allows the application to
> > > > run. I'm using spring with the following loadTimeWeaver on my
> > > > entityManagerFactory...
> > > >
> > > > org.springframework.instrument.classloading.SimpleLoadTimeWeaver
> > > >
> > > > If i change it to the following and comment out the work around
> > > > openjpa.RuntimeUnenhancedClasses then the application complains that i
> > > > need an agent but still runs as the classes are already enhanced.
> > > >
> > > >
> > org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver
> > > >
> > > > I emailed you directly with my test app..
> > > >
> > > > Regards
> > > >
> > > > Ben
> > > >
> > > >
> > > > On 8/29/07, Patrick Linskey <[EMAIL PROTECTED]> wrote:
> > > > > > I download the 1.0.0 source and ran mvn install. It built and
> > > > > > installed ok. I use either the maven enhance plugin or the ant task
> > to
> > > > > > enhance the classes. When I run my simple test app I get the
> > following
> > > > > > exception...
> > > > >
> > > > > Is there any way we could get access to that test application? I kinda
> > > > > suspect some sort of classloader issue, as I can't see how the
> > > > > isManagedType() call would otherwise fail.
> > > > >
> > > > > Also, can you work around it by setting the
> > > > > openjpa.RuntimeUnenhancedClasses property to 'disabled'?
> > > > >
> > > > > > Also i think the following ddl is incorrect..
> > > > > >
> > > > > > CREATE TABLE AttributeAndValue (id INTEGER NOT NULL IDENTITY,
> > > > > > mAttribute VARCHAR(255), mValue VARCHAR(255), version INTEGER,
> > > > > > mProductInstance_id INTEGER, UNIQUE (mValue))
> > > > > >
> > > > > > this is the @Table annotation used on the AttributeAndValue class.
> > > > > >
> > > > > > @Table([EMAIL PROTECTED](columnNames={
> > > > > > "mProductInstance, mAttribute", "mValue"}))
> > > > >
> > > > > IIRC, OpenJPA does not currently support multi-column unique
> > > > > constraints. I think that there is work in progress to resolve this,
> > > > > though.
> > > > >
> > > > > -Patrick
> > > > >
> > > > > On 8/29/07, ben short <[EMAIL PROTECTED]> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I download the 1.0.0 source and ran mvn install. It built and
> > > > > > installed ok. I use either the maven enhance plugin or the ant task
> > to
> > > > > > enhance the classes. When I run my simple test app I get the
> > following
> > > > > > exception...
> > > > > >
> > > > > > 32  openjpa  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.0.0
> > > > > > 438  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 7143488> executing prepstmnt 25621063 SELECT SEQUENCE_SCHEMA,
> > > > > > SEQUENCE_NAME FROM INFORMATION_SCHEMA.SYSTEM_SEQUENCES
> > > > > > 438  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 7143488> [0 ms] spent
> > > > > > 438  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 5285449> executing stmnt 6109469 CREATE TABLE AttributeAndValue (id
> > > > > > INTEGER NOT NULL IDENTITY, mAttribute VARCHAR(255), mValue
> > > > > > VARCHAR(255), version INTEGER, mProductInstance_id INTEGER, UNIQUE
> > > > > > (mValue))
> > > > > > 438  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 5285449> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 1067475> executing stmnt 33189144 CREATE TABLE Product (id INTEGER
> > NOT
> > > > > > NULL IDENTITY, version INTEGER)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 1067475> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 9716945> executing stmnt 21658130 CREATE TABLE ProductInstance (id
> > > > > > INTEGER NOT NULL IDENTITY, version INTEGER)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 9716945> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 32486590> executing stmnt 2830910 CREATE TABLE
> > Product_ProductInstance
> > > > > > (Product_id INTEGER, mProductInstances_id INTEGER)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 32486590> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 7858936> executing stmnt 30983464 CREATE INDEX
> > > > > > I_TTRBDVL_MPRODUCTINSTANCE ON AttributeAndValue
> > (mProductInstance_id)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 7858936> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 10127976> executing stmnt 14900151 CREATE INDEX I_PRDCTNC_ELEMENT ON
> > > > > > Product_ProductInstance (mProductInstances_id)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 10127976> [0 ms] spent
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 17010151> executing stmnt 32826737 CREATE INDEX I_PRDCTNC_PRODUCT_ID
> > > > > > ON Product_ProductInstance (Product_id)
> > > > > > 454  openjpa  TRACE  [main] openjpa.jdbc.SQL - <t 9194103, conn
> > > > > > 17010151> [0 ms] spent
> > > > > > Exception in thread "main" <openjpa-1.0.0-rType 'svnversion --help'
> > > > > > for usage. fatal user error>
> > > > > > org.apache.openjpa.persistence.ArgumentException: The type "class
> > > > > > com.daisytechnologies.jpatest.ProductInstance" has not been
> > enhanced.
> > > > > >         at
> > org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1631)
> > > > > >         at
> > org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1605)
> > > > > >         at
> > org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:675)
> > > > > >         at
> > org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:575)
> > > > > >         at
> > org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:500)
> > > > > >         at
> > org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:302)
> > > > > >         at
> > org.apache.openjpa.enhance.ManagedClassSubclasser.setIntercepting(ManagedClassSubclasser.java:264)
> > > > > >         at
> > org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:157)
> > > > > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > > > > >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > >         at
> > org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:287)
> > > > > >         at
> > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:197)
> > > > > >         at
> > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> > > > > >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> > > > > >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
> > > > > >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
> > > > > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > > > > >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > >         at
> > org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:375)
> > > > > >         at $Proxy0.createEntityManager(Unknown Source)
> > > > > >         at com.daisytechnologies.jpatest.Main.insert(Main.java:45)
> > > > > >         at com.daisytechnologies.jpatest.Main.main(Main.java:39)
> > > > > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > > > > >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > >         at
> > com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> > > > > >
> > > > > > But if i use the 0.9.8-SNAPSHOT version without recompiling or
> > > > > > enhancing the classes it works OK.
> > > > > >
> > > > > > The same issue occurred with a postgres setup.
> > > > > >
> > > > > > Also i think the following ddl is incorrect..
> > > > > >
> > > > > > CREATE TABLE AttributeAndValue (id INTEGER NOT NULL IDENTITY,
> > > > > > mAttribute VARCHAR(255), mValue VARCHAR(255), version INTEGER,
> > > > > > mProductInstance_id INTEGER, UNIQUE (mValue))
> > > > > >
> > > > > > this is the @Table annotation used on the AttributeAndValue class.
> > > > > >
> > > > > > @Table([EMAIL PROTECTED](columnNames={
> > > > > > "mProductInstance, mAttribute", "mValue"}))
> > > > > >
> > > > > > Ben
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Patrick Linskey
> > > > > 202 669 5907
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Patrick Linskey
> > > 202 669 5907
> > >
> >
>
>
> --
> Patrick Linskey
> 202 669 5907
>


-- 
Patrick Linskey
202 669 5907

Reply via email to