SDBG + Maven + Glassfish + Eclipse

114 views
Skip to first unread message

carlossierra

unread,
Mar 30, 2016, 1:02:45 PM3/30/16
to SDBG
Hi. I have used SDBG successfully on some projects, using the default configuration (as explained on the introductory video). 

But now I am trying to run SDBG in an existing GWT project where the server used is Glassfish (instead of the embedded Jetty). I can run the app without any problems, and even debug server side code by starting the Glassfish server in debug mode. The problem is that I don't know how to integrate SDBG in this setup, and doing the standard process simply doesn't work (break points are never hit). 

Can you please help me figuring this out? 

Thanks

carlossierra

unread,
Mar 30, 2016, 1:05:38 PM3/30/16
to SDBG
I forgot to mention that I'm using GWT 2.7.0, SDBG 1.0.8, Eclipse Mars and m2eclipse 6.4.1. 

Ivan Markov

unread,
Mar 30, 2016, 4:07:24 PM3/30/16
to SDBG
The setup is almost identical to what is demoed in my movie, with the following small tweaks:

1) Your need to have your Glassfish server running (obviously)

2) From Eclipse, you need to disable the Jetty embedded server instance, and only let the GWT SuperDevMode Code Server run. This is the same GWT "Web Application" thing (blueish "g" icon) that you can see being ran from within Eclipse on my demo movie, except that you instruct it not to run the embedded Jetty instance by going to the "Server" tab and unchecking the "Run built-in server" checkbox.

carlossierra

unread,
Mar 30, 2016, 4:52:04 PM3/30/16
to SDBG
Thanks Ivan for answering. But there's one small problem: In this setup (with Maven) I don't run the GWT apps using the Web Application run configuration, but instead use the gwt-maven-plugin for Maven which I have configured to compile the application, copy all required files to the webApp files to a certain location and runs the application. In turn, Glassfish picks up the file changes and auto publishes them, so everything works smoothly. 

Buuuut, since I don't have the Web Application configuration, I don't know how to "plug" SDBG here. 

Just for completeness sake, these are the parts of my POM that do what I explain above:

<?xml version="1.0" encoding="UTF-8"?>

<modelVersion>4.0.0</modelVersion>
<groupId>com.mydomain</groupId>
<artifactId>MyApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MyApp</name>

<properties>
<!-- Artifact versions -->
<gwt.version>2.7.0</gwt.version>

<!-- Maven GWT compiler version and parameters -->
<maven.compiler.version>3.3</maven.compiler.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<compiler.style>OBF</compiler.style>
<compiler.log.level>INFO</compiler.log.level>
<glassfish.port>8000</glassfish.port>
</properties>

<dependencies>
<!-- Core: GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>

<finalName>MyApp</finalName>

<!-- Make sure classes output dir matches hosted webapp WEB-INF/classes 
folder, so GWT Hosted browser can see the classes. -->
<directory>target</directory>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>

<plugins>

<!-- Plugin to compile GWT Java code to JavaScript. 
Usage: mvn gwt:compile , mvn gwt:run -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>

<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>

<configuration>
<!-- Compiler parameters -->
<extraJvmArgs>-Xss1024K -Xmx1024M</extraJvmArgs>
<draftCompile>true</draftCompile>
<debugSuspend>false</debugSuspend>
<logLevel>${compiler.log.level}</logLevel>
<style>${compiler.style}</style>
<!-- Launch parameters with external server -->
<!-- Add the app to Glassfish embedded server and set the server to
publsh automatically after each compile -->
<noServer>true</noServer>
<runTarget>http://localhost:${glassfish.port}/${project.build.finalName}/${project.build.finalName}.html</runTarget>
<!-- Build parameters -->
<buildOutputDirectory>${project.build.outputDirectory}</buildOutputDirectory>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
<copyWebapp>true</copyWebapp>

</configuration>
</plugin>
</plugins>
</build>

</project>

Please note that in this setup I have instructed the plugin to not run the embedded Jetty instance, which is what allows me to have everything running in Glassfish. 

