Eclipse tips
Debug Tomcat
You can debug your OpenKM installation using the Tomcat logging facility. This is useful when you have problems with your configuration. The default OpenKM installation logs important events such as errors and warnings. It is possible to change this configuration by editing the file $TOMCAT_HOME/conf/logging.properties.
The default Tomcat log configuration can generate a lot of messages. These files are stored in $TOMCAT_HOME/logs.
Debug remote Tomcat server
When you have problems in the production environment, this configuration is especially useful.
Add the following options when the JVM is started:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Or, if you are using shell scripts to start Tomcat, start it with the following command (recommended):
$ $TOMCAT_HOME/bin/catalina.sh jpda start
It will start Tomcat so that a remote debugger can connect to port 8000.
More information is available at:
Eclipse configuration
Open Eclipse "Debug configurations", then choose "Remote Java Application", right-click and choose "New".
Set the "host" and "port" of the remote server:
Include your OpenKM Java project in the Source tab:
You can debug normally by setting breakpoints, etc.
Debug GWT frontend user interface with GWT Super Dev Mode
Super Dev Mode is available from GWT version 2.5.0.RC1. More information at GWT 2.5.0.RC1 Release notes.
You can find additional information at:
- GWT Super Dev Mode official site.
Enable source for debugging
Edit the pom.xml file and uncomment this section:
<!-- Only for development -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
Uncomment the xsiframe section in the Main.gwt.xml file:
<!--
Use GWT 2.7.0 to debug in Firefox -->
<add-linker name="xsiframe"/>
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
<set-configuration-property name="devModeUrlWhitelistRegexp" value="http://(localhost|127\.0\.0\.1|192\.168\.1\.34)(:\d+)?/.*" />
Eclipse configuration
Open Eclipse "Debug configurations", then choose "Java Application", right-click and choose "New".
Set the Main class field value:
com.google.gwt.dev.DevMode
Select the "Arguments" tab and set the "program arguments" field value:
-bindAddress 0.0.0.0 -src src/ com.openkm.frontend.Main
And set the "VM arguments" field value:
-Xms2048m
Select the "JRE" tab and set the "OpenJDK version":
You should choose OpenJDK 1.8.x.
Select the "Classpath" tab and add the folder /openkm/src/main (use the "Advanced" button and the "Add Folder" option):
Add GWT JAR dependencies with the Add External JARs button:
The version of the JAR files below might change.
The javax.servlet-api-3.1.0 resolves a java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionIdListener. That happens from version 2.8.x and above.
- gwt-user-2.8.2.jar
- gwt-dev-2.8.2.jar
- gwt-user-2.8.2.jar
- javax.servlet-api-3.1.0
Now you can run the Super Dev Mode. At the end of the log, the URL where the service is bound is shown:
Open the code server URL in your Chrome browser and drag the bookmarklets to your bookmarks bar:
Open your OpenKM frontend URL in Chrome browser and then click the option in your bookmark bar "Dev Mode On" you dragged in the previous step. It will show a popup with a Compile button. Click the "Compile" button.
Finally, open the Chrome developer tools, and from the sources tab you will have the OpenKM Java code available, where you can set breakpoints, watch variables, etc:
Debug GWT frontend user interface with GWT Shell
GWT Shell is deprecated and has been removed in GWT version 2.5.1. More information at GWT 2.5.1 Release notes.
You can debug the GWT frontend with GWT Shell (which has extension support for Firefox browsers 2.4 and older) or GWT Super Dev Mode (we suggest using Chrome in this scenario).
In the documentation section below, we have tried to explain how to get the old GWT Shell working with Eclipse. The sample below shows how to debug GWT from localhost, but it is also possible to debug remotely.
You can find additional information at:
- GWT Shell official site.
Enable source for debugging
Edit the pom.xml file and uncomment this section:
<!-- Only for development -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
Eclipse configuration
Open Eclipse "Debug configurations", then choose "Java Application", right-click and choose "New".
Set the Main class field value:
com.google.gwt.dev.DevMode
Select the "Arguments" tab and set the "program arguments" field value:
-port 8080 -noserver -startupUrl /OpenKM/frontend/index.jsp com.openkm.frontend.Main
And set the "VM arguments" field value:
-Xms1024m -Xmx2048M -XX:PermSize=64m -XX:MaxPermSize=1024m
Select the "JRE" tab and set the "OpenJDK version":
You should choose OpenJDK 1.8.x.
Select the "Classpath" tab and add the folder /openkm/src/main (use the "Advanced" button and the "Add Folder" option):
Now you can run the GWT Shell.
To debug login, enter the following in your browser:
You can remotely debug GWT simply by changing localhost to your remote URL. Keep in mind you are executing GWT code from Eclipse, not the remote one. Ensure your local GWT code version is the same as the version compiled on the remote server.
http://localhost:8080/OpenKM/frontend/index?gwt.codesvr=127.0.1.1:9997
You can debug in Eclipse, view variable values, etc.