I am running my project on weblogic , the source code of the project is at 'C:/Source Code' and when I run mvn clean install the .ear file is getting created in C:/Ear/abc.ear, and I have imported the project in eclipe from C:/Source, the abc.ear is autodeployed in C:/oracle/Middleware.../Autodeploy
Now whenever i make changes in any java class i have to manually replace the class file which is build in eclipse to C:/oracle/Middleware.../Autodeploy.
Is there any way to automate this so that the changed class file would be automatically available to the C:/oracle/Middleware.../Autodeploy/abc.ear
For Eclipse development with WebLogic, install the Oracle Enterprise Pack for Eclipse to better integrate with WebLogic. You will no longer need to use the autodeploy and your application will update automatically.
http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html
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 a Java project using the Spring MVC framework and Maven as its build system. The primary IDE I wish to use is Eclipse for Java EE. I am using a standard Maven project structure for my application: source code is in src/main/java, resources for the application are in src/main/resources and code related to the web container are in src/main/webapp. In src/main/webapp/WEB-INF, I have a web.xml file for configuring my server and multiple folders for Spring-related files, such as context XML files and views. These Spring files are linked to legally in web.xml.
When I try to run the project using the Maven-Tomcat7-Plugin (via the mvn tomcat7:run-war goal), my project launches successfully and I am able to view my web pages and see my REST controller in action without issue.
However, when I try to run the project in Eclipse, using its Run As Server option, it never works and I have no idea why not. I keep getting an error dialog box titles Server Error and with the message The selection cannot be run on any server. I have already configured a Tomcat 7 server runtime legally in Eclipse; I can use this runtime without any problem for my other Java projects. I have tried everything that Google, Stackoverflow and blogs suggest to get an Eclipse Maven Spring project working on an Eclipse server. I've tried to delete the Eclipse project, delete the Eclipse-workspace files and reimport the project (both as a Maven project and as a regular Java project), but to no avail. I've also tried enabling the Dynamic Web Module in the Project Facets and setting the web directory to src/main/webapp, but also to no avail.
I'm baffled; I've worked with Tomcat servers in Eclipse many times before but it is just not working for this specific Spring project, even though it deploys just fine on Tomcat using Maven. Does anyone have any idea what might be going wrong? Have I forgotten a trouble-shooting step? Is there something wrong with my project setup that is conflicting with what Eclipse expects in a Web Server project? Thanks in advance.
I think I figured it out. There may be a bug in Eclipse's Dynamic Web Module, version 3.1. My project was being imported using this version because I am using version 3.1 of javax.servlet-api in my pom.xml. When I changed the version down to version 3.0, I am now able to run it as a server.
Basically, to do this change, I had to go into the .settings/org.eclipse.wst.common.project.facet.core.xml and change the <installed facet="jst.web" version="3.1"/> tag to instead be <installed facet="jst.web" version="3.0"/>.
Time to file a bug with Eclipse...
I have set up a project inside Eclipse which I can debug on a Glassfish (3.1) server using the Eclipse Glassfish plugin. So when I click 'Debug on server', it uploads fine and I am able to step through the code correctly etc.
The problem is that I don't know if the program is being compiled/build (to a new .war) each time I press debug. I have got an Ant script in the project (as I previously built the project via terminal) but I'm not sure if it is actually being used in Eclipse.
Is there any way to check if my ant script is being run?
Also, how does Glassfish know what resources to upload? Does it just look for any .war files in the project?
Not sure about this particular jar plugin but as far as I know here is how Eclipse handles web applications:
Eclipse automatically compiles all of the sources in the class path
Then it creates a configuration file which tells Application Server to look for webapp on your project folder and does some mapping based
on your project setup. This will not create a WAR file. Eclipse will
just map WEB-INF/classes to {projectDir}/bin, your classpath jars to
WEB-INF/lib and so on.
When launching the Application Server, eclipse will feed it the config file made above.
Actually answering your question: Eclipse will not use the Ant script you created, nor will it create a WAR of any kind. It will just use project configuration to properly map project folders to web application structure.
Again, this is how eclipse handles things by default, the plugin you're using might do something different. This is based on my experience and is not based on some kind of documentation.
I develop a java web app in intellij which is then deployed to tomcat (tomcat integrated with intellij). It is a maven project.
So, usually I do this:
I run package goal in maven. Then I run tomcat in intellij.
Or I may not package it with maven and run tomcat in intellij right away.
So what is the difference then?
If I package it with maven and then run tomcat in intellij does the source code get compiled and packaged again and then deployed? Or just war produced by maven goal is deployed to tomcat?
Well if I don't package it and just run tomcat in intellij then it obviously gets compiled by intellij goal.
I am a bit confused here.
You don't need to run mvn package before running your webapp within Intellij.
What you can do is configure your Tomcat server to run your war exploded.
In the run/debug configuration, you can specify before launch operation.
By default,
a make is done
build artifact in exploded mode is done
If you prefer to work with a-non exploded war, last step would be build artifact instead of build exploded artifact.
(Am a maven noob)
Have a maven built webapp which uses spring, etc.
When I run "mvn clean install", it generates a .war file in the target directory.
I copy the .WAR file to tomcat for deploying the app.
Debug the app
Edit the code
This process takes a lot of time. When I earlier used ant, I would point tomcat's server.xml to my webapps directory. Also, Eclipse would put all of its classfiles in my webapp\WEB-INF\classes folder. If I had to modify any JSPs, I would just edit and there was no need of additional copying. If I modified a .java file, Eclipse would build it and put the .class file in the WEB-INF\classes folder so that Tomcat would pick it up.
Now, each time I make changes to a .jsp, I need to manually copy the .jsp to tomcat's webapps directory. Isn't there a way that a maven built app can optimize this process ?
So, where do you point your tomcat at that makes development productive?
project (where pom.xml resides)
src
main
java
resources
webapp
WEB-INF
target
webapp
webapp.war
Basically, I would like to know how to configure eclipse(3.7.1) and tomcat/maven so that the edit/deploy/debug cycle is really fast.
UPDATE1
1) I was able to get m2e(http://download.eclipse.org/technology/m2e/releases/) installed in indigo(v. 3.7.1 of eclipse). it had 2 components
a) maven integration for eclipse
b) slf4j logging
It installed successfully asking me to restart eclipse. I restarted.
2) Next, I installed m2e-wtp (at http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/)
It had 3 components
a) maven integration for eclipse
b) maven integration for eclipse Extras
c) maven integration for WTP.
When I selected all 3, I got some error. So, I unselected the 1st two and only selected the 3rd one and then it installed successfully asking me to restart eclipse. I restarted.
#Raghuram
I ran the 4 steps that you suggested below. Only the 4th step resulted in an error and my webapp could not get deployed. It resulted in an error "File not found --- .svn/.wcprops/.
http://i.imgur.com/Pg1aq.png
What should I make of it ?
Thanks again,
I'd recommend you to use cargo to deploy automatically to a local container (that can be downloaded and started)
Maven+Cargo
Then having that started with jpa activated (so that you can remotly debug your code) you just have to attach a listener and debug from eclipse, intellij, whatever.
For JSP, talking Intellij, you must tell your IDE where to package files (right-click 'package file") which is done in the project setup (output classes dir in WEB-INF/classes)
Check Tomcat 7 - Maven Plugin? for an example cargo configuration for Tomcat 7. After the confiuration is valid you can deploy to your Container using mvn cargo:deploy and mvn cargo:redeploy
If you use Eclipse Indigo with m2e and m2e-wtp, you can pretty much develop and debug your web application without any manual step.
Add tomcat as a server in Eclipse
Import your maven project as a maven project in Eclipse.
Build the project (using Eclipse or using maven)
Choose "Run as server...".
Eclipse will pretty much take care of hot deploying jsps as well as classes on changes.