Debugging

Last modified by Marius Dumitru Florea on 2017/08/25 12:03

The GWT WYSIWYG editor is no longer available starting with XWiki 9.7. It has been replaced by CKEditor.

Eclipse with GWT

Download and install GWT

Download a recent XWiki snapshot

Import gwt projects into workspace

Checkout source code for e.g. xwiki/xwiki-platform from Github, which is described here .

Go into project directory "./xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-client/", open a command prompt and run the following command to prevent Eclipse from importing the project as maven project.

>mvn eclipse:clean eclipse:eclipse

If you have never done this before, have a look at Building XWiki from sources

Add the following preferences to the "maven-eclipse-plugin" and "gwt-maven-plugin" plugin in "./xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-client/pom.xml"

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
 <projectNameTemplate>[groupId].[artifactId]</projectNameTemplate>
 <addGroupIdToProjectName>false</addGroupIdToProjectName>
 <wtpversion>2.0</wtpversion>
 <projectnatures>
  <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
  <nature>org.eclipse.jdt.core.javanature</nature>
  <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
  <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
  <nature>com.google.gwt.eclipse.core.gwtNature</nature>
 </projectnatures>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
 <includes>org/xwiki/gwt/wysiwyg/WysiwygTestSuite.java</includes>
 <buildOutputDirectory>${webappDirectory}/WEB-INF/classes</buildOutputDirectory>
 <module>org.xwiki.gwt.wysiwig.Wsyiwyg</module>
 <webappDirectory>${webappDirectory}</webappDirectory>
 <hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>

Within adding this you have to skip the Checkstyle configurations to be able to build the project by adding <skip>true</skip>.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
 <skip>true</skip>
</configuration>
</plugin>

Open Eclipse, go to the Package Explorer and right-click Import...> Existing Projects into Workspace> xwiki-platform-wysiwyg-client. After that you may have errors in your project. To solve this delete the target folders and run

>mvn clean install

Debug Configurations

Next right-click on Project Debug As...> Debug Configurations and set configurations as shown on the following images.

Go to Web Application> New launch configuration to the Main tab, set

  • the Project (e.g. "xwiki-platform-wysiwyg-client")
  • and Main class "com.google.gwt.dev.DevMode".

xwiki-wysiwyg-plugins-1-project-debug-configurations-marked.PNG

Hit the "Server" tab and uncheck "Run built-in server".

xwiki-wysiwyg-plugins-2-project-debug-configurations.PNG

Switch to the "GWT" tab and add the following URL http://localhost:8080/xwiki/bin/edit/Sandbox/Test?editor=wysiwyg

xwiki-wysiwyg-plugins-3-project-debug-configurations.PNG

Next switch the tab and add the following arguments.

-noserver
-war C:\Temp\xwiki-enterprise-jetty-hsqldb-5.2-20130627.090543-2\xwiki-enterprise-jetty-hsqldb-5.2-SNAPSHOT\webapps\xwiki
-startupUrl http://localhost:8080/xwiki/bin/edit/Sandbox/Test?editor=wysiwyg
-remoteUI "${gwt_remote_ui_server_port}:${unique_id}"
-logLevel INFO
-codeServerPort auto org.xwiki.gwt.wysiwyg.Wysiwyg org.xwiki.gwt.wysiwyg.WysiwygDev

Replace "C:\Temp\xwiki-enterprise-jetty-hsqldb-5.2-20130627.090543-2\xwiki-enterprise-jetty-hsqldb-5.2-SNAPSHOT\webapps\xwiki" with the location of your current XWiki snapshot.

Change the "Working Directory" to "other" and paste the location of your current XWiki snapshot.

xwiki-wysiwyg-plugins-4-project-debug-configurations.PNG

Right-click your certain project (e.g. xwiki-platform-wysiwyg-client) in eclipse and select Properties> Google> Web Toolkit and check Use Google Web Toolkit

As of a eclipse bug you maybe have to repeat that step another time before the setting gets active.

If you need to debug more than just one project at the same time, you have to repeat these steps for e.g. xwiki-platform-gwt-user and modificate the classpath of the launch configuration. In practice this means for each project that is dependent of you have to add its source/resource directories. Follow these steps as described here and shown by the screenshot.

  • select "Classpath" tab
  • select "User Entries"
  • press "Advanced"
  • select "Add folder"

xwiki-wysiwyg-plugins-7-project-debug-configurations.PNG

These dependencies must be before "(default classpath)" as shown by the screenshot, so the hosted mode can recognize direct change.

Go to the directory of your current XWiki snapshot, open a command prompt and run start_xwiki_debug.bat

Your environment variables have to be in 8.3 DOS path format to execute this batch-file

Right-click on Project Debug As...> Debug Configurations> Debug. Maybe there will pop-up the following dialog, you don't have to consider this, just confirm with "yes".

xwiki-wysiwyg-plugins-5-project-debug-configurations.PNG

Now set e.g. a breakpoint and double click the URL like shown in the picture below to debug the wysiwyg-editor.

xwiki-wysiwyg-plugins-6-project-debug-configurations.PNG

Get Connected