GWT dev mode not refreshing when client code changes - gwt

Dev mode works fine, but if I change client code and refresh the browser it doesn't see the code changes. I'm using maven, with the following gwt plugin config.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<goals>
<goal>browser</goal>
<goal>run</goal>
<goal>debug</goal>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>simmapp/simmapp/template/Login.vm</runTarget>
<hostedWebapp>${war}</hostedWebapp>
<servicePattern>redangus/client/**/*Service.java</servicePattern>
<generateDirectory>${target}/generated-sources/gwt</generateDirectory>
<modules>
<module>redangus.Inventory</module>
</modules>
<deploy>${target}/extra</deploy>
<!--war>${war}</war-->
<!-- If you don't have this, an empty JspFactory sneaks in and
breaks the tests. -->
<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
<runClasspathExcludes>
<runClasspathExclude>javaee-web-api-6.0.jar</runClasspathExclude>
</runClasspathExcludes>
<sourceLevel>1.7</sourceLevel>
<persistentunitcache>true</persistentunitcache>
<persistentunitcachedir>${basedir}/persistent</persistentunitcachedir>
</configuration>
</plugin>
The command line produced and run by netbeans with the classpath hacked out:
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/bin/java -Xmx1024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y -classpath whatever -Dgwt.persistentunitcache=true -Dgwt.persistentunitcachedir=/Users/tom/git/reds_gwt/persistent com.google.gwt.dev.DevMode -deploy /Users/tom/git/reds_gwt/target/extra -gen /Users/tom/git/reds_gwt/target/.generated -war /Users/tom/git/reds_gwt/target/simmapp-1.0-SNAPSHOT -logLevel WARN -port 8888 -codeServerPort 9997 -startupUrl simmapp/simmapp/template/Login.vm -logdir /var/log/tomcat redangus.Inventory

Related

scala-maven-plugin : ClassNotFoundException

I am trying to run a simple Scala Hello World program using scala-maven-plugin from the command line in my Ubuntu VM running in Win-7 host OS.
I tried to execute in the following two ways :-
mvn scala:run -DmainClass=com.infoobjects.HelloWorld
Declaring the main class in a launcher tag in pom.xml and then executing mvn scala:run from the command line
But I am getting ClassNotFoundException in either case.
Directory Structure :-
Project > src > main > scala > com > infoobjects > HelloWorld.scala
Thanks in advance.
Here's my pom.xml
<build>
<finalName>sparkplay</finalName>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<launchers>
<launcher>
<id>launcher1</id>
<mainClass>com.infoobjects.HelloWorld</mainClass>
</launcher>
</launchers>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
your pom.xml has schema's issue : <executions> should not be child of <configuration>. So everything under <executions> is ignored
see Maven Model

Execute a task in Maven before packaging

I don't understand how to run a task in Maven, before packaging.
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
When I run mvn clean package, it doesn't get executed. How can I have this task executed? I'm using maven 3.0.5, if it matters.
** UPDATE: **
Adding id and goal as suggested, solved the problem from the command line.
<id>my-generate-sources</id>
<goals>
<goal>run</goal>
</goals>
To fix Eclipse error, I've configured lifecyleMappingMetadata, within the build section:
<build>
...
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.7,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
You need to add the <goals> tag (and adding an <id> tag is also strongly encouraged though not required if you only have one <execution> for the plugin), e.g.
...
<execution>
<id>print-something</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
</execution>
...
Try adding an execution id:
<execution>
<phase>generate-sources</phase>
<id>my-generate-sources</id>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
UPDATE
I forgot the run goal, as Guillame said. Eclipse maven integration is one of the worse things I have ever seen. The way we were running it is exclusivley via maven command line, and that is what I would recommend. You can still run it from eclipse like this:
create a new empty project
create mvn-clean-package.launch file in it
The file should look like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${resource}"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/usr/bin/mvn"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="clean package -DskipTests=true -U"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${selected_resource_loc}"/>
</launchConfiguration>
As long as this project is opened in your workspace, you can select any other project folder that contains pom.xml and select your mvn-clean-package command from the external tools button:
This will run:
mvn clean package -DskipTests=true -U
from the selected folder. You can see the output in Eclipse console window.
The external tools are also accessible also from the Run menu. I suppose that there is method to achieve this through Eclipse UI, but I didn't use Eclipse long enough to find that out.

GWT 2.5.0 mvn install error "Rebind result <class> must be a class"

