You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Lars Vogel <la...@googlemail.com> on 2008/03/30 20:29:32 UTC

Could not locate metadata (orm.xml)

Hi,

Can anyone point me to a working standalone example there a a orm.xml file
is used instead of Annotations?

I'm able to build a small example with annotations but if I try the same
with orm.xml I receive the following error:

Exception in thread "main" <openjpa-1.0.2-r420667:627158 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
for the class using alias "MYAPPLICATION.PEOPLETABLE". This could mean that
the OpenJPA enhancer or load-time weaver was not run on the type whose alias
is "MYAPPLICATION.PEOPLETABLE". Registered alias mappings: "{
MYAPPLICATION.PEOPLETABLE=null, Person=[class datamodel.Person]}"


I have the following orm.xml

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
    version="1.0">
    <entity class="datamodel.Person">
      <table name="MYAPPLICATION.PEOPLETABLE"/>
        <attributes>
            <id name="id" />
            <basic name="firstName" />
            <basic name="lastName" />
            <transient name="nonsenseField" />
        </attributes>
    </entity>
</entity-mappings>

I have the following persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">

    <!--
        A persistence unit is a set of listed persistent entities as well
        the configuration of an EntityManagerFactory. We configure each
        example in a separate persistence-unit.
    -->
    <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">

        <!--
            The default provider can be OpenJPA, or some other product.
            This element is optional if OpenJPA is the only JPA provider
            in the current classloading environment, but can be specified
            in cases where there are multiple JPA implementations available.
        -->

        <provider>
            org.apache.openjpa.persistence.PersistenceProviderImpl
        </provider>
        <mapping-file>META-INF/orm.xml</mapping-file>

        <!-- We must enumerate each entity in the persistence unit -->
        <class>datamodel.Person</class>

        <properties>
            <property name="openjpa.ConnectionURL"

value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
            <property name="openjpa.ConnectionDriverName"
                value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="openjpa.ConnectionUserName" value="" />
            <property name="openjpa.ConnectionPassword" value="" />

            <!--
                Tell OpenJPA to automatically create tables in the database
                for entities. Note that this should be disabled when
                running against a production database, since you probably
                don't want to be altering the schema at runtime.
            -->
            <property name="openjpa.jdbc.SynchronizeMappings"
                value="buildSchema" />

        </properties>
    </persistence-unit>

</persistence>


Best regards, Lars

Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hi Fay,

yes both are in the same directory. I tried with and without mapping entry
in persistence. For reference I attached the content of my source directory.
It is a very tiny example

If someone wants to test this, please run Main.java.

Best regards, Lars


