You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by the666pack <ma...@gmail.com> on 2008/07/05 11:19:28 UTC

error writing tuple to database "the owning entity is not mapped" geronimo 2.1.1

hello,

i am back again and hope someone can help me out with my new error in
geronimo 2.1.1. 

my database scheme consists of a Person entity and a Director entity which
is inherited from the Person entity. 

so i want to write a Person first, to keep it simple. unfortunately i get an
error when i try to perform a write:

<openjpa-1.0.2-r420667:627158 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Attempt to map
"vt.bean.entity.Person.id" failed: the owning entity is not mapped.

i was successfully writing tuples of my application to database with
geronimo version 2.0.2 and also did not change nothing in my .ear archive
and application. 

i found a jira on a similar topic:

https://issues.apache.org/jira/browse/OPENJPA-524

but i am not sure if this is the same problem, and the jira is in a
fixed-solved status.

the full debug view is:

  [exec] 10:51:04,196 INFO  [OpenEJB] invoking method create on
videothek.jar/WriteDataBean
     [exec] 10:51:04,268 INFO  [OpenEJB] finished invoking method create
     [exec] 10:51:04,300 INFO  [Transaction] TX Required: Started
transaction org.apache.geronimo.transaction.manager.TransactionImpl@1806022
     [exec] 10:51:04,304 INFO  [Transaction] TX Required: Committing
transaction org.apache.geronimo.transaction.manager.TransactionImpl@1806022
     [exec] 10:51:04,305 INFO  [Transaction] TX Required: Started
transaction org.apache.geronimo.transaction.manager.TransactionImpl@ae6e72
     [exec] 10:51:04,314 INFO  [Runtime] Starting OpenJPA 1.0.2
     [exec] 10:51:04,427 INFO  [JDBC] Using dictionary class
"org.apache.openjpa.jdbc.sql.PostgresDictionary".
     [exec] 10:51:05,734 INFO  [Transaction] TX Required: setRollbackOnly()
on transaction
org.apache.geronimo.transaction.manager.TransactionImpl@ae6e72
     [exec] 10:51:05,735 INFO  [Transaction] TX Required: Rolling back
transaction org.apache.geronimo.transaction.manager.TransactionImpl@ae6e72
     [exec] javax.ejb.EJBException: The bean encountered a non-application
exception.; nested exception is:
     [exec]     <openjpa-1.0.2-r420667:627158 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Attempt to map
"vt.bean.entity.Person.id" failed: the owning entity is not mapped.
     [exec]     at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:366)
     [exec]     at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:251)
     [exec]     at
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
     [exec]     at $Proxy23.writeToDB(Unknown Source)
     [exec]     at vt.servlet.AddServlet.doGet(AddServlet.java:48)
     [exec]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
     [exec]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
     [exec]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     [exec]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [exec]     at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     [exec]     at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     [exec]     at
org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
     [exec]     at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
     [exec]     at
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
     [exec]     at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
     [exec]     at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     [exec]     at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     [exec]     at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
     [exec]     at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
     [exec]     at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
     [exec]     at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
     [exec]     at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
     [exec]     at java.lang.Thread.run(Thread.java:619)
     [exec] Caused by: <openjpa-1.0.2-r420667:627158 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Attempt to map
"vt.bean.entity.Person.id" failed: the owning entity is not mapped.
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:544)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:496)
     [exec]     at
org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:143)
     [exec]     at
org.apache.openjpa.jdbc.meta.strats.PrimitiveFieldStrategy.map(PrimitiveFieldStrategy.java:83)
     [exec]     at
org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:120)
     [exec]     at
org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80)
     [exec]     at
org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:438)
     [exec]     at
org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:403)
     [exec]     at
org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:841)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:322)
     [exec]     at
org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:621)
     [exec]     at
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:508)
     [exec]     at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:302)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:282)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:673)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:745)
     [exec]     at
org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:643)
     [exec]     at
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:164)
     [exec]     at
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:130)
     [exec]     at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:188)
     [exec]     at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
     [exec]     at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
     [exec]     at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
     [exec]     at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
     [exec]     at
vt.bean.stateful.WriteDataBean.writeToDB(WriteDataBean.java:95)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
     [exec]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [exec]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
     [exec]     at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
     [exec]     at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
     [exec]     at
org.apache.openejb.core.stateful.StatefulContainer._invoke(StatefulContainer.java:451)
     [exec]     at
org.apache.openejb.core.stateful.StatefulContainer.businessMethod(StatefulContainer.java:413)
     [exec]     at
org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:271)
     [exec]     at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
     [exec]     at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
     [exec]     at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
     [exec]     ... 21 more


any help is highly appreciated, 

thanks a lot!

mario.
 
-- 
View this message in context: http://www.nabble.com/error-writing-tuple-to-database-%22the-owning-entity-is-not-mapped%22-geronimo-2.1.1-tp18290344s134p18290344.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: error writing tuple to database "the owning entity is not mapped" geronimo 2.1.1

Posted by Mario Kofler <ma...@gmail.com>.
hi jacek,

