Serving multiple GAE modules from one development server? - java

I'm converting some backends to modules and am perplexed on setting up the development environment configuration. I'm using Java in Eclipse but not Maven. The architecture is very simple:
Front end module is default. Basic GAE/GWT app. Puts items on task queue.
Back end module processes task queue.
With the old backend architecture one debug configuration would start up the development server that would service the GWT DevMode UI and the backend task processing.
The crux of the issue is that the arguments to DevMode provide for a -war command line argument. Now that we no longer have a single war file (there is an ear containing two war files), we have to start them independently. This is fine, we can create a Launch Group that starts up the frontend and backend.
The problem is that each war file gets it's own
WEB-INF/appengine-generated/local_db.bin, which essentially creates two standalone applications. Am I missing something here? I need to be able to put a breakpoint on my front-end RPC service and in the servlet that handles task queue items in the new backend and have both of them hit in one debugging session.
Thanks for any thoughts.

If you follow the instructions here, this will create a modularized application structure in Eclipse, and not using Maven at all. You will need Eclipse WTP in order to have the required project types available (Enterprise Application Project and Dynamic Web Project).
The Eclipse project structure should look as follows:
<<Enterprise Application Project>> ear-app
|
| (refers to)
|
<<Dynamic Web Project>> app-module-1 "default"
<<Dynamic Web Project>> app-module-2 "any_name_2"
<<Dynamic Web Project>> app-module-3 "any_name_3"
<<Dynamic Web Project>> app-module-4 "any_name_4"
The value of "name" refers to the "module" element in appengine-web.xml, while the physical web project can have any name.
Please note that you need to switch into J2EE perspective in order to have the GPE WTP menu options available, they do not show up in the standard Java perspective.
Next, you need to link the EAR project to a new local server instance (of type "Google App Engine").
Only one of the web modules must be flagged as "default" in appengine-web.xml.
Upon deployment of the EAR to the local server, the datastore location is in WEB-INF/appengine-generated/local_db.bin of the default web module, and it is shared between the web modules.

I'm having similar problems figuring out how to implement multiple modules in the MyEclipse plugin for Google App Engine. The best information I've found just says to use Maven.
"Although Java EE supports WAR files, module configuration uses unpacked WAR directories only. App Engine's Java SDK includes an Apache Maven tool that can build a skeletal EAR structure for you." (source: https://developers.google.com/appengine/docs/java/modules/)
I also found this:
"A Maven project has a different layout than an Eclipse project. So, if you wish to use a Maven project with Eclipse, you need to do a bit more work. You have the following options:
1] Import a Maven project for App Engine into Eclipse as a Web Tools Platform (WTP) project, as described in Importing an Existing Maven Project.
2] Import the Maven project into Eclipse using an appropriate Maven integration plugin such as m2eclipse.
3] Set up two debug configurations, one for the Maven project in devserver (mvn appengine:devserver), and one for a Remote Java Application that you use to connect the Eclipse debug client to the devserver jvm. For details on how to do this, see ..." (source: https://developers.google.com/appengine/docs/java/tools/maven#creating_a_new_maven_app_engine_project_using_skeleton-archetype)
I know you said you're not using Maven, but might you consider trying it?

Related

Java dynamic web project is not building

I have modified the Web content folder & then did the Clean project followed by build project. But still there is no change in project.
I am using tomcat server 7 & JRE1.7.
What is the best way to build a java dynamic web project? How to ensure each & every file of the project gets re-build?
I cannot create a comment on this question so have to put it up as an answer..
Java dynamic web project is not building
What kind of build tool are you using? i.e Maven, Gradle, Ant
I have modified the Web content folder & then did the Clean project
followed by build project. But still there is no change in project. I
am using tomcat server 7 & JRE1.7.
Tomcat is there to deploy your web project, so if your build is failing you will not be able to deploy it successfully to your tomcat server. Maybe you could provide us with some sort of error message?
What is the best way to build a java dynamic web project? How to
ensure each & every file of the project gets re-build?
Don't think you will find any "best way", but there's several options out there you can use. Fast google search for build tool
Maven
Gradle
Ant
This is just a few.

Eclipse and maven dependency during development

I do have own developed Java library (MyLib), which I later publish on private Maven repository and have it as Maven dependency in another webapp project (MyWebapp). If I have both projects - MyLib and MyWebapp at the same time opened in Eclipse - is there a way somehow to configure MyWebapp so, that local changes made to MyLib would be directly added to MyWebapp while building/deploying it? The issue is that during development it is not really comfortable always to make some changes in MyLib, make a build, deploy to Maven repository and then make a MyWebapp build, deploy it and only then I can see how the changes are affecting the webapp project...
I would like to reduce the overhead while developing and willing to see how changes are working out. Of course when it comes to real releases the above described flow does really make sense and works great.
Thanks!
There is no simple "just tick this option" solution, unfortunately. You can chose between these options:
Convert MyLib into a Maven module and add it to the sources of MyWebapp. This, of course, will make it harder later to reuse the library alone.
Stop deploying the application. If you look at the classpath in Eclipse, m2e should have added the dependency as a project from the workspace (instead of depending on the JAR in the repository). If not: There is an option for this.
The next step is to create another project which depends on Jetty and MyWebapp. Create a Java application in there (i.e. a file with main()) which creates a Jetty server and configure it to use the current classpath. That way, you can start the webapp just like any other Java application without deploying - Jetty will simply load classes from the classpath that m2e assembled.