2008/3/31, Fay Wang <fy...@yahoo.com>:
>
> Hi Lars,
>     I ran your example as a standalone one. and the PCEnhancer works for
> me.  Here is my persistence.xml:
>
>     <persistence-unit name="person">
>       <provider>com.ibm.websphere.persistence.PersistenceProviderImpl
> </provider>
>       <mapping-file>META-INF/orm.xml</mapping-file>
>       <class>datamodel.Person</class>
>       <properties>
>         <property name="openjpa.jdbc.DBDictionary" value=""/>
> ...
>
>
> and my orm.xml:
> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="
> http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
>     version="1.0">
>     <entity class="datamodel.Person">
>       <table name="MYAPPLICATION.PEOPLETABLE"/>
>         <attributes>
>             <id name="id" />
>             <basic name="firstName" />
>             <basic name="lastName" />
>             <transient name="nonsenseField" />
>         </attributes>
>     </entity>
> </entity-mappings>
>
> They are almost identical as yours. Did you put your orm.xml in the same
> directory as your persistence.xml?
>
> Fay
>
>
>
> --- On *Mon, 3/31/08, Lars Vogel <la...@googlemail.com>* wrote:
>
> From: Lars Vogel <la...@googlemail.com>
> Subject: Re: Could not locate metadata (orm.xml)
> To: users@openjpa.apache.org
> Date: Monday, March 31, 2008, 9:46 AM
>
> Hi Fay,
>
> I don't get the meaining of your comment. Are you saying my example works
> for you? Are you running it standalone or inside a web container? Best
> regards, Lars
>
> 2008/3/31, Lars Vogel <la...@googlemail.com>:
> >
> > Hi Adam,
> >
> > thank you. If I remove the <mapping-file> I still get the same
> error. I
> > change the header to your header but still no difference. I paste the new
> > version of my files below.
> >
> > Both orm.xml and persistence.xml are in the same directory META-INF.
> >
> >
>  Any further advice?
> > --------------
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <entity-mappings
> xmlns="http://java.sun.com/xml/ns/persistence/orm"
> >   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
> > http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
> >   version="1.0">
> >     <entity class="datamodel.Person">
> >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> >         <attributes>
> >             <id name="id" />
> >             <basic name="firstName" />
> >             <basic name="lastName" />
> >             <transient name="nonsenseField" />
> >         </attributes>
> >     </entity>
> > </entity-mappings>
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > ---------------
> >
>  <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> version="1.0">
> >
> >     <persistence-unit name="people"
> transaction-type="RESOURCE_LOCAL">
> >
> >         <provider>
> >             org.apache.openjpa.persistence.PersistenceProviderImpl
> >         </provider>
> >         <mapping-file>META-INF/orm.xml</mapping-file>
> >
> >         <!-- We must enumerate each entity in the persistence unit
> -->
> >         <class>datamodel.Person</class>
> >
> >         <properties>
> >             <property name="openjpa.ConnectionURL"
> >
> >
> value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true"
> />
> >             <property name="openjpa.ConnectionDriverName"
> >
>  value="org.apache.derby.jdbc.EmbeddedDriver"
> />
> >             <property name="openjpa.ConnectionUserName"
> value="" />
> >             <property name="openjpa.ConnectionPassword"
> value="" />
> >
> >             <!--
> >                 Automatically create tables in the database
> >                 for entities. Not for production use
> >                 -->
> >             <property name="openjpa.jdbc.SynchronizeMappings"
> >                 value="buildSchema" />
> >
> >         </properties>
> >     </persistence-unit>
> >
> > </persistence>
> >
> >
> >
> >
> > Best regards, Lars
> >
> >
> > 2008/3/31, Adam Hardy <ad...@cyberspaceroad.org>:
> > >
> > > Hi Lars,
> > >
> > > that is a weird error that I haven't seen before - it looks like
> OpenJPA
> > > is
> >
>  > confusing the table name with the class name.
> > >
> > > In case it helps, you don't need to reference the orm.xml in the
> > > persistence.xml. Not sure if it's a problem when you do, try
> without.
> > >
> > > orm.xml looks like it's in the same directory as persistence.xml
> from
> > > your
> > > email. perhaps you should double-check.
> > >
> > > my orm.xml header is slightly different:
> > >
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > >
> > > <entity-mappings
> xmlns="http://java.sun.com/xml/ns/persistence/orm"
> > >    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
> > >
> > > http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
> > >    version="1.0">
> > >
> > > I do not run the OpenJPA
>  enhancer and you shouldn't need to, but
> I am
> > > using the
> > > OpenJPA v1.1.0 snapshot, not 1.0.x.
> > >
> > >
> > >
> > >
> > >
> > > Lars Vogel on 30/03/08 19:29, wrote:
> > > > Hi,
> > > >
> > > > Can anyone point me to a working standalone example there a a
> orm.xmlfile
> > > > is used instead of Annotations?
> > > >
> > > > I'm able to build a small example with annotations but if I
> try the
> > > same
> > > > with orm.xml I receive the following error:
> > > >
> > > > Exception in thread "main"
> <openjpa-1.0.2-r420667:627158 fatal user
> > > error>
> > > > org.apache.openjpa.persistence.ArgumentException: Could not
> locate
> > > metadata
> > > > for the class using alias "MYAPPLICATION.PEOPLETABLE".
> This could mean
> > > that
> >
>  > > the OpenJPA enhancer or load-time weaver was not run on the type
> whose
> > > alias
> > > > is "MYAPPLICATION.PEOPLETABLE". Registered alias
> mappings: "{
> > > > MYAPPLICATION.PEOPLETABLE=null, Person=[class
> datamodel.Person]}"
> > > >
> > > >
> > > > I have the following orm.xml
> > > >
> > > > <entity-mappings
> xmlns="http://java.sun.com/xml/ns/persistence/orm"
> > > >
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >
> > > >     xsi:schemaLocation="
> > > http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
> > >
> > > >     version="1.0">
> > > >     <entity class="datamodel.Person">
> > > >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> > > >         <attributes>
> > > >             <id name="id" />
> > >
>  >             <basic name="firstName" />
> > > >             <basic name="lastName" />
> > > >             <transient name="nonsenseField" />
> > > >         </attributes>
> > > >     </entity>
> > > > </entity-mappings>
> > > >
> > > > I have the following persistence.xml
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <!--
> > > >     Licensed to the Apache Software Foundation (ASF) under one
> > > >     or more contributor license agreements.  See the NOTICE file
> > > >     distributed with this work for additional information
> > > >     regarding copyright ownership.  The ASF licenses this file
> > > >     to you under the Apache License, Version 2.0 (the
> > > >     "License"); you may not use this file except
>  in
> compliance
> > > >     with the License.  You may obtain a copy of the License at
> > > >
> > > >     http://www.apache.org/licenses/LICENSE-2.0
> > > >
> > > >     Unless required by applicable law or agreed to in writing,
> > > >     software distributed under the License is distributed on an
> > > >     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
> ANY
> > > >     KIND, either express or implied.  See the License for the
> > > >     specific language governing permissions and limitations
> > > >     under the License.
> > > > -->
> > > > <persistence
> xmlns="http://java.sun.com/xml/ns/persistence"
> > > >
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> version="1.0
> > > ">
> > > >
> > > >     <!--
> > > >         A persistence unit is a set
>  of listed persistent
> entities as
> > > well
> > > >         the configuration of an EntityManagerFactory. We
> configure
> > > each
> > > >         example in a separate persistence-unit.
> > > >     -->
> > > >     <persistence-unit name="people"
> transaction-type="RESOURCE_LOCAL">
> > > >
> > > >         <!--
> > > >             The default provider can be OpenJPA, or some other
> > > product.
> > > >             This element is optional if OpenJPA is the only JPA
> > > provider
> > > >             in the current classloading environment, but can be
> > > specified
> > > >             in cases where there are multiple JPA
> implementations
> > > available.
> > > >         -->
> > > >
> > > >         <provider>
> > > >
>
> org.apache.openjpa.persistence.PersistenceProviderImpl
> > > >         </provider>
> > > >
> <mapping-file>META-INF/orm.xml</mapping-file>
> > > >
> > > >         <!-- We must enumerate each entity in the persistence
> unit -->
> > > >         <class>datamodel.Person</class>
> > > >
> > > >         <properties>
> > > >             <property name="openjpa.ConnectionURL"
> > > >
> > > >
> value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true"
> />
> > > >             <property
> name="openjpa.ConnectionDriverName"
> > > >
> value="org.apache.derby.jdbc.EmbeddedDriver" />
> > > >             <property
> name="openjpa.ConnectionUserName" value="" />
> > > >
>  <property
> name="openjpa.ConnectionPassword" value="" />
> > > >
> > > >             <!--
> > > >                 Tell OpenJPA to automatically create tables in
> the
> > > database
> > > >                 for entities. Note that this should be disabled
> when
> > > >                 running against a production database, since you
> > > probably
> > > >                 don't want to be altering the schema at
> runtime.
> > > >             -->
> > > >             <property
> name="openjpa.jdbc.SynchronizeMappings"
> > > >                 value="buildSchema" />
> > > >
> > > >         </properties>
> > > >     </persistence-unit>
> > > >
> > > > </persistence>
> > >
> > >
> >
>
>
> ------------------------------
> Like movies? Here's a limited-time offer: Blockbuster Total Access<http://us.rd.yahoo.com/evt=47522/*http://tc.deals.yahoo.com/tc/blockbuster/text4.com>for one month at no cost.

Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hi Fay,

I don't get the meaining of your comment. Are you saying my example works
for you? Are you running it standalone or inside a web container? Best
regards, Lars