thanks for your help, i did change my birthdate field to sql.Date now.
the error message remains. but i realized, that the error message just
appears at the first write operation: all following write operations
are executed successfully. i will try to make my tests, i think i'll
just ignore the first write action and start my tests from the 2nd
write operation on.

for the moment, thanks!

mario.

2008/7/6 Jacek Laskowski <ja...@laskowski.net.pl>:
> On Sun, Jul 6, 2008 at 11:34 AM, Mario Kofler <ma...@gmail.com> wrote:
>>
>
> Hi Mario,
>
> Let's make it simpler by removing some unneeded, defaulted
> configuration values in your sample.
>
>> <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/persistence_1_0.xsd"
>>             version="1.0">
>>  <persistence-unit name="valhalla" transaction-type="JTA">
>
> Hint: you may remove transaction-type as it's JTA in managed
> environment like Geronimo.
>
>>    <description>videothek</description>
>>    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>
> Provider defaults to openjpa in Geronimo. You may remove it.
>
>>    <class>vt.bean.entity.Person</class>
>>    <class>vt.bean.entity.Actor</class>
>>    <class>vt.bean.entity.Director</class>
>>    <class>vt.bean.entity.Movie</class>
>>    <class>vt.bean.entity.Dvd</class>
>
> Not needed in managed environment like Geronimo. It makes things run
> faster - no need to look for annotated classes, but am not sure if we
> don't do this even though the class elements are specified.
>
> Also, you showed Person entity class, but what about the rest? Either
> remove them and let's play with a single entity only and add more
> later or show all of them as I think the issue might be in the others.
>
>>    <properties>
>>
>>      <property name="openjpa.jdbc.DBDictionary" value="postgres"/>
>>      <!--property name="openjpa.LockManager" value="pessimistic"/-->
>>    </properties>
>>    <jta-data-source>jdbc/postgres</jta-data-source>
>>    <non-jta-data-source>jdbc/postgres</non-jta-data-source>
>
> I think *data-source should be before properties element. Geronimo
> should really be more strict.
>
>> @Entity
>> @Table(name="person")
>> @Inheritance(strategy=InheritanceType.JOINED)
>> @DiscriminatorColumn(name="role", discriminatorType=DiscriminatorType.STRING)
>
> discriminatorType is defaulted to STRING.
>
>> @DiscriminatorValue("P")
>> public class Person implements java.io.Serializable
>> {
>>    private int id;
>>    private String name;
>>    private Calendar birthdate;
>>    private String origin;
>>
>>    @Id
>>    @GeneratedValue
>>    public int getId()
>>    {
>>        return id;
>>    }
>>
>>    public void setId(int id)
>>    {
>>        this.id = id;
>>    }
>>
>>    public String getName()
>>    {
>>        return name;
>>    }
>>
>>    public void setName(String name)
>>    {
>>        this.name = name;
>>    }
>>
>>    @Temporal(TemporalType.DATE)
>>    public Calendar getBirthdate()
>>    {
>>        return birthdate;
>>    }
>
> I think that's the issue - @Temporal. According to the spec - JSR 220:
> Enterprise JavaBeansTM,Version 3.0 Java Persistence API - page 234:
>
> <xsd:simpleType name="temporal-type">
> <xsd:annotation>
> <xsd:documentation>
> public enum TemporalType {
> DATE, // java.sql.Date
> TIME, // java.sql.Time
> TIMESTAMP // java.sql.Timestamp
> }
> </xsd:documentation>
> </xsd:annotation>
> <xsd:restriction base="xsd:token">
> <xsd:enumeration value="DATE"/>
> <xsd:enumeration value="TIME"/>
> <xsd:enumeration value="TIMESTAMP"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> so Calendar seems to not be accepted for @Temporal annotation. Change
> the return type of the getter.
>
> I think the Person entity is not mapped correctly and when you run
> your sample you are off the error messages which tell you the Person
> entity could not be mapped.
>
> Jacek
>
> --
> Jacek Laskowski
> Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl
>

Re: error writing tuple to database "the owning entity is not mapped" geronimo 2.1.1

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Sun, Jul 6, 2008 at 11:34 AM, Mario Kofler <ma...@gmail.com> wrote:
>

Hi Mario,

Let's make it simpler by removing some unneeded, defaulted
configuration values in your sample.

> <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/persistence_1_0.xsd"
>             version="1.0">
>  <persistence-unit name="valhalla" transaction-type="JTA">

Hint: you may remove transaction-type as it's JTA in managed
environment like Geronimo.

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

Provider defaults to openjpa in Geronimo. You may remove it.

>    <class>vt.bean.entity.Person</class>
>    <class>vt.bean.entity.Actor</class>
>    <class>vt.bean.entity.Director</class>
>    <class>vt.bean.entity.Movie</class>
>    <class>vt.bean.entity.Dvd</class>

Not needed in managed environment like Geronimo. It makes things run
faster - no need to look for annotated classes, but am not sure if we
don't do this even though the class elements are specified.

Also, you showed Person entity class, but what about the rest? Either
remove them and let's play with a single entity only and add more
later or show all of them as I think the issue might be in the others.

>    <properties>
>
>      <property name="openjpa.jdbc.DBDictionary" value="postgres"/>
>      <!--property name="openjpa.LockManager" value="pessimistic"/-->
>    </properties>
>    <jta-data-source>jdbc/postgres</jta-data-source>
>    <non-jta-data-source>jdbc/postgres</non-jta-data-source>

I think *data-source should be before properties element. Geronimo
should really be more strict.

> @Entity
> @Table(name="person")
> @Inheritance(strategy=InheritanceType.JOINED)
> @DiscriminatorColumn(name="role", discriminatorType=DiscriminatorType.STRING)

discriminatorType is defaulted to STRING.

> @DiscriminatorValue("P")
> public class Person implements java.io.Serializable
> {
>    private int id;
>    private String name;
>    private Calendar birthdate;
>    private String origin;
>
>    @Id
>    @GeneratedValue
>    public int getId()
>    {
>        return id;
>    }
>
>    public void setId(int id)
>    {
>        this.id = id;
>    }
>
>    public String getName()
>    {
>        return name;
>    }
>
>    public void setName(String name)
>    {
>        this.name = name;
>    }
>
>    @Temporal(TemporalType.DATE)
>    public Calendar getBirthdate()
>    {
>        return birthdate;
>    }

I think that's the issue - @Temporal. According to the spec - JSR 220:
Enterprise JavaBeansTM,Version 3.0 Java Persistence API - page 234:

<xsd:simpleType name="temporal-type">
<xsd:annotation>
<xsd:documentation>
public enum TemporalType {
DATE, // java.sql.Date
TIME, // java.sql.Time
TIMESTAMP // java.sql.Timestamp
}
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="DATE"/>
<xsd:enumeration value="TIME"/>
<xsd:enumeration value="TIMESTAMP"/>
</xsd:restriction>
</xsd:simpleType>

so Calendar seems to not be accepted for @Temporal annotation. Change
the return type of the getter.

I think the Person entity is not mapped correctly and when you run
your sample you are off the error messages which tell you the Person
entity could not be mapped.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl

Re: error writing tuple to database "the owning entity is not mapped" geronimo 2.1.1

Posted by Mario Kofler <ma...@gmail.com>.
>
> If a person becomes a director, (s)he won't be able to
> resign and become a manager or just a developer?

that's right. for my application it is assumed that if a person is a
director this person is just a director and cannot be an actor in the
same time.

>
> On to your issue...
>
> > so i want to write a Person first, to keep it simple. unfortunately i get an
> > error when i try to perform a write:
>
> Could you show us how Person looks like? And your persistence.xml too.
> I assume you don't use orm.xml or alike, do you? If so, show it too.

so thanks, the persistence.xml we discussed a lot already if i
remember right ;):

<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/persistence_1_0.xsd"
	     version="1.0">
  <persistence-unit name="valhalla" transaction-type="JTA">
    <description>videothek</description>
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>vt.bean.entity.Person</class>
    <class>vt.bean.entity.Actor</class>
    <class>vt.bean.entity.Director</class>
    <class>vt.bean.entity.Movie</class>
    <class>vt.bean.entity.Dvd</class>

    <properties>

      <property name="openjpa.jdbc.DBDictionary" value="postgres"/>
      <!--property name="openjpa.LockManager" value="pessimistic"/-->	
    </properties>
    <jta-data-source>jdbc/postgres</jta-data-source>
    <non-jta-data-source>jdbc/postgres</non-jta-data-source>
  </persistence-unit>
</persistence>


--------------------------------------------------------
 the Person entity:
--------------------------------------------------------

/*Persistent Entity Person*/
@Entity
@Table(name="person")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="role", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("P")
public class Person implements java.io.Serializable
{
    private int id;
    private String name;
    private Calendar birthdate;
    private String origin;

    @Id
    @GeneratedValue
    public int getId()
    {
	return id;
    }

    public void setId(int id)
    {
	this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Temporal(TemporalType.DATE)
    public Calendar getBirthdate()
    {
        return birthdate;
    }

    public void setBirthdate(Calendar birthdate)
    {
        this.birthdate = birthdate;
    }

    public String getOrigin()
    {
        return origin;
    }

    public void setOrigin(String origin)
    {
        this.origin = origin;
    }

}


and yes i do not use an orm.xml

thanks a lot for helping,

greetings,

mario.

>
> Jacek
>
> --
> Jacek Laskowski
> Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl

Re: error writing tuple to database "the owning entity is not mapped" geronimo 2.1.1

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Sat, Jul 5, 2008 at 11:19 AM, the666pack <ma...@gmail.com> wrote:

> my database scheme consists of a Person entity and a Director entity which
> is inherited from the Person entity.

Hi,

It won't solve your issue, but why is Person a superclass of
Directory. Shouldn't Director be a role of a Person in a given
scenario? If a person becomes a director, (s)he won't be able to
resign and become a manager or just a developer?

On to your issue...

> so i want to write a Person first, to keep it simple. unfortunately i get an
> error when i try to perform a write:

Could you show us how Person looks like? And your persistence.xml too.
I assume you don't use orm.xml or alike, do you? If so, show it too.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl