How I can use com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl on WebSphere instead com.ibm.xtq.xslt.jaxp.TransformerImpl?

I have java application on WebSphere 8.5.5. I use xslt transformer from jdk. When I used console version I could use jdk version of transformer. Now, I switched to WebSphere. When I create a TransformerImpl, it is created fromIbm. It has a lot of bugs. I need normal version from jdk. I can't use Xalan 2.7.2 because it works more slowly. I can'y use Saxon because I can't rewrite thousands xslt to version '2.0'. Saxon doesn't work well with xslt 1.0.

Upvotes: 0

Views: 3921

Answers (1)

DefyGravity
DefyGravity

Reputation: 6031

This can break a lot. Plan for this to take a while to fix. I do not have a websphere server 8.5.5 anymore. So I cannot test these instructions, so the best I hope to do with this answer is to give you a place to start.

  1. Set your Websphere application class loader policy to parent last, and hope this change does not cause more issues than it fixes. This must be done to override the newer Xalan version that comes with Websphere. Here is a link to IBM's instructions

  2. Test your application. I hope you do not have to follow any of the instructions below.

If you do not think it is working, then you must make sure that your Websphere server is setup for Multiple Class loaders

admin screen picture of the settings drop down

A warning, IBM has their own JDK. Just like Oracle's java jdk, and open-jdk. Websphere 8.5.5 will run an IBM JDK based JVM by default. Even if the sever operating system's default java -version is an Oracle or openjdk based, IBM may still go find its IBM JDK based JVM. Your bugs may be coming from the IBM JDK. Have someone double check here while you keep working on this.

IBM jdk settings you'll need can be found here. Changing some of these settings in #1 or #2 below will change how Websphere processes its internal xml. At worst, Websphere will not start. At best, all parent first class loader policy applications also need to be retested.

from IBM jdk's class loader documentation:

  1. The system property with the same name as the service provider.
  2. The service provider specified in a properties file.
    • For XMLEventFactory, XMLInputFactory, and XMLOutputFactory only. The value of the service provider in the file /opt/ibm/java--70/jre/lib/stax.properties.
    • For other factories. The value of the service provider in the file /opt/ibm/java--70/jre/lib/jaxp.properties.
  3. The contents of the your-war-file/META-INF/services/<service.provider> file.
  4. The default service provider.

the services/<you.must.make.the.service.provider.file.name> and the services directory may not exist.

For your problem, make the /META-INF/services/javax.xml.transform.TransformerFactory file, and its contents will be the name of the .class file you wish to use for those j2EE services. Pick One line:

your.j2EE.java.xml.transform.TransformerFactoryImpl.goes.here - and make sure the Impl's .class files are in your classpath

or

com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl - Websphere's Xalan jar

or

com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl - Websphere's Default

I cannot determine from your question which TransformerFactoryImpl name you need from your question.

Test your application, and I hope this helped you.

Upvotes: 0

Related Questions