2008/3/31, Lars Vogel <la...@googlemail.com>:
>
> Hi Adam,
>
> thank you. If I remove the <mapping-file> I still get the same error. I
> change the header to your header but still no difference. I paste the new
> version of my files below.
>
> Both orm.xml and persistence.xml are in the same directory META-INF.
>
> Any further advice?
> --------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
> http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
>   version="1.0">
>     <entity class="datamodel.Person">
>       <table name="MYAPPLICATION.PEOPLETABLE"/>
>         <attributes>
>             <id name="id" />
>             <basic name="firstName" />
>             <basic name="lastName" />
>             <transient name="nonsenseField" />
>         </attributes>
>     </entity>
> </entity-mappings>
>
> <?xml version="1.0" encoding="UTF-8"?>
> ---------------
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
>
>     <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">
>
>         <provider>
>             org.apache.openjpa.persistence.PersistenceProviderImpl
>         </provider>
>         <mapping-file>META-INF/orm.xml</mapping-file>
>
>         <!-- We must enumerate each entity in the persistence unit -->
>         <class>datamodel.Person</class>
>
>         <properties>
>             <property name="openjpa.ConnectionURL"
>
> value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
>             <property name="openjpa.ConnectionDriverName"
>                 value="org.apache.derby.jdbc.EmbeddedDriver" />
>             <property name="openjpa.ConnectionUserName" value="" />
>             <property name="openjpa.ConnectionPassword" value="" />
>
>             <!--
>                 Automatically create tables in the database
>                 for entities. Not for production use
>                 -->
>             <property name="openjpa.jdbc.SynchronizeMappings"
>                 value="buildSchema" />
>
>         </properties>
>     </persistence-unit>
>
> </persistence>
>
>
>
>
> Best regards, Lars
>
>
> 2008/3/31, Adam Hardy <ad...@cyberspaceroad.org>:
> >
> > Hi Lars,
> >
> > that is a weird error that I haven't seen before - it looks like OpenJPA
> > is
> > confusing the table name with the class name.
> >
> > In case it helps, you don't need to reference the orm.xml in the
> > persistence.xml. Not sure if it's a problem when you do, try without.
> >
> > orm.xml looks like it's in the same directory as persistence.xml from
> > your
> > email. perhaps you should double-check.
> >
> > my orm.xml header is slightly different:
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
> >    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
> >
> > http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
> >    version="1.0">
> >
> > I do not run the OpenJPA enhancer and you shouldn't need to, but I am
> > using the
> > OpenJPA v1.1.0 snapshot, not 1.0.x.
> >
> >
> >
> >
> >
> > Lars Vogel on 30/03/08 19:29, wrote:
> > > Hi,
> > >
> > > Can anyone point me to a working standalone example there a a orm.xmlfile
> > > is used instead of Annotations?
> > >
> > > I'm able to build a small example with annotations but if I try the
> > same
> > > with orm.xml I receive the following error:
> > >
> > > Exception in thread "main" <openjpa-1.0.2-r420667:627158 fatal user
> > error>
> > > org.apache.openjpa.persistence.ArgumentException: Could not locate
> > metadata
> > > for the class using alias "MYAPPLICATION.PEOPLETABLE". This could mean
> > that
> > > the OpenJPA enhancer or load-time weaver was not run on the type whose
> > alias
> > > is "MYAPPLICATION.PEOPLETABLE". Registered alias mappings: "{
> > > MYAPPLICATION.PEOPLETABLE=null, Person=[class datamodel.Person]}"
> > >
> > >
> > > I have the following orm.xml
> > >
> > > <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
> > >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >
> > >     xsi:schemaLocation="
> > http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
> >
> > >     version="1.0">
> > >     <entity class="datamodel.Person">
> > >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> > >         <attributes>
> > >             <id name="id" />
> > >             <basic name="firstName" />
> > >             <basic name="lastName" />
> > >             <transient name="nonsenseField" />
> > >         </attributes>
> > >     </entity>
> > > </entity-mappings>
> > >
> > > I have the following persistence.xml
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!--
> > >     Licensed to the Apache Software Foundation (ASF) under one
> > >     or more contributor license agreements.  See the NOTICE file
> > >     distributed with this work for additional information
> > >     regarding copyright ownership.  The ASF licenses this file
> > >     to you under the Apache License, Version 2.0 (the
> > >     "License"); you may not use this file except in compliance
> > >     with the License.  You may obtain a copy of the License at
> > >
> > >     http://www.apache.org/licenses/LICENSE-2.0
> > >
> > >     Unless required by applicable law or agreed to in writing,
> > >     software distributed under the License is distributed on an
> > >     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > >     KIND, either express or implied.  See the License for the
> > >     specific language governing permissions and limitations
> > >     under the License.
> > > -->
> > > <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> > >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0
> > ">
> > >
> > >     <!--
> > >         A persistence unit is a set of listed persistent entities as
> > well
> > >         the configuration of an EntityManagerFactory. We configure
> > each
> > >         example in a separate persistence-unit.
> > >     -->
> > >     <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">
> > >
> > >         <!--
> > >             The default provider can be OpenJPA, or some other
> > product.
> > >             This element is optional if OpenJPA is the only JPA
> > provider
> > >             in the current classloading environment, but can be
> > specified
> > >             in cases where there are multiple JPA implementations
> > available.
> > >         -->
> > >
> > >         <provider>
> > >             org.apache.openjpa.persistence.PersistenceProviderImpl
> > >         </provider>
> > >         <mapping-file>META-INF/orm.xml</mapping-file>
> > >
> > >         <!-- We must enumerate each entity in the persistence unit -->
> > >         <class>datamodel.Person</class>
> > >
> > >         <properties>
> > >             <property name="openjpa.ConnectionURL"
> > >
> > > value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
> > >             <property name="openjpa.ConnectionDriverName"
> > >                 value="org.apache.derby.jdbc.EmbeddedDriver" />
> > >             <property name="openjpa.ConnectionUserName" value="" />
> > >             <property name="openjpa.ConnectionPassword" value="" />
> > >
> > >             <!--
> > >                 Tell OpenJPA to automatically create tables in the
> > database
> > >                 for entities. Note that this should be disabled when
> > >                 running against a production database, since you
> > probably
> > >                 don't want to be altering the schema at runtime.
> > >             -->
> > >             <property name="openjpa.jdbc.SynchronizeMappings"
> > >                 value="buildSchema" />
> > >
> > >         </properties>
> > >     </persistence-unit>
> > >
> > > </persistence>
> >
> >
>

Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hi Adam,

thank you. If I remove the <mapping-file> I still get the same error. I
change the header to your header but still no difference. I paste the new
version of my files below.

Both orm.xml and persistence.xml are in the same directory META-INF.

