简体   繁体   中英

Dozer 5.3.2 on Oracle Weblogic 10.3.6

I have a problem running Dozer 5.3.2 on Oracle Weblogic 10.3.6. If I run Dozer in the container following exception occurs. In my JUnit tests Dozer works fine.

java.lang.IllegalArgumentException   
oracle.xml.jaxp.JXDocumentBuilderFactory.setAttribute(JXDocumentBuilderFactory.java:147) 
weblogic.xml.jaxp.RegistryDocumentBuilderFactory.setAttribute(RegistryDocumentBuilderFactory.java:176) 
org.dozer.loader.xml.XMLParserFactory.createDocumentBuilderFactory(XMLParserFactory.java:56) 
org.dozer.loader.xml.XMLParserFactory.createParser(XMLParserFactory.java:35) 
org.dozer.loader.xml.MappingFileReader.<init>(MappingFileReader.java:46) 
org.dozer.loader.CustomMappingsLoader.<init>(CustomMappingsLoader.java:52) 
org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:212) 
org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:186) 
org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111) 
myProject.myObject.MyDefaultMapper.map(MyDefaultMapper.java:23) 
myProject.myObject.mapToClientDS(XYZService.java:162) 
myProject.myObject.read(XYZService.java:42) 
myProject.myObject.search(MyController.java:64) 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
java.lang.reflect.Method.invoke(Method.java:597) 
com.sun.el.parser.AstValue.invoke(Unknown Source) 
com.sun.el.MethodExpressionImpl.invoke(Unknown Source) 
oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:173) 
.... 
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

The Problem seems to be following method in org.dozer.loader.xml.XMLParserFactory :

private DocumentBuilderFactory createDocumentBuilderFactory() { DocumentBuilderFactory     
factory = DocumentBuilderFactory.newInstance(); 
factory.setValidating(true); 
factory.setNamespaceAware(true); 
factory.setIgnoringElementContentWhitespace(true); 
factory.setAttribute(SCHEMA_FEATURE, true); // For Xerces implementation 
return factory; }

This method sets factory.setAttribute(SCHEMA_FEATURE, true) . The Oracle implementation does not support the attribute SCHEMA_FEATURE and throws an IllegalArgumentException including the following stack trace:

oracle.xml.jaxp.JXDocumentBuilderFactory.setAttribute(JXDocumentBuilderFactory.java:147) 
weblogic.xml.jaxp.RegistryDocumentBuilderFactory.setAttribute(RegistryDocumentBuilderFactory.java:176)

I have also tried to replace the oracle implementation of JAXP with Xerces. I have done it by configuring <prefer-web-inf-classes>true</prefer-web-inf-classes> in WEB-INF/weblogic.xml and adding the Xerces libraries to the libraries wich are deployed. But if I try to replace the libraries I receive following exception while deploying the application. I have tried Xerces 2.11.0 (JAXP 1.4) and also Xerces 2.9.1 (JAXP 1.3, which should be the right replacement for Weblogic 10.3.6). ( xercesImpl.jar , xml-apis.jar )

Caused By: java.lang.NoSuchMethodError: 

org.apache.xerces.impl.xpath.regex.RegularExpression.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Locale;)V at 

org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets(Unknown Source) at 

org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets1(Unknown Source) at 

org.apache.xerces.impl.dv.xs.BaseSchemaDVFactory.createBuiltInTypes(Unknown Source) at 

org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.createBuiltInTypes(Unknown Source) at 

org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(Unknown Source) Truncated. see log file for complete stacktrace

f you look in the sourcecode of org.apache.xerces.impl.xpath.regex.RegularExpression you will see that RegularExpression has following ctors in version 2.11.0:

(String a) 
(String b, String d) 
(String c, String f, Locale l) 
(String d, Token t, int p, boolean h, int o)

RegularExpression has following ctors in version 2.9.1:

(String a) 
(String b, String d) 
(String c, Token t, int p, boolean h, int o) 

So I can´t unterstand why the exception occurs for both versions.

I also have tried to configure xerces to be loaded by the filter classloader by configuring <prefer-application-packages> <package-name>org.apache.xerces.*<package-name> but that results in ClassCastException s because implementations were mixed up.

I hope somebody can help me to run Dozer on WebLogic 10.3.6.

Regards,

Max

I came to the similar situation.

I have not found any better way but remove file javax.xml.parsers.DocumentBuilderFactory in your jar file META-INF can make it work. But maybe cause another issue.

The problem can be solved changing the class loading order. Add the file weblogic-application.xml with the next content:

<prefer-application-packages>
  <package-name>org.dozer.*</package-name>
  <package-name>org.apache.*</package-name>
  <package-name>antlr.*</package-name>    
</prefer-application-packages>                      

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM