Hi Gopi,

On Mon, Oct 26, 2009 at 6:10 PM, Gopi <[email protected]> wrote:

>
> > o  The @ManagedInterface "instances" are created by the runtime when you
> > call createInstance(c).  You should not be defining a separate @Entity
> > class.  This is like doubly defining your object model.
> >
> >
>
> Ok. I removed the @Entity from the class. So now in my persistence.xml,
> instead of <class>EndpointObject</class>, I now have
> <class>Endpoint</class>. Is this right?
>
> Yes, that's what I would expect.


>
> > o  To that end, your @GeneratedValue should be moved from your Entity
> > class
> > to your ManagedInterface interface.
> >
> >
> Ok. Done.
>
> Good.


> > o  And, it looks like you are doing a lot of extra processing with
> > registration with the MetaDataRepository and ClassMetaData.  You should
> > not
> > have to mess around with these data structures.  After creating the
> > instance
> > and persisting it, the OpenJPA runtime should take care of the
> > registration.
> >
> >
>
> The reason I am doing the extra processing is because, if I don't, I get
> the
> following error message. I found a solution to this in this forum at
>
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
>
>  [java] java.lang.IllegalArgumentException: No metadata was found for
> managed interface Endpoint.
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
>     [java]     at
>
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
>     [java]     at
>
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
>     [java]     at Main.main(Main.java:36)
>
> So how else do I get rid of this error message?
>

According to that post, this extra processing should not be necessary if you
have included the ManagedInterface "entity" in the <class> element of
persistence.xml.  So, even with the changes you did above, you are still
getting this exception?

>From Pinaki's response...
     "The metadata registration and classloading done in your code for
managed interface *should* not be required if you specify the class name in
<class> clause of persistence.xml. But please report if that is not the
case."


>
> > o  One additional thought is how are you performing the enhancement
> > processing [2]?  To be honest, I'm not entirely clear on how the
> > @ManagedInterface instance creation integrates with our enhancement
> > processing.  Maybe another developer can shed some light on this aspect.
> >
> >
>
> I am doing this by passing an arg to the jvm as follows in my build.xml
> file.
>
> <target name="Main">
>                <java classname="Main" failonerror="true" fork="yes">
>                        <jvmarg
> value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar" />
>                        <classpath refid="TestJPA1.classpath" />
>                </java>
> </target>
>

If you are only using @ManagedInterfaces and no other @Entities, then this
should not even be required.  Pinaki's other reply on this thread has
indicated that due to the generated byte-codes that we do for the
@ManagedInterface instance creation, all of the enhancement processing is
already done.  But, if you have other @Entities, then the use of the
-javaagent is an easy way to get your Entities enhanced.

Kevin


> --
> View this message in context:
> http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Reply via email to