Any further advice?
--------------

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  version="1.0">
    <entity class="datamodel.Person">
      <table name="MYAPPLICATION.PEOPLETABLE"/>
        <attributes>
            <id name="id" />
            <basic name="firstName" />
            <basic name="lastName" />
            <transient name="nonsenseField" />
        </attributes>
    </entity>
</entity-mappings>

<?xml version="1.0" encoding="UTF-8"?>
---------------
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">

    <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">

        <provider>
            org.apache.openjpa.persistence.PersistenceProviderImpl
        </provider>
        <mapping-file>META-INF/orm.xml</mapping-file>

        <!-- We must enumerate each entity in the persistence unit -->
        <class>datamodel.Person</class>

        <properties>
            <property name="openjpa.ConnectionURL"

value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
            <property name="openjpa.ConnectionDriverName"
                value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="openjpa.ConnectionUserName" value="" />
            <property name="openjpa.ConnectionPassword" value="" />

            <!--
                Automatically create tables in the database
                for entities. Not for production use
                -->
            <property name="openjpa.jdbc.SynchronizeMappings"
                value="buildSchema" />

        </properties>
    </persistence-unit>

</persistence>




Best regards, Lars


2008/3/31, Adam Hardy <ad...@cyberspaceroad.org>:
>
> Hi Lars,
>
> that is a weird error that I haven't seen before - it looks like OpenJPA
> is
> confusing the table name with the class name.
>
> In case it helps, you don't need to reference the orm.xml in the
> persistence.xml. Not sure if it's a problem when you do, try without.
>
> orm.xml looks like it's in the same directory as persistence.xml from your
> email. perhaps you should double-check.
>
> my orm.xml header is slightly different:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
>
> http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
>    version="1.0">
>
> I do not run the OpenJPA enhancer and you shouldn't need to, but I am
> using the
> OpenJPA v1.1.0 snapshot, not 1.0.x.
>
>
>
>
>
> Lars Vogel on 30/03/08 19:29, wrote:
> > Hi,
> >
> > Can anyone point me to a working standalone example there a a orm.xmlfile
> > is used instead of Annotations?
> >
> > I'm able to build a small example with annotations but if I try the same
> > with orm.xml I receive the following error:
> >
> > Exception in thread "main" <openjpa-1.0.2-r420667:627158 fatal user
> error>
> > org.apache.openjpa.persistence.ArgumentException: Could not locate
> metadata
> > for the class using alias "MYAPPLICATION.PEOPLETABLE". This could mean
> that
> > the OpenJPA enhancer or load-time weaver was not run on the type whose
> alias
> > is "MYAPPLICATION.PEOPLETABLE". Registered alias mappings: "{
> > MYAPPLICATION.PEOPLETABLE=null, Person=[class datamodel.Person]}"
> >
> >
> > I have the following orm.xml
> >
> > <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
> >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> >     xsi:schemaLocation="
> http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
>
> >     version="1.0">
> >     <entity class="datamodel.Person">
> >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> >         <attributes>
> >             <id name="id" />
> >             <basic name="firstName" />
> >             <basic name="lastName" />
> >             <transient name="nonsenseField" />
> >         </attributes>
> >     </entity>
> > </entity-mappings>
> >
> > I have the following persistence.xml
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--
> >     Licensed to the Apache Software Foundation (ASF) under one
> >     or more contributor license agreements.  See the NOTICE file
> >     distributed with this work for additional information
> >     regarding copyright ownership.  The ASF licenses this file
> >     to you under the Apache License, Version 2.0 (the
> >     "License"); you may not use this file except in compliance
> >     with the License.  You may obtain a copy of the License at
> >
> >     http://www.apache.org/licenses/LICENSE-2.0
> >
> >     Unless required by applicable law or agreed to in writing,
> >     software distributed under the License is distributed on an
> >     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> >     KIND, either express or implied.  See the License for the
> >     specific language governing permissions and limitations
> >     under the License.
> > -->
> > <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
> >
> >     <!--
> >         A persistence unit is a set of listed persistent entities as
> well
> >         the configuration of an EntityManagerFactory. We configure each
> >         example in a separate persistence-unit.
> >     -->
> >     <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">
> >
> >         <!--
> >             The default provider can be OpenJPA, or some other product.
> >             This element is optional if OpenJPA is the only JPA provider
> >             in the current classloading environment, but can be
> specified
> >             in cases where there are multiple JPA implementations
> available.
> >         -->
> >
> >         <provider>
> >             org.apache.openjpa.persistence.PersistenceProviderImpl
> >         </provider>
> >         <mapping-file>META-INF/orm.xml</mapping-file>
> >
> >         <!-- We must enumerate each entity in the persistence unit -->
> >         <class>datamodel.Person</class>
> >
> >         <properties>
> >             <property name="openjpa.ConnectionURL"
> >
> > value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
> >             <property name="openjpa.ConnectionDriverName"
> >                 value="org.apache.derby.jdbc.EmbeddedDriver" />
> >             <property name="openjpa.ConnectionUserName" value="" />
> >             <property name="openjpa.ConnectionPassword" value="" />
> >
> >             <!--
> >                 Tell OpenJPA to automatically create tables in the
> database
> >                 for entities. Note that this should be disabled when
> >                 running against a production database, since you
> probably
> >                 don't want to be altering the schema at runtime.
> >             -->
> >             <property name="openjpa.jdbc.SynchronizeMappings"
> >                 value="buildSchema" />
> >
> >         </properties>
> >     </persistence-unit>
> >
> > </persistence>
>
>

Re: Could not locate metadata (orm.xml)

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
Hi Lars,

that is a weird error that I haven't seen before - it looks like OpenJPA is 
confusing the table name with the class name.

In case it helps, you don't need to reference the orm.xml in the 
persistence.xml. Not sure if it's a problem when you do, try without.

orm.xml looks like it's in the same directory as persistence.xml from your 
email. perhaps you should double-check.

my orm.xml header is slightly different:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm 
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
   version="1.0">

I do not run the OpenJPA enhancer and you shouldn't need to, but I am using the 
OpenJPA v1.1.0 snapshot, not 1.0.x.




