openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Díez Fernández" <carlo...@gmail.com>
Subject Re: Problem with OpenJPA/PostgreSQL
Date Thu, 14 Feb 2008 12:28:00 GMT
Emm problem fixed with the following persistence.xml file

<?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="pajitamusic" transaction-type="RESOURCE_LOCAL">
        <description>pajitadb</description>
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
        <!-- We must enumerate each entity in the persistence unit -->
        <class>com.pajitamusic.ear.Song</class>
        <class>com.pajitamusic.ear.Album</class>
        <class>com.pajitamusic.ear.Artist</class>
        <class>com.pajitamusic.ear.PUser</class>
        <class>com.pajitamusic.ear.UserSong</class>
        <properties>
            <property name="openjpa.jdbc.DBDictionary" value="postgres"/>
            <property name="openjpa.jdbc.SynchronizeMappings"
value="false"/>
            <property name="openjpa.ConnectionDriverName" value="
org.postgresql.Driver"/>
            <property name="openjpa.ConnectionURL"
                   value="jdbc:postgresql://localhost:5432/pajitadb"/>
            <property name="openjpa.ConnectionUserName" value="postgres"/>
            <property name="openjpa.ConnectionPassword" value="0004051310"/>
        </properties>
   </persistence-unit>
</persistence>

