You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Zoran Regvart (JIRA)" <ji...@apache.org> on 2013/11/22 16:40:35 UTC
[jira] [Created] (OPENJPA-2458) XMLFactory caches JAXP
implementations that could be reloaded which will cause ClassCastExceptions
Zoran Regvart created OPENJPA-2458:
--------------------------------------
Summary: XMLFactory caches JAXP implementations that could be reloaded which will cause ClassCastExceptions
Key: OPENJPA-2458
URL: https://issues.apache.org/jira/browse/OPENJPA-2458
Project: OpenJPA
Issue Type: Bug
Components: kernel
Environment: When running on application servers and application ships with it's own JAXP implementation
Reporter: Zoran Regvart
XMLFactory caches JAXP implementations in _saxFactories and _domFactories fields if those JAXP implementations are reloaded, such as when they originate from application that is deployed in a application server and the application is restarted or redeployed -- ClassCast exception could (depending on classloading) ensue.
Consider an application that ships it's own JAXP implementation (e.g. Sun JAXP RI), which contains META-INF/services/javax.xml.parsers.DocumentBuilderFactory or SAXParserFactory and a application server that ships with OpenJPA (e.g. IBM WebSphere). If that application is the first that uses OpenJPA it's JAXP implementation will be used and cached in the org.apache.openjpa.lib.xml.XMLFactory fields _saxFactories and _domFactories. If the application is restarted then new versions of JAXP implementation classes are loaded in a new classloader. This causes ClassCastException, such as:
{code}
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration incompatible with com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration
at com.sun.org.apache.xerces.internal.parsers.DOMParser.(DOMParser.java:177)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.(DOMParser.java:161)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.(DocumentBuilderImpl.java:159)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:115)
at org.apache.openjpa.lib.xml.XMLFactory.getDOMParser(XMLFactory.java:107)
at org.apache.openjpa.jdbc.sql.SQLErrorCodeReader.parse(SQLErrorCodeReader.java:107)
at org.apache.openjpa.jdbc.sql.DBDictionary.endConfiguration(DBDictionary.java:4718)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:531)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:456)
at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:199)
at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:66)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:579)
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1518)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:531)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:456)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:949)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:940)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:346)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:333)
{code}
The only way I see that this could be fixed is not to cache the JAXP implementations, or to cache them in an application specific cache thats tied to EntityManager, and not to global OpenJPA state.
--
This message was sent by Atlassian JIRA
(v6.1#6144)