TransformerFactoryConfigurationError
This problem shows up as the following stack trace when starting a DWR enabled webapp:
root cause
javax.xml.transform.TransformerFactoryConfigurationError:
Provider org.apache.xalan.processor.TransformerFactoryImpl not found
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
This doesn't really have much to do with DWR, it's caused by Tomcat not being setup properly. The quick answer is to download Xalan and place xalan.jar into $TOMCAT-HOME/common/lib. DWR 2.0 copes with this problem better than DWR 1.x, but the core problem is still that DWRs XML serialization support requires an XSLT parser.
If you have this problem with JDK 5 then it has been reported that the following VM parameter will kick Tomcat into action.
-Djavax.xml.transform.TransformerFactory= com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
XML Parser Errors
The most common error when getting started with DWR is an XML parser error. It has nothing to do with DWR, and is due to your installation of Tomcat having Xerces installed when it shouldn't or not installed when it should.
- JDK 1.3 didn't come with an XML parser, so you will need xercesImpl.jar and xml-apis.jar for that case.
- JDK 1.4.0 and JDK 1.4.1 did come with an XML parser but it was buggy so you may need to override the default by putting xercesImpl.jar into the tomcat\common\endorsed directory.
- JDK 1.4.2 and JDK 5 come with a fully working XML parser and you shouldn't need one at all.
In addition to these issues, various version of Tomcat either came with XML parsers or had add-on packages that included them. It's important to check that you have the correct add-on packages for your JDK version.
Classpath Issues With BEA Weblogic
Weblogic 8.1 (and maybe other versions) can make it hard for DWR to find classes.
This can happen if dwr.jar is being used from an APP-INF directory (i.e. APP_INF/lib). Under these circumstances DWR will still appear to function, the debug pages will be visible for example, however it will have trouble finding your classes.
The solution is to place dwr.jar into your WEB-INF/lib directory.
Support for DWR without cookies
The servlet spec supports using URL re-writing to support HttpSessions when cookies are turned off. DWR 2.x supports this with the URLs it creates. DWR 1.x however does not. You can alter DWR 1.x to support cookies with the following procedure:
- Extract engine.js from dwr.jar and save it to the filesystem as a jsp file.
- Inside the "
DWREngine._sendData = function(batch)" method, add one line:statsInfo += ";jsessionid=" + <%="'"+session.getId()+"'"%>
This hack allows DWR 1.x to support url-rewriting. DWR 2+ supports this by default.
DWR and Multiple IEs on one machine
Microsoft discourage people from using multiple versions of IE on a single machine, even though there are solutions like Tredosof Multiple IE. The issue is that you never really have a full installation of the non-system browser. Cookie support is one area where multiple versions of IE breaks, which can cause problems with DWR's cross-domain security.
Probably the best solution is to use Virtual PC. This is Microsoft's recommended solution.
Alternatively you could disable DWRs cross domain security feature, by adding this parameter to your web.xml in the DWR servlet section:
<init-param>
<!-- fix for multiple IEs on one machine. Remove this before going live -->
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
Annotations and Websphere
Websphere is rather late to support Java5 and some versions of Websphere react strangely when Java5 code is found. DWR 1.x contains no Java5 specific code so there is no issue there. DWR 2.x contains optional Java5 support. The vast majority of the JAR file was compiled with JDK 1.3 however the Annotations support was compiled with JDK 1.5. Normally a 1.4 JVM will throw an exception that DWR can catch using a normal try/catch mechanism, however for some reason the IBM 1.4 JVM seems to throw a magic uncatchable exception!. The following console message maybe found with Websphere / DWR 2.x.
TRAS0014I: The following exception was logged java.lang.LinkageError: LinkageError while defining class: org.directwebremoting.annotations.AnnotationsConfigurator Could not be defined due to: org/directwebremoting/annotations/AnnotationsConfigurator (Unsupported major.minor version 49.0) This is often caused by having a class defined at multiple locations within the classloader hierarchy. Other potential causes include compiling against an older or newer version of the class that has an incompatible method signature. ...
If this prevents DWR from working, there are 2 solutions:
- Download the source and remove org.directwebremoting.annotations.AnnotationsConfigurator.java before building
- Since dwr.jar is just a .zip file it is simple to open the file in a .zip editor and remove the offending class: org/directwebremoting/annotations/AnnotationsConfigurator.class
Still having problems?
If you can't find a solution here then please join the mailing list and ask there.