This page is divided into two sections. The first section - titled "Troubleshooting Steps" provides step-by-step instructions 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.
- The DWR test page - Check the DWR test page and execute any problem methods from the test page.
- Everything works from the DWR test page, but not from a custom page. What should I do?
- The DWR test page does not come up, my exposed class does not show up on the test page, or my method call does not work from the test page. What should I do?
- Your Java code - Have you verified it is not your Java code causing the problem?
- General Tips
- Use the server logs
- Use an HTTP Debugging proxy/Sniffer to examine the request/response.
- If all else fails? Search for your issue on the DWR users mailing list, if you can't find a solution send a message to the mailing list. Make sure you include all of the information you have gathered from your troubleshooting!
Accessing the DWR test page
- The test page is located at http://yourwebapp:yourport/dwr/index.html.
- You must have the debug param set to true on the
DWRServlet (in your web.xml) to access the test page.
- You should remove the debug param or set it to false in a production environment.
- DWR is properly configured - Don't waste time looking at the server (dwr.xml, web.xml, logs, etc.)
- Simplify, Simplify, Simplify - Trim your script and simplify it as much as possible. If you are using any third party libraries remove them.
- dwr.jar and commons-logging.jar - Verify that both jars are in your applications WEB-INF/lib directory.
- dwr.xml - Verify your dwr.xml is in your WEB-INF directory and that it is valid and contains all of the necessary creators and converters. Verify that all classes being created or converted by DWR are in your applications classpath (WEB-INF/lib, WEB-INF/classes).
- web.xml - Verify your web.xml is in your WEB-INF directory and that it contains the necessary servlet definitions and mapping for DWR.
- Server logs - If all else fails check the server's log files. DWR generally provides detailed logging and any errors will surely end up in your logs.
- Simplify, Simplify, Simplify - Once again, simplify, simplify, simplify. Trim your logic and simplify it as much as possible. Verify that your Java code works outside of DWR.
Are you sure it is not your own Java code causing the problem? Make sure it isn't by testing your Java code outside of DWR. If everything is working in your test case try debugging through your code when called from DWR to see if you can isolate the problem.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.
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 errorA failure to add the commons-logging.jar into your application's classpath will result in the following error:
SEVERE: No converter found for 'dwr.book.model.User'
SEVERE: StandardWrapper.ThrowableThe logs are there for a reason -- use them. Many times reading the logs will guide you to a quick solution.
at java.lang.Class.forName0(Native Method)
- Firefox - Firebug is the most popular tool for debugging in Firefox. If you are unfamiliar with Firebug the "Introduction To Firebug" on the Firebug Wiki will help you get started.
- Google Chrome - Google Chrome has advanced developer tools built-in. For more information view the Google Chrome documenation.
- Internet Explorer - Internet Explorer 8 has build in development tools. You can read more about these tools on MSDN. If you are using a version of IE older than 8 you may use Firebug Lite.
- Other Browsers - Please search for the browser you are using to find out what tools are available. If your browser does not have built-in debugging tools check Firebug Lite for compatibility.
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:
- Wireshark - Wireshark is free, very powerful, and highly recommended.
- Fiddler - Fiddler is free, has a lot of nice features and is stable.
- Charles - Charles can be purchased for a small fee and has a lot of nice features. One of my favorite features is the bandwidth throttler that allows you to simulate different connection conditions.
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.
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
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.
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:
- 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.