Lars Vogel on 30/03/08 19:29, wrote:
> Hi,
> 
> Can anyone point me to a working standalone example there a a orm.xml file
> is used instead of Annotations?
> 
> I'm able to build a small example with annotations but if I try the same
> with orm.xml I receive the following error:
> 
> Exception in thread "main" <openjpa-1.0.2-r420667:627158 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
> for the class using alias "MYAPPLICATION.PEOPLETABLE". This could mean that
> the OpenJPA enhancer or load-time weaver was not run on the type whose alias
> is "MYAPPLICATION.PEOPLETABLE". Registered alias mappings: "{
> MYAPPLICATION.PEOPLETABLE=null, Person=[class datamodel.Person]}"
> 
> 
> I have the following orm.xml
> 
> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
>     version="1.0">
>     <entity class="datamodel.Person">
>       <table name="MYAPPLICATION.PEOPLETABLE"/>
>         <attributes>
>             <id name="id" />
>             <basic name="firstName" />
>             <basic name="lastName" />
>             <transient name="nonsenseField" />
>         </attributes>
>     </entity>
> </entity-mappings>
> 
> I have the following persistence.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
>     Licensed to the Apache Software Foundation (ASF) under one
>     or more contributor license agreements.  See the NOTICE file
>     distributed with this work for additional information
>     regarding copyright ownership.  The ASF licenses this file
>     to you under the Apache License, Version 2.0 (the
>     "License"); you may not use this file except in compliance
>     with the License.  You may obtain a copy of the License at
> 
>     http://www.apache.org/licenses/LICENSE-2.0
> 
>     Unless required by applicable law or agreed to in writing,
>     software distributed under the License is distributed on an
>     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>     KIND, either express or implied.  See the License for the
>     specific language governing permissions and limitations
>     under the License.
> -->
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
> 
>     <!--
>         A persistence unit is a set of listed persistent entities as well
>         the configuration of an EntityManagerFactory. We configure each
>         example in a separate persistence-unit.
>     -->
>     <persistence-unit name="people" transaction-type="RESOURCE_LOCAL">
> 
>         <!--
>             The default provider can be OpenJPA, or some other product.
>             This element is optional if OpenJPA is the only JPA provider
>             in the current classloading environment, but can be specified
>             in cases where there are multiple JPA implementations available.
>         -->
> 
>         <provider>
>             org.apache.openjpa.persistence.PersistenceProviderImpl
>         </provider>
>         <mapping-file>META-INF/orm.xml</mapping-file>
> 
>         <!-- We must enumerate each entity in the persistence unit -->
>         <class>datamodel.Person</class>
> 
>         <properties>
>             <property name="openjpa.ConnectionURL"
> 
> value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true" />
>             <property name="openjpa.ConnectionDriverName"
>                 value="org.apache.derby.jdbc.EmbeddedDriver" />
>             <property name="openjpa.ConnectionUserName" value="" />
>             <property name="openjpa.ConnectionPassword" value="" />
> 
>             <!--
>                 Tell OpenJPA to automatically create tables in the database
>                 for entities. Note that this should be disabled when
>                 running against a production database, since you probably
>                 don't want to be altering the schema at runtime.
>             -->
>             <property name="openjpa.jdbc.SynchronizeMappings"
>                 value="buildSchema" />
> 
>         </properties>
>     </persistence-unit>
> 
> </persistence>


Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hello,

thank you all for your very quick and constructive feedback. I'll clean my
example up and post it later to this group so that others can use it also as
a starting point (if desired).

Thank you again, Lars

Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hello,

cool script. I modified it a little bit so that it runs for me....

Thanks to your script I'm now able to create a working example. I believe I
confused @Table(name="MYAPPLICATION.PEOPLETABLE") with @Entity(name="
MYAPPLICATION.PEOPLETABLE") in my annotation example and this let me to
incorrect orm.xml coding.

Thank you very much.

Best regards, Lars




2008/3/31, os_developer <os...@yahoo.com>:
>
> Lars,
>
> In your ant build script, I don't see where you are
> specifying against which database the reverse mapping
> tool should run. You need to provide your username and
> password as well.
>
> In my setup, I have an initial database already up and
> running.  In my build directory, I have a build.xml
> file and then a META-INF/persistence.xml file.
>
> When I run "ant reversemap" of my build.xml file, it
> generates an orm.xml file and all of my java source.
>
> You will have to update my files with your database
> info but here they are in case they might be of help.
> I did have to modify the orm.xml file a bit after it
> was created so it was exactly how I wanted, but it did
> work as-is without my changes.
>
> Here's my persistence.xml file (and below is my
> build.xml file):
>
> <?xml version="1.0"?>
>
>
> <persistence
> xmlns="http://java.sun.com/xml/ns/persistence"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
>
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>
>
>
> http://java.sun.com/xml/ns/persistence/persistence_1.0.xsd"
>              version="1.0">
>
> <persistence-unit name="test"
> transaction-type="RESOURCE_LOCAL">
>
>
>    <provider>
>
> org.apache.openjpa.persistence.PersistenceProviderImpl
>    </provider>
>
>
> </persistence-unit>
>
> </persistence>
>
>
>
> Here's my build.xml (I've cut out some pieces which
> aren't relevant).
>
>
> build.xml
>
> ---------
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <project default="reversemap" name="test" basedir=".">
>
>
> <property environment="env"/>
>
> <condition property="bea.home"
> value="${env.BEA_HOME}">
>   <isset property="env.BEA_HOME"/>
> </condition>
> <fail unless="env.BEA_HOME" message="The BEA_HOME
> property must be set"/>
>
> <condition property="package.name"
> value="${env.PACKAGE_NAME}">
>   <isset property="env.PACKAGE_NAME"/>
> </condition>
> <fail unless="env.PACKAGE_NAME" message="The
> PACKAGE_NAME property must be set"/>
>
>
> <property name="dbdriver"
> value="oracle.jdbc.OracleDriver"/>
> <property name="dburl"
> value="jdbc:oracle:thin@localhost:1521:mysid"/>
> <property name="dbuser" value="myusername"/>
> <property name="dbpass" value="mypassword"/>
>
> <path id="classpath">
>    <pathelement path="${basedir}" />
>    <pathelement path="${basedir}/META-INF" />
>    <fileset dir="${bea.home}/modules">
>      <include name="javax.persistence_*.jar"/>
>      <include name="org.apache.openjpa_*.jar"/>
>      <include
> name="com.bea.core.apache.commons.lang_*.jar"/>
>      <include name="javax.transaction_*.jar"/>
>      <include name="javax.resource_*.jar"/>
>      <include name="com.bea.core.serp_*.jar"/>
>    </fileset>
>    <fileset dir="${bea.home}/modules">
>       <include name="com.bea.oracle.ojdbc14_*.jar"/>
>    </fileset>
> </path>
>
> <path id="classpath.oracle">
>    <fileset dir="${bea.home}/modules">
>       <include name="com.bea.oracle.ojdbc14_*.jar"/>
>    </fileset>
> </path>
>
> <!-- =========================================== -->
> <!-- Runs against the database to create an orm.xml
>      file and java classes -->
> <!-- =========================================== -->
> <target name="reversemap">
>
>    <!-- Removes any previously generated orm.xml -->
>    <delete>
>       <fileset dir="${basedir}">
>         <include name="orm.xml" />
>       </fileset>
>    </delete>
>
>    <taskdef name="reversemappingtool"
>             classpathref="classpath"
>
>
>
> classname="org.apache.openjpa.jdbc.ant.ReverseMappingToolTask"/>
>
>
>
>    <reversemappingtool
>        package="${package.name}"
>        directory="${basedir}/build">
>
>    <!-- This must be set to your database -->
>    <config
>        connectiondrivername="${dbdriver}"
>        connectionurl="${dburl}"
>        connectionusername="${dbuser}"
>        connectionpassword="${dbpass}"
>        propertiesfile="META-INF/persistence.xml"/>
>
>    <classpath>
>       <pathelement path="${classpath}"/>
>       <pathelement path="${basedir}"/>
>       <pathelement path="${basedir}/META-INF"/>
>       <pathelement path="${classpath.oracle}/>
>    </classpath>
>
>
>    <codeformat tabSpaces="4" spaceBeforeParen="true"
>
> braceOnSameLine="false"/>
>
>    </reversemappingtool>
>
>
>    <!-- This copies the persistence.xml and orm.xml
> into
>         the directory where the java classes were
> generated -->
>
>    <mkdir dir="${basedir}/build"/>
>    <copy todir="${basedir}/build/META-INF">
>       <fileset dir="${basedir}">
>          <include name="orm.xml"/>
>       </fileset>
>       <fileset dir="${basedir}/META-INF">
>          <include name="persistence.xml"/>
>       </fileset>
>    </copy>
>
>
> </target>
>
> </project>
>
>
>
>
>
>       ____________________________________________________________________________________
> Special deal for Yahoo! users & friends - No Cost. Get a month of
> Blockbuster Total Access now
> http://tc.deals.yahoo.com/tc/blockbuster/text3.com
>

