users@glassfish.java.net

orm.xml not being used? (either ignored or ValidationException)

From: Tom Mutdosch <tommut_at_csh.rit.edu>
Date: Tue, 30 Jan 2007 09:14:46 -0500

Hi all,

I am having a problem with my orm.xml not being found in a JSF web
application running on Glassfish (glassfish-installer-v2-b32.jar).

I have entities that I am persisting to a DB2 database, and I want to
set the default schema. Rather than setting the schema annotation on
every Java entity, I want to specify it in the orm.xml file. The path
is /META-INF/orm.xml (next to persistence.xml) and it looks like:

<?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 orm_1_0.xsd"
               version="1.0">
  <persistence-unit-metadata>
       <persistence-unit-defaults>
           <schema>ADMINISTRATOR</schema>
       </persistence-unit-defaults>
   </persistence-unit-metadata>
</entity-mappings>

However when I try to execute a query on my entity, I get a DB2 error as
it is still incorrectly using the default DB2 schema, and not the one I
specified:
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE:
42704, SQLERRMC: DB2ADMIN.DEPARTMENT

I then tried to place the mapping information in a separate
/META-INF/mappings.xml and pointed to it from my persistence.xml:
 <mapping-file>/META-INF/mappings.xml</mapping-file>

In this case, when I run on the server I get the following exception:
Exception [TOPLINK-7252] (Oracle TopLink Essentials - 9.1 (Build b32)):
oracle.toplink.essentials.exceptions.ValidationException
Exception Description: There are multiple mapping files called
[/META-INF/mappings.xml] in classpath for persistence unit named [ pu ].

Does anyone know what might be causing this?

Thanks
Tom