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 <[email protected]> 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.mess...@1094d48" to PersistenceCapable failed. Ensure
> that it has been enhanced.
> FailedObject: hellojpa.mess...@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
>