Re: Could not locate metadata (orm.xml)

Posted by os_developer <os...@yahoo.com>.
Lars,

In your ant build script, I don't see where you are
specifying against which database the reverse mapping
tool should run. You need to provide your username and
password as well.

In my setup, I have an initial database already up and
running.  In my build directory, I have a build.xml
file and then a META-INF/persistence.xml file.

When I run "ant reversemap" of my build.xml file, it
generates an orm.xml file and all of my java source. 

You will have to update my files with your database
info but here they are in case they might be of help. 
I did have to modify the orm.xml file a bit after it
was created so it was exactly how I wanted, but it did
work as-is without my changes. 

Here's my persistence.xml file (and below is my
build.xml file):

<?xml version="1.0"?>

<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
            
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence


http://java.sun.com/xml/ns/persistence/persistence_1.0.xsd"
             version="1.0">

<persistence-unit name="test"
transaction-type="RESOURCE_LOCAL">

   <provider>
     
org.apache.openjpa.persistence.PersistenceProviderImpl
   </provider>

</persistence-unit>

</persistence>



Here's my build.xml (I've cut out some pieces which
aren't relevant).


build.xml
---------

<?xml version="1.0" encoding="UTF-8"?>
<project default="reversemap" name="test" basedir=".">


<property environment="env"/>

<condition property="bea.home"
value="${env.BEA_HOME}">
  <isset property="env.BEA_HOME"/>
</condition>
<fail unless="env.BEA_HOME" message="The BEA_HOME
property must be set"/>

<condition property="package.name"
value="${env.PACKAGE_NAME}">
  <isset property="env.PACKAGE_NAME"/>
</condition>
<fail unless="env.PACKAGE_NAME" message="The
PACKAGE_NAME property must be set"/>


<property name="dbdriver"
value="oracle.jdbc.OracleDriver"/>
<property name="dburl"
value="jdbc:oracle:thin@localhost:1521:mysid"/>
<property name="dbuser" value="myusername"/>
<property name="dbpass" value="mypassword"/>

<path id="classpath">
   <pathelement path="${basedir}" />
   <pathelement path="${basedir}/META-INF" />
   <fileset dir="${bea.home}/modules">
     <include name="javax.persistence_*.jar"/>
     <include name="org.apache.openjpa_*.jar"/>
     <include
name="com.bea.core.apache.commons.lang_*.jar"/>
     <include name="javax.transaction_*.jar"/>
     <include name="javax.resource_*.jar"/>
     <include name="com.bea.core.serp_*.jar"/>
   </fileset>
   <fileset dir="${bea.home}/modules">
      <include name="com.bea.oracle.ojdbc14_*.jar"/>
   </fileset>
</path>

<path id="classpath.oracle">
   <fileset dir="${bea.home}/modules">
      <include name="com.bea.oracle.ojdbc14_*.jar"/>
   </fileset>
</path>

<!-- =========================================== -->
<!-- Runs against the database to create an orm.xml
     file and java classes -->
<!-- =========================================== -->
<target name="reversemap">

   <!-- Removes any previously generated orm.xml -->
   <delete>
      <fileset dir="${basedir}">
        <include name="orm.xml" />
      </fileset>
   </delete>

   <taskdef name="reversemappingtool"
            classpathref="classpath"
            

classname="org.apache.openjpa.jdbc.ant.ReverseMappingToolTask"/>


   <reversemappingtool 
       package="${package.name}"
       directory="${basedir}/build">

   <!-- This must be set to your database -->
   <config
       connectiondrivername="${dbdriver}"
       connectionurl="${dburl}"
       connectionusername="${dbuser}"
       connectionpassword="${dbpass}"
       propertiesfile="META-INF/persistence.xml"/>

   <classpath>
      <pathelement path="${classpath}"/>
      <pathelement path="${basedir}"/>
      <pathelement path="${basedir}/META-INF"/>
      <pathelement path="${classpath.oracle}/>
   </classpath>

   <codeformat tabSpaces="4" spaceBeforeParen="true" 

