You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by hezjing <he...@gmail.com> on 2010/04/22 16:45:32 UTC

Problem build and run hellojpa using Maven

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

Re: Problem build and run hellojpa using Maven

Posted by Craig L Russell <cr...@oracle.com>.
Hi Chris,

If you want this fixed, please file a JIRA with a reproducible test  
case. The message should be useful and it's not. This is a usability  
issue that should be fixed. You can even fix it yourself and help  
everyone.

Thanks,

Craig

On Apr 22, 2010, at 8:15 AM, C N Davies wrote:

> Did you add the Message class to your persistence.xml?
>
> I just love OpenJPA error messages, about as useful as tits on a bull:
>
> "..The configuration property named "openjpa.Id" was not recognized  
> and will be ignored, although the name
> closely matches a valid property called "openjpa.Id" ..."
>
> Looks like the same spelling and capitalisation to me, who the hell  
> writes these messages? The only useful word in this message is "error"
>
> Chris
>
>
>
>
>
> -----Original Message-----
> From: hezjing [mailto:hezjing@gmail.com]
> Sent: Friday, 23 April 2010 12:46 AM
> To: users@openjpa.apache.org
> Subject: Problem build and run hellojpa using Maven
>
> 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
>

Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!


RE: Problem build and run hellojpa using Maven

Posted by C N Davies <cn...@cndavies.com>.
Did you add the Message class to your persistence.xml?

I just love OpenJPA error messages, about as useful as tits on a bull:

"..The configuration property named "openjpa.Id" was not recognized and will be ignored, although the name
closely matches a valid property called "openjpa.Id" ..."

Looks like the same spelling and capitalisation to me, who the hell writes these messages? The only useful word in this message is "error"

Chris





-----Original Message-----
From: hezjing [mailto:hezjing@gmail.com] 
Sent: Friday, 23 April 2010 12:46 AM
To: users@openjpa.apache.org
Subject: Problem build and run hellojpa using Maven

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


Re: Problem build and run hellojpa using Maven

Posted by Michael Dick <mi...@gmail.com>.
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 <he...@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
>