netbeans + svn + deployment workflow

I have almost no experience in using netbeans and svn so please correct me gently if I am wrong. I come from using python/vim/git so workflow wise is foreign to me.
Currently, I used the Netbeans' svn plugin to checkout my project from a remote repository. The project has several components like webservices, and also a swing client and of the business logics.
Assuming that I need to work with the web services and the swing client, do I create separate projects for each, and import the project as references?
Finally, currently I'm using netbeans to test the webapp on the local glassfish server. How do I deploy on a remote test server so that my team mates can use and test the web app?
If all of the seperate components are a part of the same project in svn then, no, you should only create one project in netbeans. Check out the project from svn and once netbeans has checked out the project it should prompt you to create a netbeans project when it does select project from existing sources, follow the wizard steps and your project will be created. You will have to import any external jars needed by the project that has been checked out into the newly created project in netbeans. NOTE: Netbenas will create a build.xml file for the newly created project so be sure that you do not commit that build.xml file into the repository unless it's needed.
To setup a remote server in netbeans go to tools->servers, select add server, select the server type(glassfish, tomcat, etc) then enter the pertinent information for the server using the wizard.
First question "Assuming that I need to work with the web services and the swing client, do I create separate projects for each, and import the project as references?"
It really depends on your architecture - how coupled are those components. It's also important what packaging system do you use? For example if you use Maven you can easily modulate the project and define dependencies between the modules. Check out this for details. I am referring to maven as it's build-in in Netbeans.
Regarding your testing you basically have 2 options:
a) expose your glassfish to your buddies
b) package and deploy your project remotely - this really cannot be given straight answer - depends on your infrastructure, where's the remote server, how big the deployment package is, how the application server behaves regarding hot deployments etc.
I suggest try the first option.
SVN helps you to keep the project in several versions in the repository.
You can always checkout from repository.
once you checked out, you will be using the project from a saved directory somewhere in your local machine.
Now, you can keep on developing the project, at the same time your friends can also keep doing that, and whenever you think you have done enough changes or development then after verifying your own copy of the project, you can commit the changes to repository.
After committing the changes will be visible in the repository to everyone, and hence anyone can access this updated version of the project residing in the repository.
Note that the earlier version will not be deleted, unless you do so.
Your friend can also checkout a copy of the project from the repository and they can merge it with their existing ones, and they can also commit the changes.
and at the same time, you can ask your friend to check your developed code by checking out the project and deploying on their local server.
I hope it gives you a better picture.

How to integrate maven generated vaadin project into eclipse vaadin plugin?

Eclipse Vaadin plugin has cool autobuild feature. Just clicking "restart application" in debug console will bring up to date application version to live.
Unfortunately importing maven generated vaadin project(using m2e) and copy-pasting .project buildCommands and natures from vaadin eclipse plugin generated project does not works.
I'm unnable to "Run on server...", tomcat does not deploy app for unknown reason. I can see app in wtpapps folder but it still does not deploys.
You can build your Vaadin app as a regular Java library, by itself (not as a WAR, or anything complicated). Then do two things: Create another project that builds the actual WAR file, and create another project that sets up Jetty for direct execution (google for details on how to get Vaadin operating under Jetty standalone, using Jetty as a library). With that in place you can treat your Vaadin UI like a regular java program (fast, direct restart through the standard debug window), and still have it be a WAR file for deployment.
See this thread for details on how to set up Jetty (look for Launcher).
I have also stumbled upon this problem some time ago and eventually found this:
http://www.streamhead.com/maven-spring-vaadin-appengine/
It eventually helped me to get up and running after a scenario that has been very similar to what you have described.

How to have Eclipse Java EE automatically generate the exploded WAR for a web project?

I need to have a Java EE project generate a WAR file automatically - preferably exploded - as opposed to choosing Export -> War file.
I have played with the various server definitions but have not been able to get either the Java EE preview or the HTTP server to work, and before installing each of the external container specific servers I'd like to hear if anybody has made this work.
So, question is: Which steps to take to have a WAR deployment automatically created and maintained by Eclipse?
EDIT: This is Eclipse 3.5 Java EE, and it is a Dynamic Web project in Eclipse. I want the WAR file/tree to be easily copyable to a network drive to be accessible for the target host. It runs an embedded Jetty, but I am interested in the generic WAR.
MyEclipse can do this, but we are standardizing on plain Eclipse.
EDIT: This particular web application will run inside an embedded Jetty. Since this question was asked we have found empirically that we need to have the complete tree containing the application with embedded Jetty, war file (exploded) and all built by the Hudson server in order to avoid human steps in the build-deploy-process. The answer for us therefore is scripting with ant (using ant4eclipse).
EDIT 2012: The ant4eclipse approach proved to be generally too inflexible and fragile in the long run, so we have switched to Maven. This solved very many problems, this one included.
Make an ant task to build the war (and copy if you like). Then add an Ant builder to the project (project -> properties -> builders). As long as your project is configured to build automatically the war will always be upto date.
This would equally work with maven, or pretty much any other build tool.
You should be able to do this with "File" -> "Export", scroll down to "Web" -> "WAR File" and follow the instructions
Have a look at this question. It refers to 3.2 version, but I believe that it still holds, until up to 3.4 version at least. It seems there is no automatic way of doing the Export - War thing.
Consider the solution given by Pablojim and drop the Export facility.

Categories

Resources