braceOnSameLine="false"/>

   </reversemappingtool>

   <!-- This copies the persistence.xml and orm.xml
into
        the directory where the java classes were
generated -->

   <mkdir dir="${basedir}/build"/>
   <copy todir="${basedir}/build/META-INF">
      <fileset dir="${basedir}">
         <include name="orm.xml"/>
      </fileset>
      <fileset dir="${basedir}/META-INF">
         <include name="persistence.xml"/>
      </fileset>
   </copy>
     

</target>

</project>



      ____________________________________________________________________________________
Special deal for Yahoo! users & friends - No Cost. Get a month of Blockbuster Total Access now 
http://tc.deals.yahoo.com/tc/blockbuster/text3.com

Re: Could not locate metadata (orm.xml)

Posted by Lars Vogel <la...@googlemail.com>.
Hi Andreas,

thank you for your response.

I tried this. If I run the Ant task example from the OpenJPA manual for
creating a schema (Schema Tool Ant Task)  then the system tells me:

[schematool] The options supplied to the SchemaToolTask are not valid.
Please check your ant build file.

If I try to run the mapping tool against the database I receive the
following:
[reversemappingtool] <openjpa-1.0.2-r420667:627158 fatal user error>
org.apache.openjpa.util.UserException: A JDBC Driver or DataSource class
name must be specified in the ConnectionDriverName property.

Below is my ant task:

Any idea what is wrong?

Thank you, Lars

----
<?xml version="1.0"?>

<project name="docbook-src" default="reversemap">

    <description>
        This Ant build.xml file is used to transform DocBook XML to
        various output formats
    </description>

    <target name="schema">
        <!-- define the schematool task; this can be done at the top of -->
        <!-- the build.xml file, so it will be available for all targets -->
        <taskdef name="schematool" classname="
org.apache.openjpa.jdbc.ant.SchemaToolTask" />
        <!-- add the schema components for all .schema files below the -->
        <!-- current directory -->
        <schematool action="add">
            <fileset dir=".">
                <include name="**/*.schema" />
            </fileset>
        </schematool>
    </target>
    <target name="reversemap">
        <!-- define the reversemappingtool task; this can be done at the top
of -->
        <!-- the build.xml file, so it will be available for all targets -->
        <taskdef name="reversemappingtool" classname="
org.apache.openjpa.jdbc.ant.ReverseMappingToolTask" />
        <!-- reverse map the entire database -->
        <reversemappingtool package="datamodel" directory="${basedir}/src"
customizerProperties="${basedir}/conf/reverse.properties">
            <codeformat tabSpaces="4" spaceBeforeParen="true"
braceOnSameLine="false" />
        </reversemappingtool>
    </target>

</project>
--------------



2008/3/30, os_developer <os...@yahoo.com>:
>
> I'm not sure if your orm.xml file is invalid or not
> but   one of the ways I've found to get a start on a
> valid orm.xml file when I wasn't sure if mine was
> correct was to use the Reverse Mapping tool in openjpa
> (see the manual for more info).
>
> If you already have a working example using
> annotations, you can use the ant task to create your
> orm.xml file for you, based on what you already have
> in the database from your previous working example.
>
> I do know that my orm.xml files look very different
> from yours but I don't know where exactly the problem
> might be.
>
> Andrea
>
>
>
> --- Lars Vogel <la...@googlemail.com> wrote:
>
> > Hi,
> >
> > Can anyone point me to a working standalone example
> > there a a orm.xml file
> > is used instead of Annotations?
> >
> > I'm able to build a small example with annotations
> > but if I try the same
> > with orm.xml I receive the following error:
> >
> > Exception in thread "main"
> > <openjpa-1.0.2-r420667:627158 fatal user error>
> > org.apache.openjpa.persistence.ArgumentException:
> > Could not locate metadata
> > for the class using alias
> > "MYAPPLICATION.PEOPLETABLE". This could mean that
> > the OpenJPA enhancer or load-time weaver was not run
> > on the type whose alias
> > is "MYAPPLICATION.PEOPLETABLE". Registered alias
> > mappings: "{
> > MYAPPLICATION.PEOPLETABLE=null, Person=[class
> > datamodel.Person]}"
> >
> >
> > I have the following orm.xml
> >
> > <entity-mappings
> > xmlns="http://java.sun.com/xml/ns/persistence/orm"
> >
> >
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >
> >
>
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
>
> >     version="1.0">
> >     <entity class="datamodel.Person">
> >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> >         <attributes>
> >             <id name="id" />
> >             <basic name="firstName" />
> >             <basic name="lastName" />
> >             <transient name="nonsenseField" />
> >         </attributes>
> >     </entity>
> > </entity-mappings>
> >
> > I have the following persistence.xml
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--
> >     Licensed to the Apache Software Foundation (ASF)
> > under one
> >     or more contributor license agreements.  See the
> > NOTICE file
> >     distributed with this work for additional
> > information
> >     regarding copyright ownership.  The ASF licenses
> > this file
> >     to you under the Apache License, Version 2.0
> > (the
> >     "License"); you may not use this file except in
> > compliance
> >     with the License.  You may obtain a copy of the
> > License at
> >
> >     http://www.apache.org/licenses/LICENSE-2.0
> >
> >     Unless required by applicable law or agreed to
> > in writing,
> >     software distributed under the License is
> > distributed on an
> >     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
> > OF ANY
> >     KIND, either express or implied.  See the
> > License for the
> >     specific language governing permissions and
> > limitations
> >     under the License.
> > -->
> > <persistence
> > xmlns="http://java.sun.com/xml/ns/persistence"
> >
> >
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > version="1.0">
> >
> >     <!--
> >         A persistence unit is a set of listed
> > persistent entities as well
> >         the configuration of an
> > EntityManagerFactory. We configure each
> >         example in a separate persistence-unit.
> >     -->
> >     <persistence-unit name="people"
> > transaction-type="RESOURCE_LOCAL">
> >
> >         <!--
> >             The default provider can be OpenJPA, or
> > some other product.
> >             This element is optional if OpenJPA is
> > the only JPA provider
> >             in the current classloading environment,
> > but can be specified
> >             in cases where there are multiple JPA
> > implementations available.
> >         -->
> >
> >         <provider>
> >
> >
> org.apache.openjpa.persistence.PersistenceProviderImpl
> >         </provider>
> >
> > <mapping-file>META-INF/orm.xml</mapping-file>
> >
> >         <!-- We must enumerate each entity in the
> > persistence unit -->
> >         <class>datamodel.Person</class>
> >
> >         <properties>
> >             <property name="openjpa.ConnectionURL"
> >
> >
> value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true"
> > />
> >             <property
> > name="openjpa.ConnectionDriverName"
> >
> > value="org.apache.derby.jdbc.EmbeddedDriver" />
> >             <property
> > name="openjpa.ConnectionUserName" value="" />
> >             <property
> > name="openjpa.ConnectionPassword" value="" />
> >
> >             <!--
> >                 Tell OpenJPA to automatically create
> > tables in the database
> >                 for entities. Note that this should
> > be disabled when
> >                 running against a production
> > database, since you probably
> >                 don't want to be altering the schema
> > at runtime.
> >             -->
> >             <property
> > name="openjpa.jdbc.SynchronizeMappings"
> >                 value="buildSchema" />
> >
> >         </properties>
> >     </persistence-unit>
> >
> > </persistence>
> >
> >
> > Best regards, Lars
> >
>
>
>
>
>
>       ____________________________________________________________________________________
> Special deal for Yahoo! users & friends - No Cost. Get a month of
> Blockbuster Total Access now
> http://tc.deals.yahoo.com/tc/blockbuster/text3.com
>