Any ideas? Thanks in advance for your time and help! 

Ivan Markov

unread,
Mar 30, 2016, 11:37:29 PM3/30/16
to SDBG
During development, you do need to run item (2) from my email, one way or the other.

Item (2) is essentially the so called "GWT Code Server". It is a simple web service listening on a special port, which recompiles your app quickly and incrementally each time you do a small change of your GWT app code and you hit F5 in the browser to refresh it. While debugging a GWT app does not strictly require the GWT Code Server running (SDBG and/or Chrome can debug your app just fine as long as your current compilation process generates a SourceMap file), you really want to run the Code Server, as it has a lightning fast incremental recompilation which is a must during development.

With the above said, if you use Maven, you can still run the code server (I think). Look at the gwt-maven-plugin documentation for further info, e.g. here: https://gwt-maven-plugin.github.io/gwt-maven-plugin/run-codeserver-mojo.html

By the way, I hope you understand now that the setup we are discussing is not specific to debugging with SDBG. Even if you use JIdea, or maybe plain Chrome debugging, you do need the Code Server.

carlossierra

unread,
Mar 31, 2016, 12:00:40 AM3/31/16
to SDBG
Hi Ivan. Once more, thanks for your reply and time. I really appreciate it!

And I'm sorry if I haven't been very clear, but I know I am running the code server, because I can hit F5 after a change in the code is made, and a recompile will be triggered, resulting in Glassfish republishing all the files that were changed. F5 "refresh" works as expected, allowing me to run the updated code.

In the end, I think I am doing the same thing that is accomplished when using the Web Application run configuration (your second step), but with the gwt-maven-plugin. The only problem is that after 1) creating the Launch Chrome configuration (as instructed in your video), 2) running Glassfish and 3) running the Launch chrome configuration, SDBG don't seem to work, and my break points aren't being hit.

I hope this is clearer now and you can provide some guidance on how to proceed.

Thanks!

Ivan Markov

unread,
Mar 31, 2016, 12:44:53 AM3/31/16
to SDBG
OK here is a simple question: are your breakpoints being hit when you debug with Chrome, rather than with SDBG?

carlossierra

unread,
Mar 31, 2016, 2:06:35 AM3/31/16
to SDBG
Yes sir... The are hit as expected!

Ivan Markov

unread,
Mar 31, 2016, 2:18:12 AM3/31/16
to SDBG
Could it be, that you are simply experiencing this: https://github.com/sdbg/sdbg/issues/104 ?

carlossierra

unread,
Mar 31, 2016, 9:00:27 AM3/31/16
to SDBG
No sir, I am not setting breakpoints inside the onModuleLoad method, if that is what that bug means...
But also, how do I test this? How can I make Chrome remember the scripts/sourcemaps?

Ivan Markov

unread,
Mar 31, 2016, 9:51:47 AM3/31/16
to SDBG
It means inside the onModuleLoad() method, but also inside any other methods which are called by this one. Basically any breakpoint set on code, which will be executed before onModuleLoad() is completed.


As for Chrome, you don't have to do anything explicit to make it remember the sourcemaps, it does it automatically.

Hmm, I'm at a loss what this could be.

There is one more thing which can be done: you can enable Tracing for SDBG in Eclipse, from Window/Preferences/General/Tracing/Enable Tracing. Then set to "true" the "breakpoints" and "sourcemaps" items. Then record one session where you fire the SDBG debugger, set breakpoints, load the app, and then send me the trace log. Thanks in advance.

carlossierra

unread,
Mar 31, 2016, 12:03:40 PM3/31/16
to SDBG
Hi Ivan. I checked this behavior with a set point in another class different to the one containing my onModuleLoad, and now it did worked correctly. Thanks for bearing with me on this one. 

Do you have an estimate of when will be the fix for this bug available? 

Finally, thanks for providing this great product!!! I will keep recommending it to other GWT and SmartGWT programmers! 
Reply all
Reply to author
Forward
0 new messages