I've got a project using GWT 2.6.1 + Maven 3.2 + Tomcat 5.5 (yes, I know it's an old one ...) + Eclipse Luna which is using JNDI allowing for external parameters to be configured.
As you might know, the context XML file is located at /conf/Catalina/localhost/myWebApp.xml where myWebApp is the Java web application name.
I am using gwt-maven-plugin for this project (the one from mojo haus) which has the version 2.6.1.
Here is my current configuration :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<module>xxx.yyy.myModuleName</module>
<runTarget>myWebPage.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<encoding>UTF-8</encoding>
<failOnError>true</failOnError>
<style>OBF</style>
<i18nMessagesBundle>xxx.yyy.zzz.client.ui.i18n.OlbClientMessages</i18nMessagesBundle>
<extraParam>true</extraParam>
<extraJvmArgs>-Dgwt.compiler.optimizationLevel=9</extraJvmArgs>
<extraJvmArgs>-Xms128M</extraJvmArgs>
<extraJvmArgs>-Xmx1200M</extraJvmArgs>
<extraJvmArgs>-XX:MaxPermSize=768M</extraJvmArgs>
<noServer>true</noServer>
<logLevel>INFO</logLevel>
</configuration>
</plugin>
As you can see, i am using the noServer (configured to "true") option because I must use an external Tomcat container for the server side.
My question is :
How can I enable client side AND server side debugging within my actual configuration through a step-by-step help.
I've made a lot of attempts but i can't make things working.
I've tested running the "mvn gwt-debug" which tries to connect to default port 8000 and then connecting a remote java application which connects to my webapp to localhost:8000 and it works well, but it's only for the server side.
I also need to debug the client side in the DEVMODE.
Thanks for your help.
There are two ways to run a remote server. First is using using DevMode with -noserver and pointing the war directory to the output war directory of the external server. The second way is to use the CodeServer entrypoint and run a WTP server runtime and set the launcher directory to tomcat output war directory.
I prefer the second routine, and built automation into the GPE fork.
http://gwt-plugins.github.io/documentation/gwt-eclipse-plugin/servers/Tomcat.html - see it in action here. There are videos and such.
Related
I have configured the Jetty Maven plugin to run my compiled war.
Here is the relevant part of my pom.xml.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.50.v20221201</version>
<configuration>
<war>${jway.webapps.dir}/myapp.war</war>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
If I execute mvn jetty:run-war, my war is build and Jetty serves the app as expected.
I have configured scanIntervalSeconds to allow hot redeploy.
However, if I rebuild using mvn install, I get the following error during redeployment:
java.lang.IllegalStateException: Failed to delete temp dir F:\...\myproject\target\tmp
at org.eclipse.jetty.webapp.WebInfConfiguration.configureTempDirectory (WebInfConfiguration.java:532)
at org.eclipse.jetty.webapp.WebInfConfiguration.resolveTempDirectory (WebInfConfiguration.java:424)
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure (WebInfConfiguration.java:140)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure (WebAppContext.java:488)
at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:523)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:397)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.maven.plugin.JettyRunWarMojo.restartWebApp (JettyRunWarMojo.java:113)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo$1.filesChanged (AbstractJettyMojo.java:472)
at org.eclipse.jetty.util.Scanner.reportBulkChanges (Scanner.java:848)
at org.eclipse.jetty.util.Scanner.reportDifferences (Scanner.java:765)
at org.eclipse.jetty.util.Scanner.scan (Scanner.java:641)
at org.eclipse.jetty.util.Scanner$1.run (Scanner.java:558)
at java.util.TimerThread.mainLoop (Timer.java:555)
at java.util.TimerThread.run (Timer.java:505)
It seems that Jetty wants to delete the file, but Windows locks the file. In the plugin documentation, I have not found any configuration which seems to be helpful. Furthermore I have nothing found on Google. Is there any way to solve this issue?
I don't know if its relevant, but I do not use the jetty:run goal, because my war is build using a third party tool and I do not have a standard directory structure.
The jetty documentation contains a section about Troubleshooting Locked Files on Windows.
So I updated my plugin config according to the documentation:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.50.v20221201</version>
<configuration>
<war>${jway.webapps.dir}/myapp.war</war>
<scanIntervalSeconds>2</scanIntervalSeconds>
<webApp>
<_initParams>
<org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
</_initParams>
</webApp>
</configuration>
</plugin>
I have set up JRebel in Intellij IDEA for spring-boot project, I have followed all the steps to install it in the correct way, but it is still not working, I have the following pom.xml configuration:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.7</version>
<configuration>
<addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
</configuration>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Box is also checked:
The funny thing is when I do changes in the source code and then go to the bytecode or .properties I can see the changes that have been made, but nothing is changing on the front-end...
Every time I compile the changed file I can see the following message in the event log:
From which I can conclude that changes should be applied.
I'm using out of the box servlet container which provides spring-boot, if I'm not wrong it is - Tomcat.
If any one knows, can you help me where am I wrong?
how do you start your SpringBoot application? With start buttons in IntelliJ or using the command line? I think you can remove the JRebel plugin from Maven pom.xml if you make sure that checking boxes in the JRebel panel generates a file called "rebel.xml". If the rebel.xml pom is generated, just verify it's content if it points to the folder with your compiled classes. After that, run "mvn clean compile package" and rerun your application again. If you start your application using buttons in IntelliJ, use JRebel buttons instead of normal ones. If from the command line, follow instructions in the plugin menu.
So I have a very basic question about how to most effectively work with a local spark environment along with a remote server deployment and despite all of the various pieces of info about this, I still don't find any of them very clear.
I have my IntelliJ environment and dependencies in need within my pom to be able to compile and run and test with my local within intellij. Then I want to test and run against a remote server by copying over my packaged jar file via scp to then run spark-submits.
But I don't need any of the dependencies from maven within my pom file since spark-submit will just use the software on the server anyway so really I just need a jar file with the classes and keeping it very lightweight for the scp would be best. Not sure if I'm mis-understanding this but now I just need to figure out how to exclude any dependency from being added to the jar during packaging. What is the right way to do that?
Update:
So I managed to create a jar with and without dependencies using the below and I could just upload the one without any dependencies to server after building but how can I build only one jar file without any dependencies rather than waiting for a larger jar with everything which I don't need anyway:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Two things here.
The provided dependency scope will allow you to work locally and prevent any server provided libraries from being packaged.
Maven doesn't package external libraries without creating an uber or shaded jar.
An example of a good Spark POM is provided by Databricks
Also worth mentioning, Maven copy local file to remote server using SSH
See Maven Wagon SSH plugin
In my project, I have to current Maven modules setup:
- Application
|- (application code, using Spring Boot 1.2.6)
- E2E-testing (has a dependency to Application)
|- src
|- main
|- java
|- AbstractCucumberTest.java
Before, this used to be a Spring 3 application serving JSP pages, so no Boot included. I refactored it to be a Boot application.
The E2E testing setup basically built a WAR file of the application code, and the E2E module booted a Jetty server, running that WAR. All was well.
Now, after the refactor, not so much.
The Jetty setup no longer works as-is. When I boot the WAR, I'm getting class loading exceptions, which are related to Jetty itself. Now, I'm not hung up on Jetty, it's just a testing container for me. So I started digging around in the Boot documentation, because I was convinced there had to be a way to make it all "Boot'-iful, meaning: I could simply boot the application when launching the tests. And there is, of course, so I ended up with these annotations on my AbstractCucumberTest:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = ApplicationConfig.class, loader = SpringApplicationContextLoader.class)
#WebIntegrationTest({"spring.profiles.active=local"})
public abstract class AbstractCucumberTest extends SeleniumTest {
So, basically, I'm loading the application config of the application, and launching the Tomcat server from the test. And all rejoiced, because now the application was successfully booting upon launching a Cucumber test. The application boots, it reads the classpath, Liquibase boots, everything is working alright. I can call the Actuator endpoints, which all work fine. Even the REST endpoints of the application are all working, so Spring MVC is doing its thing.
However, 1 thing is not, and that's serving JSP's -- and that's of course a deal breaker for E2E tests. Every time I surf to a page, I get the same unnerving 404 error. Before you ask: yes, tomcat-embed-jasper and jstl are present. They are present in the application, I even added them to the E2E pom, no luck. In fact, these are the things I tried, but they all failed:
Excluding the tomcat-embed-jasper and jstl dependency from the application
Copying over the JSP's from the application to the resources of the E2E module
Setting up my own CucumberConfig, which basically contained the same configuration as the ApplicationConfig
It just seems to me that the application cannot find the JSP's. Everything else is working just fine, just the JSP's are not found/served.
Does anyone have any thoughts?
Oh, on a side note, I tried using the spring-boot-maven-plugin, to try and boot the application that way. Problem is, though, that it cannot be forked. In the 1.2.6 release, the fork simply ... does not fork. When I say fork, I mean it in the Jetty way: it boots the application, and gives control back to Maven. It instantiates a "stop" command, which Maven can call after all tests have run.
In the 1.3.0.BUILD-SNAPSHOT version, it should be present (using the start goal), but that's still not working for me.
[EDIT] For what it's worth, the Application module is configured to build a WAR file. So it's not JAR packaging.
To whom it may concern, eventually I turned to the Maven Cargo plugin, which works just fine. I configured it in the pom of the E2E testing module. As you can see, my application is marked as a deployable, and the cargo plugin boots at the pre-integration-test phase, and shuts down at post-integration-test phase.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.16</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>
http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.27/bin/apache-tomcat-8.0.27.zip
</url>
</zipUrlInstaller>
</container>
<deployables>
<deployable>
<groupId>my.group.id</groupId>
<artifactId>Application</artifactId>
<type>war</type>
<properties>
<context>/context</context>
</properties>
</deployable>
</deployables>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>9999</cargo.servlet.port>
<cargo.jvmargs>-Dspring.profiles.active=local</cargo.jvmargs>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
To ease up the deployment process of my Jave EE application, I instructed Maven to automatically copy the resulting WAR file to the application server.
pom.xml:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution><!-- Run our version calculation script -->
<id>Copy to Application Server</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/copy-to-appserver.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
copy-to-appserver.sh:
scp /home/user/.m2/repository/com/wolf/apix/1.0/apix-1.0.war user#srv-web:/opt/wildfly-8.2.0.Final/standalone/deployments/apix.war
Unfortunately, this fails! The WAR is successfully transmitted to the application server, but it's mixed with old and new code. My assumption is that Maven tries to send it while still being in the WAR creation process, because when I run the copy script copy-to-appserver.sh manually after the deployment, everything works fine with it on the application server.
My question is, what do I have to change, so that Maven only accesses the WAR file when its creation / manipulation is complete?
Your plugin is being executed prematurely in the generate-sources phase
Run it in the last phase by changing the phase to deploy
<phase>deploy</phase>
In addition running the plugin in the correct phase, as suggested by 6ton, you might also want to consider using the Maven WildFly plugin, which specifically designed to solve your problem. That way, you can get rid of that nasty, nasty script.
I would recommend to separate the build process and the deployment process cause the deploy life cycle phase is intended to upload the artifacts to a remote repository.