Re: Could not locate metadata (orm.xml)

Posted by os_developer <os...@yahoo.com>.
I'm not sure if your orm.xml file is invalid or not
but   one of the ways I've found to get a start on a
valid orm.xml file when I wasn't sure if mine was
correct was to use the Reverse Mapping tool in openjpa
(see the manual for more info).

If you already have a working example using
annotations, you can use the ant task to create your
orm.xml file for you, based on what you already have
in the database from your previous working example.  

I do know that my orm.xml files look very different
from yours but I don't know where exactly the problem
might be.

Andrea


--- Lars Vogel <la...@googlemail.com> wrote:

> Hi,
> 
> Can anyone point me to a working standalone example
> there a a orm.xml file
> is used instead of Annotations?
> 
> I'm able to build a small example with annotations
> but if I try the same
> with orm.xml I receive the following error:
> 
> Exception in thread "main"
> <openjpa-1.0.2-r420667:627158 fatal user error>
> org.apache.openjpa.persistence.ArgumentException:
> Could not locate metadata
> for the class using alias
> "MYAPPLICATION.PEOPLETABLE". This could mean that
> the OpenJPA enhancer or load-time weaver was not run
> on the type whose alias
> is "MYAPPLICATION.PEOPLETABLE". Registered alias
> mappings: "{
> MYAPPLICATION.PEOPLETABLE=null, Person=[class
> datamodel.Person]}"
> 
> 
> I have the following orm.xml
> 
> <entity-mappings
> xmlns="http://java.sun.com/xml/ns/persistence/orm"
>    
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    
>
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/ormorm_1_0.xsd"
>     version="1.0">
>     <entity class="datamodel.Person">
>       <table name="MYAPPLICATION.PEOPLETABLE"/>
>         <attributes>
>             <id name="id" />
>             <basic name="firstName" />
>             <basic name="lastName" />
>             <transient name="nonsenseField" />
>         </attributes>
>     </entity>
> </entity-mappings>
> 
> I have the following persistence.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
>     Licensed to the Apache Software Foundation (ASF)
> under one
>     or more contributor license agreements.  See the
> NOTICE file
>     distributed with this work for additional
> information
>     regarding copyright ownership.  The ASF licenses
> this file
>     to you under the Apache License, Version 2.0
> (the
>     "License"); you may not use this file except in
> compliance
>     with the License.  You may obtain a copy of the
> License at
> 
>     http://www.apache.org/licenses/LICENSE-2.0
> 
>     Unless required by applicable law or agreed to
> in writing,
>     software distributed under the License is
> distributed on an
>     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
> OF ANY
>     KIND, either express or implied.  See the
> License for the
>     specific language governing permissions and
> limitations
>     under the License.
> -->
> <persistence
> xmlns="http://java.sun.com/xml/ns/persistence"
>    
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> version="1.0">
> 
>     <!--
>         A persistence unit is a set of listed
> persistent entities as well
>         the configuration of an
> EntityManagerFactory. We configure each
>         example in a separate persistence-unit.
>     -->
>     <persistence-unit name="people"
> transaction-type="RESOURCE_LOCAL">
> 
>         <!--
>             The default provider can be OpenJPA, or
> some other product.
>             This element is optional if OpenJPA is
> the only JPA provider
>             in the current classloading environment,
> but can be specified
>             in cases where there are multiple JPA
> implementations available.
>         -->
> 
>         <provider>
>            
>
org.apache.openjpa.persistence.PersistenceProviderImpl
>         </provider>
>        
> <mapping-file>META-INF/orm.xml</mapping-file>
> 
>         <!-- We must enumerate each entity in the
> persistence unit -->
>         <class>datamodel.Person</class>
> 
>         <properties>
>             <property name="openjpa.ConnectionURL"
> 
>
value="jdbc:derby:C:/DerbyDatabases/hellojpa-database9;create=true"
> />
>             <property
> name="openjpa.ConnectionDriverName"
>                
> value="org.apache.derby.jdbc.EmbeddedDriver" />
>             <property
> name="openjpa.ConnectionUserName" value="" />
>             <property
> name="openjpa.ConnectionPassword" value="" />
> 
>             <!--
>                 Tell OpenJPA to automatically create
> tables in the database
>                 for entities. Note that this should
> be disabled when
>                 running against a production
> database, since you probably
>                 don't want to be altering the schema
> at runtime.
>             -->
>             <property
> name="openjpa.jdbc.SynchronizeMappings"
>                 value="buildSchema" />
> 
>         </properties>
>     </persistence-unit>
> 
> </persistence>
> 
> 
> Best regards, Lars
> 



      ____________________________________________________________________________________
Special deal for Yahoo! users & friends - No Cost. Get a month of Blockbuster Total Access now 
http://tc.deals.yahoo.com/tc/blockbuster/text3.com