This page is divided into two sections. The first section - titled "Troubleshooting" provides advice to follow if you encounter problems configuring or using DWR. The second section - title "Common Problems and Fixes" lists several common problems and their associated fixes.

Troubleshooting

Using the DWR test page

If you encounter problems using DWR your first step should be to check the DWR test page. The test page displays all classes available to DWR and allows you to invoke methods on those classes. If a method call works from the test page you have properly installed and configured DWR.

Accessing the DWR test page
What to do when things work from the DWR test page, but do not work from a custom page
This situation indicates that you have a Javascript problem on your custom page.
What to do when things don't work from the DWR test page or a custom page
This situation indicates that DWR is not properly configured.
Using the server logs

The chances are if you encounter an error DWR will be logging the cause of the error in the server logs. Many times the errors in the log can quickly lead you to a fix for the problem you are experiencing. Here are a few examples:

A failure to configure a converter for a class that DWR needs to serialize will result in the following error:

Jul 22, 2008 2:37:58 PM org.directwebremoting.util.CommonsLoggingOutput error
SEVERE: No converter found for 'dwr.book.model.User'
A failure to add the commons-logging.jar into your application's classpath will result in the following error:
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.directwebremoting.dwrp.PollHandler.<clinit>(PollHandler.java:382)
at java.lang.Class.forName0(Native Method)
The logs are there for a reason -- use them. Many times reading the logs will guide you to a quick solution.
Debugging with Firebug or dwr.util.toDescriptiveString

Firebug is an invaluable tool when you are having problems with your DWR application and need to inspect what you are sending to or receiving from DWR. Firebug is an add-on for Firefox that allows you to:

You can learn more about Firebug and download it on the Firebug site. If you would like to use Firebug with a browser other than Firefox take a look at Firebug Lite.
dwr.util.toDescriptiveString

If for some reason you cannot use Firebug the dwr.util.toDescriptiveString function will allow you to display the JavaScript objects you are sending to or receiving from DWR. This function is located in DWR's util.js and you must include this file in your HTML page in order to use it. The function takes three arguments:

  1. The JavaScript object you would like to display.
  2. The depth you would like to traverse the object.
  3. An options object that can be used to customize the display.
You can read more about the dwr.util.toDescriptiveString method in the DWR manual.
Using an HTTP Debugging Proxy

HTTP debugging proxies are a nice tool to have in your arsenal. These tools allow you to inspect all HTTP traffic and even manipulate incoming/outgoing data. A few we recommend are:

Using a Java Debugger

Many developers new to the web don't bother setting up a debugging environment. I feel this is a mistake. It is easy to do and you can learn a lot by stepping through code. Setting up a debugging environment is specific to your IDE and servlet container/application server and beyond the scope of our documentation. I recommend looking into the options that are available for the development environment you are working in.

Common Problems and Fixes

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.

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.

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 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:

Still having problems?

If you can't find a solution here then please join the mailing list and ask there.