2008/2/14, Carlos Díez Fernández <carlosdf@gmail.com>:
>
> Hello, i'm developing a java2se app with OpenJPA (1.0.1) and PostgreSQL (
> 8.1)
> and i think i have a problem with the build.xml and persistence.xml files
> because
> when i try to run the application i get this error:
>
>      [java] java.lang.reflect.InvocationTargetException
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>      [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>      [java]     at java.lang.reflect.Method.invoke(Unknown Source)
>      [java]     at
> sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
>      [java]     at
> sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
>      [java] Caused by: java.util.MissingResourceException:
> org.apache.openjpa.persistence.PersistenceProductDerivation:java.io.IOException:
> org.xml.sax.SAXException:
> file:/C:/Documents%20and%20Settings/Carlos/Escritorio/workspace/PajitaDatabase/META-INF/persistence.xml
> [Location: Line: 17, C: 20]: org.xml.sax.SAXParseException:
> cvc-complex-type.2.4.d: Invalid content was found starting with element
> 'jta-data-source'. No child element is expected at this point.
>      [java]     at
> org.apache.openjpa.lib.conf.ProductDerivations.reportErrors(
> ProductDerivations.java:351)
>      [java]     at org.apache.openjpa.lib.conf.ProductDerivations.load(
> ProductDerivations.java:341)
>      [java]     at
> org.apache.openjpa.lib.conf.ProductDerivations.loadDefaults(
> ProductDerivations.java:307)
>      [java]     at
> org.apache.openjpa.lib.conf.Configurations.populateConfiguration(
> Configurations.java:324)
>      [java] FATAL ERROR in native method: processing of -javaagent failed
>      [java]     at
> org.apache.openjpa.enhance.PCEnhancerAgent.registerClassLoadEnhancer(
> PCEnhancerAgent.java:93)
>      [java]     at org.apache.openjpa.enhance.PCEnhancerAgent.premain(
> PCEnhancerAgent.java:79)
>      [java]     ... 6 more
>
> Maybe it's a classpath error? I must include the jdbc postgresql jar in
> the classpath?
> :S
>
> Here are my persistence.xml file:
>
> <?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="pajitamusic" transaction-type="JTA">
>         <description>pajitadb</description>
>         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl
> </provider>
>         <properties>
>             <property name="openjpa.jdbc.DBDictionary" value="postgres"/>
>             <property name="openjpa.jdbc.SynchronizeMappings"
> value="false"/>
>             <property name="openjpa.ConnectionDriverName" value="
> org.postgresql.Driver"/>
>             <property name="openjpa.ConnectionURL"
>                    value="jdbc:postgresql://localhost:5432/pajitadb"/>
>             <property name="openjpa.ConnectionUserName" value="postgres"/>
>             <property name="openjpa.ConnectionPassword"
> value="0004051310"/>
>         </properties>
>         <jta-data-source>pajitamusic</jta-data-source>
>         <non-jta-data-source>pajitamusic</non-jta-data-source>
>         <!-- We must enumerate each entity in the persistence unit -->
>         <class>com.pajitamusic.ear.Song</class>
>         <class>com.pajitamusic.ear.Album</class>
>         <class>com.pajitamusic.ear.Artist</class>
>         <class>com.pajitamusic.ear.PUser</class>
>         <class>com.pajitamusic.ear.UserSong</class>
>    </persistence-unit>
> </persistence>
>
> And here is my build.xml file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="pajitamusic" default="run">
>     <property name="root" value="${basedir}"/>
>     <property name="srcdir" value="${basedir}/src/com/pajitamusic/ear"/>
>     <property name="openjpadir" value="C:/Documents and
> Settings/Carlos/Escritorio/OpenJPA/apache-openjpa-1.0.1/" />
>     <property name="psqljdbcdir" value="C:/Archivos de
> programa/PostgreSQL/8.1/jdbc/" />
>
>     <path id="classpath"
>         description="The classpath to use for compiling and running">
>         <pathelement path="${root}"/>
>         <pathelement path="${root}/src"/>
>         <fileset dir="${openjpadir}/lib">
>             <include name="*.jar"/>
>         </fileset>
>         <fileset dir="${openjpadir}">
>             <include name="openjpa-*.jar"/>
>         </fileset>
>         <fileset dir="${psqljdbcdir}">
>             <include name="postgresql-8.1-410.jdbc3.jar" />
>         </fileset>
>     </path>
>
>     <path id="javaagent">
>         <fileset dir="${openjpadir}">
>             <include name="openjpa-*.jar"/>
>         </fileset>
>     </path>
>
>     <pathconvert property="javaagent" refid="javaagent"/>
>
>     <target name="compile"
>        description="Compile the pajita java files">
>         <javac srcdir="${srcdir}" classpathref="classpath"
>            debug="yes" includes="**.java"/>
>     </target>
>
>     <target name="run" depends="compile"
>             description="Run the Main program">
>         <java classname="com.pajitamusic.ear.Main"
> classpathref="classpath" fork="yes"
>             failonerror="yes">
>             <!--
>                 Specifying the openjpa jar as the javaagent argument is
>                 necessary in order for automatic class-enhancement to
> work.
>             -->
>             <jvmarg value="-javaagent:${javaagent}"/>
>
>             <!--
>                 Specify the system properties to use when configuring
>                 OpenJPA. Note that these will only be used becuase,
>                 the call to "Persistence.createEntityManagerFactory"
>                 is passed "System.getProperties()".
>             -->
>
>             <sysproperty key="openjpa.ConnectionDriverName"
>                 value="${dbdriver}"/>
>             <sysproperty key="openjpa.ConnectionURL" value="${dburl}"/>
>             <sysproperty key="openjpa.ConnectionUserName"
> value="${dbuser}"/>
>             <sysproperty key="openjpa.ConnectionPassword"
> value="${dbpass}"/>
>
>             <!--
>                 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.
>             -->
>             <sysproperty key="openjpa.jdbc.SynchronizeMappings"
>                 value="buildSchema"/>
>
>             <!--
>                 Output all the SQL for educational purposes, but set the
>                 general logging level to only show warnings.
>             -->
>             <sysproperty key="openjpa.Log"
>                 value="DefaultLevel=WARN,SQL=TRACE"/>
>         </java>
>     </target>
>
>     <target name="clean"
>         description="Clean up compiled files and generated database
> files">
>         <delete includeemptydirs="yes">
>             <fileset dir="${srcdir}">
>                 <include name="*.class"/>
>                 <include name="*.log"/>
>             </fileset>
>         </delete>
>     </target>
> </project>
>

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