Problem: I run mvn install on my GWT 2.5.0 project that I built with the gwt-maven-plugin and get the error Rebind result 'c3gw.fwk.gui.client.ClientFactory' must be a class.
This is a snippet of my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>resources</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>C3gwGui.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>c3gw.fwk.gui.client.Messages</i18nMessagesBundle>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
This is a snippet of my C3gwGui.gwt.xml:
<replace-with class="c3gw.fwk.gui.client.ClientFactoryImpl">
<when-type-is class="c3gw.fwk.gui.client.ClientFactory" />
</replace-with>
This is a snippet of the line where the error is thrown:
public void onModuleLoad() {
ClientFactory clientFactory = GWT.create(ClientFactory.class);
...
}
ClientFactory is an interface and ClientFactoryImpl implements the interface.
What I've figured out so far: The code works perfectly fine in Eclipse when I run debug, it just doesn't work when I do mvn install. I've run all the goals available for gwt-maven-plugin (clean, compile, sources, etc...) and they all work so the only conclusion I can have at this point is that something is happening during the maven-war-plugin phase or much later.
I also took the basics of this code from the following google tutorial and they use an interface so it should work, assuming that the example project also works that is.
Removing war:exploded, as Thomas indicated, solved the issue.

jRebel breaks loading of Application and Session Scoped beans

While starting without jRebel the debug log of jetty contains lots of messages referring MyApplicationScopedBean like:
13:46:29.620 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - loaded class MyApplicationScopedBean from WebAppClassLoader=571787213#2214c7cd
13:46:32.132 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - loaded class MyApplicationScopedBean$1 from WebAppClassLoader=571787213#2214c7cd
13:46:32.162 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - loaded class MyApplicationScopedBean$2 from WebAppClassLoader=571787213#2214c7cd
...
But with jRebel the log contains only one string about MyApplicationScopedBean:
13:44:12.351 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - loaded class MyApplicationScopedBean from WebAppClassLoader=1298169768#4d607fa8
Any ideas why it could happen?
Here are maven plugins:
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webAppConfig>
<sessionHandler implementation="org.eclipse.jetty.server.session.SessionHandler">
<sessionManager
implementation="org.eclipse.jetty.server.session.HashSessionManager">
<!-- Disable url sessions using JSessionID -->
<sessionIdPathParameterName>none</sessionIdPathParameterName>
</sessionManager>
</sessionHandler>
</webAppConfig>
<!-- <failOnMissingWebXml>false</failOnMissingWebXml> -->
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<systemProperties>
<systemProperty>
<name>logback.configurationFile</name>
<value>./src/etc/logback.xml</value>
</systemProperty>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
I was using jRebel 5.0 without eclipse plugin. Installation of up to date jRebel 5.1 eclipse plugin solved the problem.
UPDATE: After I upgraded my trial license to social one it stopped loading JSF beans again. Also I got annoyed by their suspicious marketing solutions:
1. Foolish misleading statements in every topic on coderanch like: "here it is: jRebel... " .
2. Social license supposes permission to post to your FB (or Twitter).
It looks like guys are really concentrated on making money at any price.
So, I decided to get rid of this bullshit and installed DCEVM. It just works! And it's free and open source.
http://ssw.jku.at/dcevm/

Trouble debugging Maven integration test in Eclipse

I'm using Eclipse Indigo on Win XP, with Maven 3.0.3. I have created a Selenium 2 test that I wish to debug in Eclipse. It is set up to run in the Maven integration test phase. I'm using the Maven Cargo plugin with Tomcat as the container. Here's the relevant section from my pom.xml ...
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat${tomcat.major}x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
<output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<pingURL>http://localhost:8080/${project.artifactId}</pingURL>
<pingTimeout>30000</pingTimeout>
<properties>
<context>${project.artifactId}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
Problem is, when I right click on my integration test in Eclipse, select "Debug As" and then choose my Debug Configuration (which is just the maven goal "clean install -Dtest=TableIntegrationTest"), the execution runs without hitting the breakpoint I set (http://screencast.com/t/at0AKWwxslE). How can I do step-through debugging on a JUnit/Selenium integration test in Eclipse?
Maven's integration tests by default run in a forked JVM. Therefore, eclipse is unable to attach to the forked JVM and see the breakpoints.
You can force the integration-test to run in the same JVM with the -DforkMode=never option.
More here: http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
Edit: Updated link