I have a google app engine project with java using maven, and every time I want to see the changes I made even to a simple jsp or html, I have to run clean install then run the server. I want to know if it's possible to see the changes without having to go through this long process.
I have a GAE project structure that contains a war and ear folders.
I run the clean install on the war, then I go to the ear folder to run the "appengine:devapp".
Yes, it's possible to make the development process more agile and see the changes on JSP/HTML files w/o having to redeploy the whole application again. In a nutshell, all you need to do is to copy the files to the target directory. There are several ways to do that, ANT is one of the options.
I friend of mine wrote an article several months ago explaining this process in more details. Take a look: http://fabiouechi.blogspot.com.br/2013/07/smart-appengine-devserver-restarts-for.html
cheers!
Related
My team is working on a Java application that runs on Jboss WildFly, using Maven to resolve dependencies and Primefaces.
We're using Eclipse to build, deploy and run the server. Eclipse does most of the work, building the WAR file, deploying it to server and running it.
Now we need to create an script that performs all those steps because it has to run on remote server.
.
The steps would be something like this...
1 Run Maven:
$M2_HOME/bin/mvn clean install
2 Build project to a war file
3 Deploy war file into the WildFly deployment folder
$WILDFLY_HOME/bin/jboss-cli.sh --connect --command="deploy --force [PATH_TO_WAR]"
4 Start server
$WILDFLY_HOME/bin/standalone.sh
.
I can perform every step but once the server is running it don't seem to be any changes in the application. I think this is because the WAR file has to be built optimizing it for JBoss. Eclipse has a way to do this when exporting the project. I need to know how to do that from command.
EDIT:
The real problem is that Jboss is not updating the published project when i run it from bash script. I thought it was because i had to build it on a specific way. I was wrong. The build is fine, just running Maven the deploy is done. The thing is that even if i rebuild project and redeploy it, server doesn't seem to notice at all.
I've tried deleting tmp, lib and data folders from standalone folder, and nothing happens. I also deleted standalone/deployed sub files and folders and got the same result.
The only way i achieve the result i'm expecting is getting into Eclipse, go to Servers tab, right click on JBoss Wildfly and click on 'Clean...'. This options seems to clean cache, rebuild and re publish the application in a right way that i don't know. I didn't find any answers on google.
eclipse server clean option
Give a look on Eclipse war export: optimize for a specific server runtime.
Quoting from #Konstantin Komissarchik's answer :
Eclipse itself doesn't do anything with that option. What happens is
dependent on a particular server adapter. Many of the adapters don't
do anything with this option either, but they might in the future.
If a server adapter does support export optimization, it has the
option of displaying custom options beneath that pop-up list of
runtimes, so that's a good cue to use to see if something will
actually happen.
So taking in consideration that in your provided image there is no custom options below Wildfly 9 selection, I am pretty sure that this option does not perform any optimization at your exported war so you can totally omit it in your new build-deploy process.
How can i build the war file from command, knowing it will have to run on Wildfly?
We are also deploying applications for a long time on several versions of Widlfy with the same approach as you are planning to, without the optimization thing. I can ensure you that we have not faced any performance issue.
I'm trying to develop an application using Google App-Engine and Maven using Eclipse. I am facing a problem where by whenever you change a CSS or JSP file, a restart of the application is required. This makes working quite difficult, since a reload takes a lot of time.
For example when you develop on tomcat no need for restart is required when such a change is made, only Java or xml file require restart of the server.
Is there a solution that mimics the tomcat behavior on GAE SDK when developing on localhost?
If you've built using the standard app engine maven archetype, when you run mvn appengine:devserver from you -ear directory, the exploded war working directory is located here:
<yourapp>/<yourapp>-ear/target/<yourapp>-ear-1.0-SNAPSHOT/<yourapp>-war-1.0-SNAPSHOT.war
If you change any JSPs in this directory, they will get reloaded without needing to restart the devserver.
Thus, you can set up a simple script or command that copies all your JSPs and static files from /-war/src/main/webapp to that deploy directory whenever you want your files to be refreshed. I saw on some threads where people set up their IDE (in this case IntelliJ) to automatically do that copy whenever the IDE loses focuses, which makes it trivial to get pages reloaded.
Building application with appengine in eclipse using maven is not very effective and time consuming because on every change on jsp/css/js with a traditional approach there is a need to restart appengine or mvn appengine:devserver.
#adevine make me thought about a solution, and I found this link: http://andrei.gmxhome.de/filesync/index.html wich installs a plugin in eclipse, then I activate the project to sync files from myapp/src/main/webapp to a target folder generated by maven myapp/target/myapp-snapshot-0.0.1.
It's working!!!
Whenever a change is done in webapp the files are transfered automtically(no need to run anything else, just save the file) to the target folder and are reloaded successfully.
Hope this could help people because its frustrating working with appengine(restarts takes a lot).
I have a project in eclipse, a java app with appengine sdk and maven as my builder.
The .class files are not refreshed until i launch clean install, so every change i do in code i have to run:
mvn clean install
mvn eclipse:clean
mvn eclipse:eclipse
and then try to launch my app.
Help me please it's really annoying. Thanks
I know this is a very old post but I recently came across this issue while working with STS and Websphere application server. Hope this helps anyone to come across this ancient relic of a post.
Have a look at the "FileSync" plugin in the Eclipse marketplace. It allows to sync your workspace files with external directories (think your application server). After you install "FileSync" you can configure it to "copy/paste" your workspace files directly to your application server's exploded .war directory. It might take a little playing around with to get your files copied in a j2ee compliant format but it worked like a charm for me. Once its configured you basically just update files, save them, and your application is ready to go!
You are probably looking for a hot deployment feature. When working wit ha webapp, in most cases it is not enough just to compile a java class - usually you have to create a war package, and nearly always you have to redeploy the new code to the app server.
mvn package should be enough to create the war. You don't need to run mvn clean as long as you don't remove or rename any file. That would make things faster.
To achieve hot deployment (i.e. to get the new code instantaneously on the web-engine dev server) you need to do do some extra work, however. Make sure you use the Google Plugin for Eclipse - you can use it along with maven. The plugin at least should take care of static files hot deployment. Running the application in debug mode with Eclipse helps a bit as well as it is capable of replacing the methods' bodies on the fly.
Find further information answers to this question.
It's unclear from the question exactly what is happening and why. To figure this out, we would need to see the pom.xml and the "tree" command output showing the relevant folders and files. Then we could compare that to what the relevant maven plugin should be doing, and work from there.
As it stands, this is a quite old question in which it's unclear exactly what's happening, and OP has disappeared a long time ago. If this issue occurred today, the best thing to do would be to post to the App Engine Public Issue Tracker, although this could be inappropriate if the issue weren't in the App Engine SDK (or related maven plugins) but came from a third-party maven plugin not behaving properly (maven-compiler-plugin, for example). However, until a more in-depth analysis were performed, it would be difficult to know in advance.
Getting hot-reload of your App Engine application working is easy using only the Eclipse m2e plugin actually, and doesn't require the GPE plugin or any other special connectors:
1) Create your App Engine app as a Maven project in Eclipse as you would normally, using one of the provided Google archetypes or another custom archetype.
2) Configure your project, and do an initial build with mvn clean install in the root of the project to create the initial target/<artifact>-<version> WAR directory.
3) Start the development server with mvn appengine:devserver in the project root and ensure you can view your locally served app in a browser. Leave the development server running.
4) In Eclipse, make sure that Project -> Build automatically is checked.
Now, whenever you save a .java file Eclipse will automatically build the corresponding .class file under target/<artifact>-<version>/WEB-INF/classes. In a Maven project, this directory is set as the output directory for classes in your .classpath. The development server will detect the file change and do a hot-reload of your application so that the changes will appear immediately when you refresh your app in the browser.
I am converting an application from Flex to Javascript. My workflow within Eclipse for Flex was to use Maven to start my Java web app in Tomcat and then have Eclipse configured to compile edited Actionscript files to a SWF and save it to my exploded WAR directory (that Maven/Cargo uses).
It worked very well for a long time allowing me to edit actionscript source code, flip over the browser, refresh the screen and see the changes.
I am new to Javascript however, and am struggling to get the same workflow up and running. The part I don't understand is how to tell Eclipse that I would like my edited Javascript files to be written out to a particular directory (that contains the exploded WAR). In my WAR project (a WTP dynamic web project) there is something that looks like a Javascript build path called "Javascript resources", but there is no output directory.
I would really like to continue to run Tomcat and Jetty via Maven if at all possible. I realize I can do what I want via WTP (M2E-WTP), but would prefer to use Maven/Cargo.
Denis's suggestion to create custom builder is probably best solution if you want to continue using pure Maven/Cargo approach with Eclipse.
If you are deploying to an exploded war directory, then another similar idea would be to use a File Synchronization plugin. These will automatically copy modified files to configured folders. See:
http://andrei.gmxhome.de/filesync/
https://wiki.onehippo.com/display/CMS7/Use+Filesync+Eclipse+plugin+for+faster+turn+around
-------------
FWIW, I don't think Maven:Tomcat/Cargo plugins are ideal for real-time web development, especially on the frontend side of things. They are useful mainly for controlled deployments or bootstrapping a server without initial setup. My thoughts:
Eclipse WTP used to be great for real-time web development, but I stopped using it a few years back as it just got way too hard to make it work correctly in a Maven environment. Fwiw, my preferred approach these days looks like this:
Do not install or use Eclipse WTP.
Use m2eclipse to integrate Maven with Eclipse.
Use Maven to do clean builds and generate exploded WAR directory in target folder.
Setup independent Tomcat server to load webapp from the exploded target folder.
I suspect the tomcat setup/startup could be integrated into Maven. It's not worth the extra complexity to me though.
Then, I configure JRebel (automatically via Maven) to handle java and web resource file changes. With this setup, I almost never have to redeploy or restart Tomcat. All changes (java, html, js, etc.) are seen immediately.
I think the same setup could be used without JRebel (for non-java files only) by configuring the web source folders as source folders in Eclipse with custom target output path being the corresponding directory in the exploded war directories. If that didn't work, then it would definitely work by using the custom builder or file synchronization solutions mentioned above.
Eclipse introduces the concept of "builder" to build a project. It comes with hardcoded builders such as the java compiler or the war builder of WTP.
But eclipse also enable to setup your own Builder using ant files : on your project, right click the project properties, go to section Builders, click on the new button.
You can use arguments to your ant file and use variables defined in by eclipse to build them
Do not forget to fill the refresh tab if you want eclipse to by notified of the produced files.
Do not forget the fill the Build options tab, section "Specify working set of relevant resources" in order to have your builder called each time a source used by the build file is changed inside eclipse.
Also go to the "targets" tab to specify during which type of build phase your ant file is called and which target is called.
I knwo this solution may not be the best for you since your build process will be described more than once but it may help you achieve your goal.
I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment:
Do you check in all the Netbeans project files into the repository, normally?
If I build the project using Netbeans (or ant) I get a .jar file and some additional jar libraries. In order for the app to run properly on the server, some additional config files and directories (log/ for example) are needed. The application itself is a J2SE application (no frameworks) which runs from the command line on a Linux platform. How would you deploy and install such an application? It would also be nice if I could see what version of app is currently installed (maybe by appending the version number to the installed app path).
Thanks for any tips.
No, not usually. Anything specific to NetBeans (or Eclipse, IntteliJ, etc), I don't check in; try to make it build from the command line with your ant script and produce exactly what you want. The build.xml is something that can be used for other IDEs, or in use with Anthill or CruiseControl for automated builds/continuous integration, so that should be checked in. Check in what is needed to produce/create your artifacts.
You don't specify what type of server, or what exact type of application. Some apps are deployed via JNLP/WebStart to be downloaded by multiple users, and have different rules than something deployed standalone for one user on a server to run with no GUI as a monitoring application. I cannot help you more with that unless you can give some more details about your application, the server environment, etc.
Regarding the config files, how do you access those? Are they static and never going to change (something you can load using a ResourceBundle)? ? You can add them to the jar file to look them up in the ResourceBundle, but it all depends on what you are doing there. If they have to be outside the jar file for modification without recompiling, have them copied with an installer script.
As for directories, must they already exist? Or does the application check for their existence, and create them if necessary? If the app can create them if absent, you have no need to create them. If they need to be there, you could make it part of the install script to create those folders before the jar files are installed.
Version number could be as simple as adding an about box somewhere in the app, and looking up the version string in a config/properties file. It has to be maintained, but at least you would be able to access something that would let you know you have deployed build 9876.5.4.321 (or whatever version numbering scheme you use).
Ideally, you should not tie down your application sources and config to a particular IDE.
Questionwise,
I suggest you do not. Keep you repository structure independent of the IDE
You might have to change your application so that it's structure is very generic and can be edited in any IDE.
Is this a web app? A standalone Java app? If you clarify these, it would be easier to answer your query.
We don't check in the /build or the /dist directories.
We tend to use this structure for our Netbeans projects in SVN:
/project1/
/trunk
/tags/
/1.0
/1.1
/binaries/
/1.0
/1.1
When a change is need we check out the netbeans project from trunk/ and make changes to it and check it back in. Once a release of the project is needed we do an SVN copy of the netbeans project files to the next tag version. We also take a copy of the deployable (JAR or WAR) and place it in the version directory under binaries along with any dependencies and config files.
By doing this we have a clean, versioned deployable that is separate from the source. Are deployables are version in the name - project1-1.0.jar, project1-1.1jar and so on.
I disagree with talonx about keeping your source non-IDE specific - by not storing IDE files in SVN along with you source you are adding extra complication to the checkout, change, checkin, deploy cycle. If you store the IDE project files in SVN you can simply check out the project, fire up the IDE and hit build. You don't have to go through the steps of setting up a new project in the IDE, including the files you SVNed, setting up dependencies etc. It saves time and means all developers are working with the same setup, which reduces errors and discrepancies. The last thing you want is for a developer to check out a project to make a small bug fix and have to spend time having to find dependencies and set stuff up.
To answer question #2 -- who's your consumer for this app?
If it's an internal app and only you (or other developers) are going to be deploying it, then what you have is perfectly all right. Throw in a README file explaining the required directories.
If you're sending it out to a client to install, that's a different question, and you should use an installer. There are a few installers out there that wrap an ant script and your resources, which is a nice approach particularly if you don't need the GUI... just write a simple ant script to put everything in the right place.
Version number is up to you -- naming the JARs isn't a bad idea. I also have a habit of printing out the version number on startup, which can come in handy.