openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Problem build and run hellojpa using Maven
Date Thu, 22 Apr 2010 16:09:25 GMT
Hi Hez,

It looks like the entities haven't been enhanced. The ant script does this
by specifying a javaagent when it runs hellojpa.Main. I'm not familiar with
the maven exec plugin but it looks like adding the -javaagent argument is
what you need :

      <argument>-javaagent:${path.to.openjpa.jar}</argument>

FWIW the ant script obtains the path to openjpa.jar like this :

    <path id="javaagent">
        <fileset dir="${root}">
            <include name="openjpa-*.jar"/>
        </fileset>
    </path>
    <pathconvert property="javaagent" refid="javaagent"/>

hth,
-mike

On Thu, Apr 22, 2010 at 9:45 AM, hezjing <hezjing@gmail.com> wrote:

> Hi
>
> I have successfully ran the hellojpa sample as described in the getting
> started with Netbeans and Ant.
>
> Now, I'm trying to build and run the same sample using Maven.
>
> When the goal exec:exec is executed, the following ArgumentException is
> thrown:
>
> 0  WARN   [main] openjpa.Runtime - The configuration property named
> "openjpa.Id" was not recognized and will be ignored, although the name
> closely matches a valid property called "openjpa.Id".
> Exception in thread "main" <openjpa-1.2.2-r422266:898935 nonfatal user
> error> org.apache.openjpa.persistence.ArgumentException: Attempt to cast
> instance "hellojpa.Message@1094d48" to PersistenceCapable failed.  Ensure
> that it has been enhanced.
> FailedObject: hellojpa.Message@1094d48
>        at
>
> org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4377)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2443)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2304)
>        at
>
> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1021)
>        at
>
> org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:645)
>        at hellojpa.Main.main(Main.java:54)
>
>
> Here are the snippets of my pom.xml:
>
> <dependency>
>    <groupId>org.apache.openjpa</groupId>
>    <artifactId>openjpa</artifactId>
>    <version>1.2.2</version>
>    <scope>compile</scope>
> </dependency>
> <dependency>
>    <groupId>org.apache.derby</groupId>
>    <artifactId>derby</artifactId>
>    <version>10.5.3.0</version>
> </dependency>
> <plugin>
>    <groupId>org.codehaus.mojo</groupId>
>    <artifactId>exec-maven-plugin</artifactId>
>    <version>1.1.1</version>
>    <configuration>
>        <executable>java</executable>
>        <arguments>
>
>
>  <argument>-Dopenjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver</argument>
>
>
>  <argument>-Dopenjpa.ConnectionURL=jdbc:derby:openjpa-database;create=true</argument>
>            <argument>-Dopenjpa.ConnectionUserName=</argument>
>            <argument>-Dopenjpa.ConnectionPassword=</argument>
>
>  <argument>-Dopenjpa.jdbc.SynchronizeMappings=buildSchema</argument>
>            <argument>-Dopenjpa.Log=DefaultLevel=WARN,SQL=TRACE</argument>
>            <argument>-classpath</argument>
>            <classpath/>
>            <argument>hellojpa.Main</argument>
>        </arguments>
>    </configuration>
> </plugin>
>
>
> Do you have any idea of what could be the problem?
>
>
> --
>
> Hez
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message