I've created a Spring MVC project that can be deployed to my GAE instance very nicely. Now I'm trying to make it so that I can deploy it to the flex environment with IntelliJ with no luck.
My project structure is as follows:
\src
\main
\appengine
app.yaml
\java
normal java project files
\resources
property files
When, in IntelliJ, I create a new Run Configuration of "Google App Engine Deployment" the setting / environment is always "App Engine Standard Environment." I can't seem to make this be part of the flexible environment.
My current app.yaml:
runtime: java
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
runtime_config: # Optional
jdk: openjdk8
server: jetty9
manual_scaling:
instances: 1
I've tried copying all of the setting I can find from example project on github
Here's a screenshot of my deployment
Do you also happen to have an appengine-web.xml configuration file in your project? If so, this will supersede any flex configuration and the plugin will assume an App Engine standard deployment.
If so, try removing it (or renaming it) and then recreate the deployment run configuration. At this point it should be marked as targeting the App Engine flexible environment.
If you don't have this config file (or if renaming it doesn't help, or if your list of deployment sources does not include any war/jar artifacts), then its possible that you have a native IntelliJ project (not built with Maven / Gradle etc.) and that your Artifact settings are insufficient.
For your target artifact to be deployable to App Engine flexible you need to ensure that you have a non exploded artifact set up (either a war, or a jar if your project has an embedded server):
Open Module Settings: right click on the root of your project -> Module Settings
Click on 'Artifacts' on the left
Check what artifact types you have listed.
If its only an exploded war then try creating a new war (non-exploded) artifact - select Web Application archive, then choose your module
Save this and then recheck your deployment run configuration
I'm sure you've done this already, but perhaps you just missed something simple: the flexible environment requires a special IntelliJ plugin, Cloud Tools for IntelliJ (installation quickstart instructions).
Related
I use Eclipse and Gradle for a few "desktop" / command line Java application projects, including multi-project projects.
But I haven't used Gradle for a Java web application project in Eclipse so far. My usual approach is:
Create empty workspace and configure it (JDK, Runtime environment Tomcat server)
"Create a Dynamic Web project", run through wizard
And everything works fine. The project has a proper structure (WEB-INF exists, web.xml is created etc.), it compiles and it is deployed automatically to Tomcat by Eclipse. CATALINA_BASE is set to some temp folder in the workspace.
But how do I create a Gradle project which is a "Dynamic Web project" and not just a command line Java application or java-library?
I have tried two approaches:
Create a Gradle project using the wizard in Eclipse. It seems to create a java-library project always with a lib subproject. Having created the "wrapper" project and the actual Gradle project lib, set java and war as plugins for this. Open the project properties of the Gradle project lib, Project Facets, add Dynamic Web Project Facet (4.0). Create run configuration to make it run in Tomcat server.
Create a Gradle project using gradle init in an empty directory. Create application project instead of library. Import that existing Gradle project into an empty workspace (instead of using Eclipse to create the project). And apply the same procedures as above (facet etc.).
None of the approaches gave me a working, ready-to-use web application project that has the expected folder structures (WebContent, WEB-INF, ...), that deploys correctly (no deployment or e.g. web.xml missing) ...
I spent several hours to use Gradle in a Java web application project in Eclipse. (Because I want to profit from its easy declarative dependency management.) But I didn't manage to make it work.
Also the samples in the Gradle docs do not contain a Java web application project:
https://docs.gradle.org/current/samples/index.html
Only Java Application or Java Library.
Has someone else already managed to set this up?
Gradle 7.0.x
Eclipse 2021-03
Tomcat 9 or 10 (I've tried both)
AdoptOpenJDK 11
Windows machine
Please share your approach. :)
I have my main web application(has its own POM) that is dependent on module A((has its own POM).
When i make a build using mvn install on web application, it dependent modules
are also built in to jar file and ultimately included under WEB-INF/lib folder of main web app.
But that does not happen in when i make build using eclipse kepler (containing both maven projects i.e main web app and its dependent module A).
When building with eclipse, it just put the modified classes under moduleA/target/classes/ folder but does not make any updated jar file and put it
under WEB-INF/lib folder of main web app.
Is there a setting where i can configure eclipse building the project same way as maven does (which will really save lot of time and help in hot deployment) ?.
It used to work in one of my projects looks like some configuration is required for this.
looks like m2e connector(i have SonarQube) needs some configuration to make eclipse build in the same fashion as maven build
When i do the project > right click > mvn install , i am able to make jar file.
But what i want is eclipse build automatically option do
the build for project/module wherever modification is done , construct the jar and include it in parent WEB-INF/lib folder if it is dependent module ?
Assuming you're using the Java EE flavour of Eclipse, you can easily deploy Maven based web applications to a local server (like Tomcat, Wildfly...) from the server view.
m2e-wtp, included in recent Eclipse Java EE distros, takes care of configuring all Eclipse settings based on your project pom.xml configuration and dependencies.
See this screencast to see how simple it is : https://www.youtube.com/watch?v=TksoKkSP208
For the record, deployment/publishing is performed by each server adapter differently. They're responsible for publishing the proper jars under the WEB-INF/lib folder of the deployed application. Dependent jar projects are automatically zipped and deployed to WEB-INF/lib without user interaction
I have a Vaadin project and an external Java project. I would like call code in the external project from Vaadin. I have both project imported in Eclipse and the Vaadin project references the external one in Eclipse Java Build Path. Eclipse reports no error but when I deploy the Vaadin application to Tomcat (using Project > Run As > Run on Server), I get the following error:
HTTP Status 500 - java.lang.NoClassDefFoundError: com/example/MyClass
Note that the Vaadin project is based on Ivy, not Maven.
I've tried searching around for Vaadin external project dependencies with no success. I'll be thankful for any suggestions on how to use the external project's code from Vaadin.
The solution was to add the external projects to the classpath of the Tomcat instance in Eclipse. Select
Run > Run Configurations > Apache Tomcat > (your Tomcat instance) > Classpath
Click Add Projects... and add the required project.
This will work for development. For deployment, the external project must be packaged as a library to a .jar file and copied manually (or using a build script) to WEB-INF/lib directory of the Vaadin project (see this answer on the Vaadin forum).
Another solution which will deploy your dependencies directly in the WEB-INF/lib is to :
- Add your external project to the Project / Java Build Path / Projects
- Add your external project libraries (assumed to be Maven here) to the Project / Java Build Path / Libraries
Click on Add Variable / M2_REPO and click on Extend to select the right library.
This part can be painful if you depend on many libraries.
- Add your external project and java build path entries in the Project / Deployment Assembly panel.
- Restart your Tomcat instance.
Check the content of the WEB-INF/lib directory under:
eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\your_ project\WEB-INF\lib
Take your external project and export it as a jar. Then copy your new jar and any dependencies into the WEB-INF/lib directory of your vaadin project. This will work in a deployment as well as development environment.
I'm working with some very old, monolithic software that is basically a heavily customized JBoss deployment. Unfortunately, this means that JBoss can't be started from the "Servers" view in Eclipse, it must be started as a Windows service or via the command line. There are multiple WARs/EARs, but the WAR classloaders are rarely used and most of the actual class files are located in jboss/shared/lib as .jars.
We need a way to run a Maven build in Eclipse (via m2e) and deploy the class files in the resulting .jar to C:/product/jboss/shared/lib so that when we start JBoss, we can use Eclipse to debug (as a remote java application). Ideally, the artifact that Maven pushes will not overwrite the existing .jar file that was originally installed. For example, if the Maven project builds an artifact named myjar-1.0.0.jar, we need a way to deploy the classes inside of myjar-1.0.0.jar to C:/product/jboss/shared/lib/classes so that they are picked up by the classloader prior to C:/product/jboss/shared/lib/myjar-1.0.0.jar, which was installed with the product.
Currently, our (very hacky) solution is this:
Under the project configuration's Java Build Path > Source tab, we use the "symlink" functionality under Advanced to map the Default Output Directory (e.g. project/target/classes) to a class folder (e.g. C:/product/jboss/shared/lib/classFolder). This modifies the .project file, which is checked into source control.
We build the project normally with a m2e launcher (e.g. clean install).
Assuming the Maven build is successful, we run an Eclipse project build. This pushes the class files to C:/product/jboss/shared/lib/classFolder:
We restart JBoss. Since classFolders take precedence over jars, JBoss will load the classes in C:/product/jboss/shared/lib/classFolder, which are identical to the classes in our Eclipse workspace.
We attach to JBoss and debug the project as a remote java application.
Pros:
We're able to push our new classes to JBoss and test them without backing up the original jars and copy/pasting the new ones by hand (jar hell).
Cons:
We're compiling twice -- once with the maven-compiler-plugin, and
once with an Eclipse project build (Java Builder).
The symlink functionality is hit or miss in my experience. Sometimes we need to
do the refresh project/close project/build project dance to get it to
work.
Is there a better way to do this? I cannot force them to restructure the project so heavily that all deployables are container-agnostic WARs, but our developers need to be able to make changes and quickly test them without manually copy/pasting .jars.
How old is old?
Have you looked at the Cargo plugin?
http://cargo.codehaus.org/Quick+start
It can deploy to JBoss 3.x.
It has a Java API so you should be able to write something to extend it to do what you want.
Why are you trying to deploying classes instead of jar files?
You can still remote debug via Eclipse with jar files.
Worst case scenario - use Ant.
Maven is not designed for this kind of stuff, trying to force it to work will just cause you pain.
Once you have got Maven generated the right artifacts, work out what you would do manually and then script it via Ant.
I would try looking at the maven-dependency-plugin which has the possibility of copying artifacts to different location.
Please check your Deployment Assembly (project -> properties -> Deployment Assembly) and verify if your maven libs are there.
I have a web project in my workspace that has a dependency on a java project in the workspace.
In project references, I made my web project reference the java project, but there are still build errors that indicate that classes in my java project are not referenced by my web project.
An Answer
This is not a direct answer to your question, but is an solution to the problem you are experiencing.
The java project must be deployed for your web project to run in any environment other than you eclipse debug environment. I assume that the deployment technique is a JAR file.
Build the java project. That is, produce the deployable jar file. I will call this the XYZ.JAR file.
Put the XYZ.JAR file in the /WEB-INF/lib of your web project.
Possible answer to your question
Check the following, I suspect your answer lies therein:
Is the JDK Compliance of the java project different from the JDK compliance of the web project? Higher on the web project is fine. Lower on the web project will not work.
Did you build the java project?
Is automatic build set for the java project. I suggest that you sould set auto build.
Try running a clean then a build on the java project then the same on the web project.
You say dependancy. Do you mean that you added a reference to the java project in the Properties!Java Build Path!Projects tab of the web project? If the answer is no, then you should add one. Note: this is fine for compilation, but in no way helps once you deploy.
Have you setup an EAR file with which to deploy the java project and the web project (not applicable if you are deploying to a servlet container such as Tomcat)? If yes, then add a reference to the java project in the Properties!J2EE Module Dependencies of the web project