I've been using IntelliJ successfully for quite a while to develop App Engine projects that contain a single service (formerly 'module'), but am having difficulty setting up a project up that contains more than one service (a default front-end service plus one or more backend services).
I understand the multi-module EAR deployment folder structure, which is different from the single WAR structure, but I have not been able to figure out how to successfully launch the development server with this configuration to debug before I deploy.
Any help would be greatly appreciated.
My application is structured as a multi module Gradle project. I have a top level Gradle Build file and
three subprojects. One project contains the EAR project, and two projects are Goolge App Engine War projects.
I would propose that you start with trying to setup such a project. You will find a good example with a corresponding
project structure at Googles Github
https://github.com/GoogleCloudPlatform/appengine-modules-sample-java
You will deploy the ear to your locale dev server by running the ear gradle task appengineRun
You need to add the following entry to your ear gradle build file (keep the other entries)
appengine {
jvmFlags = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000']
}
Next step is to configure a Remote Debug configuration similar to this
https://stackoverflow.com/a/18692212/2062634
After you started your application you have to start your remote debug configuration which will attach the debugger.
Related
Since App Engine reached the end of life last August on the 30th, it's not possible anymore to deploy updates to the same application using the appengine (appcfg) command line.
I was using the appengine maven plugin which in turn was using appcfg to deploy my application.
I'm looking on how to migrate my application to Google Cloud SDK now but between the limitations I saw that Google Cloud SDK does not support EAR applications to be deployed.
Surprize surprize my applications does have an EAR structure.
Is there a workaround for this or should I completely change the structure of my application?
You don't have to change your application structure at all. It's only the deployment that it slightly altered.
Before, you used to create war artifacts and package them into a deployable ear.
Now you keep creating the same war artifacts but you must not package them into an ear. Instead, you deploy them all together using the gcloud command:
gcloud app deploy ./path_module1/WEB-INF/appengine-web.xml ./path_module2/WEB-INF/appengine-web.xml
path_moduleX are paths to the exploded artifacts (not path to your source code, of course)
as explained here https://cloud.google.com/appengine/docs/standard/java/configuration-files
I've inherited a Spring web app. It's a gradle web app project that I've imported into Eclipse. We're using Eclipse 4.7.3, Tomcat 7.0.47 and JDK 1.8.0.151.
The problem is that when I deploy the project to Tomcat from Eclipse, some of the dependency jars are not copied to the project lib directory. When TC tries to start the web app, there are ClassNotFoundException errors.
I'm new to Java web apps, so what I need is some tips for verifying my project import/build/deploy.
Here's what I've done so far:
Install Tomcat 7.0.47 (don't start it after install) Install Eclipse
4.7.3 JavaEE flavor (which comes with Buildship Gradle integration 2.0 installed)
Import my project as a Gradle project (File -> Import -> Gradle ->
Existing Gradle Project). I point at the project root, choose the
web project for deployment, and use the default settings.
Add a server to the project (from Server view click Add -> choose
Tomcat 7.0 -> point to TC root)
Right click the web target and select Run As -> Run As Server and
choose the TC 7 server I added.
At this point the project builds and deploys. The console shows the TC log. TC starts but the shows an error when it attempts to start the web app (for example):
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
I could copy jars but it's my impression Gradle should be grabbing the dependency jars during deployment. I can verify that some are copied, but others are missing. How can I debug this issue?
Here's part of my build.gradle file
buildscript {
repositories {
maven {
url projectDownloadUrl
}
}
dependencies {
classpath lib_license_gradle_plugin
}
}
The web app is deployed to ...eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0. The lib directory here contains some of the deployed dependency jars. The gradle.properties file contains a list of dependencies, for example
lib_apache_tomee=org.apache.openejb:apache-tomee:1.7.1
This is apparently not the place to ask and answer Gradle/Tomcat questions. I figured out the issue shortly after posting, and not wanting to disappoint the 40 people who've come here for help since then, thought I should finally answer my own question.
First, I was on the right track on how to debug deployment of a gradle/maven app in Eclipse. After it deploys you can check which jars are in the deployment directory. Eclipse deploys locally to a place similar to c:\users\\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core.
Second, the immediate problem I was having was due to using Tomcat instead of Tomcat EE. The answer to this was right in the question:
lib_apache_tomee=org.apache.openejb:apache-tomee:1.7.1
Tomee is Tomcat + Java Enterprise Edition, which includes some extra logging and other jars, the ones I was missing.
I have a Maven web project (Java) that I created in Eclipse. Due to in house IDE restriction I had to move the project to JDeveloper 12c and disable the Maven nature. I had to make several tweaks to project's properties in JDeveloper to make it work.
We found that the back-end code (Service Impl, DAO and Entity classes) can be used on several other projects so we are evaluating/considering to separate the single large web project into 2 projects. One for the front end, which is specific for each project and the other for backend, which is common for all projects.
Here are few ways I thought it can done.
1) From the single large web project, create 2 projects; web UI project and web back-end project.
2) Keep the code as it is and use maven modules or maven overlays feature and generate 2 wars from the same code.
I have not dealt with the projects depending on others or multi module projects a lot. Do you see any issues with this type of architecture, good or bad!
Please let me know if you have any other suggestions or ran into similar situations before. Thanks in advance.
Splitting project into many subproject is a good idea. You could use maven multimodule project setup (docs). Every frontend project would have a separate maven project (module in parent pom) and you'll have one project (module) for the backend.
Depending on your requirements you could then create:
an EAR archive with backend in EJB jar and all frontends in WAR archives,
a WAR archive for every frontend project with EJB jar (or jar for non-plain-javaee setup) inside WEB-INF/lib.
Multimodule setup has few advantages and the main one is that you can build the whole application from scratch just by issuing single mvn command.
I know Google Plugin for Eclipse can create the web-archive (WAR) structure automatically for App Engine projects. If there are more than one modules in my project, how can I get eclipse to create the enterprise archive (EAR) structure, ie., WAR directories for all modules and application.xml, app-engine-application.xml and other default files?
Many thanks for any help! I have not found guidance on this process anywhere.
Google App Engine has added support for EAR module development since SDK 1.8.2. You will have to create a new 'Enterprise Application Project' under Java EE in Eclipse and set Google App Engine as your target run time.
You can find more information at:
https://developers.google.com/appengine/docs/java/webtoolsplatform#enterprise_application_ear
I hope this helps!
I have Maven2 war project built, I'm using the cargo start plugin, and it works great for deploying the web app. To run the maven command, I use a .bat file in my workspace, and I have en external run config to run the the bat file. I can't seem to stop the server from the Eclipse console, or re-deploy.
Does anyone have any advice on how quickly start/stop/re-deploy to Tomcat locally while developing.
Did you try JavaEE tools and m2eclipse? As far as I can see it should work well in most common situations. What m2eclipse does for you is to exactly map the maven configuration to an eclipse projects with the necessary facets set. Also, if the Dynamic Web Application facet is set for your project, you will be able to deploy it to a Tomcat server that you set up in the Server view of JavaEE tools. This configuration allows hot redeploy.
More information on JavaEE tools:
http://eclipse.org/home/categories/index.php?category=enterprise
There is a full Eclipse distribution with the EE tools available on their download site:
http://www.eclipse.org/downloads/
m2eclipse is freely available from Sonatype:
http://m2eclipse.sonatype.org/
At work we use the mentioned software as well. Additionally we use the JBoss tools that provide a feature called Project Archives that let you individually build your web application archive (ear/war/...).
To get startet you should perhaps start a fresh workspace and import the existing maven project (via the import existing maven project wizard). If everything went fine you can set up your tomcat in the server view. Maybe switch to the Java EE perspective. Right click on the newly added server and select Add to add the dynamic web project you just imported. If it doesn't show up in the list try to update the project configuration via the project's maven context menu.
Well, you could use cargo:redeploy to Undeploy and deploy again a deployable (that's a shortcut to cargo:deployer-redeploy). But I personally don't use Cargo this way, I use it mostly for integration testing (i.e. during the build) and use Eclipse WTP during development (this works whether you're using the maven eclipse plugin or m2eclipse).