Luis Muñoz created OPENJPA-2560:
------------------------------------

             Summary: Multiple persistence unit found on tomcat 6
                 Key: OPENJPA-2560
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2560
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa, kernel
    Affects Versions: 2.2.1, 2.2.0
         Environment: Suse Enterprise 11 SP3
tomcat6-6.0.18
            Reporter:  Luis Muñoz


Persistence unit will be reported as duplicated on SuSE tomcat 6 installation 
due to directory structure containing symbolic links. Reported as 'Major' 
because it affects performance when creating entity factory.

503  domain-persistence  WARN   [http-8080-9] openjpa.MetaData - Found 
duplicate metadata or mapping for "class 
com.mydomain.testpkg.persistence.entity.entity1".  Ignoring.
1503  domain-persistence  WARN   [http-8080-9] openjpa.MetaData - Found 
duplicate metadata or mapping for "class 
com.mydomain.testpkg.persistence.entity.entity2".  Ignoring.
... < more similar messages>
1503  domain-persistence  WARN   [http-8080-9] openjpa.MetaData - Found 
duplicate metadata or mapping for "class 
com.mydomain.testpkg.persistence.entity.entitynn".  Ignoring.
3769  domain-persistence  INFO   [http-8080-9] openjpa.Runtime - A down level 
Entity was detected and logged. Please enable RUNTIME trace to see all down 
level Entities.
3695  domain-persistence  WARN   [http-8080-3] openjpa.Runtime - The 
persistence unit "testpkg-persistence-pu" was found multiple times in the 
following resources 
"[jar:file:/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar!/META-INF/persistence.xml,
 
jar:file:/usr/share/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar!/META-INF/persistence.xml]",
 but persistence unit names should be unique. The first persistence unit 
matching the provided name in 
"jar:file:/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar!/META-INF/persistence.xml"
 is being used.

4103  domain-persistence  INFO   [http-8080-9] openjpa.Runtime - OpenJPA 
dynamically loaded a validation provider.
4128  domain-persistence  INFO   [http-8080-21] openjpa.Runtime - Starting 
OpenJPA 2.2.1


There's only one physical jar file at 
/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar
 but openjpa search mechanism will think there are two different jars.

jar:file:/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar!/META-INF/persistence.xml
jar:file:/usr/share/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persistence-ext.jar!/META-INF/persistence.xml

On the directory structure it can be seen /usr/share/tomcat6/webapps points to 
/srv/tomcat6/webapps

ls -l /usr/share/tomcat6
total 4
drwxr-xr-x 2 root root 4096 Jan 30  2014 bin
lrwxrwxrwx 1 root root   12 Jan 30  2014 conf -> /etc/tomcat6
lrwxrwxrwx 1 root root   15 Jan 30  2014 lib -> ../java/tomcat6
lrwxrwxrwx 1 root root   16 Jan 30  2014 logs -> /var/log/tomcat6
lrwxrwxrwx 1 root root   23 Jan 30  2014 temp -> /var/cache/tomcat6/temp
lrwxrwxrwx 1 root root   20 Jan 30  2014 webapps -> /srv/tomcat6/webapps
lrwxrwxrwx 1 root root   18 Jan 30  2014 work -> /var/cache/tomcat6

There's a partial workaround to overcome most of the 'Found duplicate metadata 
or mapping' messages. The appBase attribute of <Host> can be changed at 
/etc/tomcat6/server.xml to point to an absolute path instead of a path relative 
to CATALINA_BASE or CATALINA_HOME 

      <Host name="localhost"  appBase="/srv/tomcat6/webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

The "multiple times" error will persist even if only one jar is mentioned after 
the workaround was applied:

1255  testpkg-persistence-pu  WARN   [http-8080-1] openjpa.MetaData - Found 
duplicate metadata or mapping for "class 
com.mydomain.testpkg.persistence.entity.entity1".  Ignoring.
3571  testpkg-persistence-pu  INFO   [http-8080-1] openjpa.Runtime - A down 
level Entity was detected and logged. Please enable RUNTIME trace to see all 
down level Entities.
3580  testpkg-persistence-pu  WARN   [http-8080-1] openjpa.Runtime - The 
persistence unit "testpkg-persistence-pu" was found multiple times in the 
following resources 
"[jar:file:/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/medx-persistence-ext.jar!/META-INF/persistence.xml]",
 but persistence unit names should be unique. The first persistence unit 
matching the provided name in 
"jar:file:/srv/tomcat6/webapps/testpkg-domain-wsvc/WEB-INF/lib/testpkg-persist
ence-ext.jar!/META-INF/persistence.xml" is being used.
3671  testpkg-persistence-pu  INFO   [http-8080-1] openjpa.Runtime - OpenJPA 
dynamically loaded a validation provider.
3925  testpkg-persistence-pu  INFO   [http-8080-1] openjpa.Runtime - Starting 
OpenJPA 2.2.1




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to