Creating and debugging app with springmvc and eclipse with internal server - java

I currently have a sprimgmvc app that uses maven. I am currently using mvn:package to build war and deploy it to tomcat to develop and this is getting very cumbersome. I dont have the eclipse configured to automatically build and deploy to tomcat for that matter?
Can anyone please provide me steps that I need to take so that if I make any changes in my project I can just hit save and run and it will deploy to the tomcat OR a way in which I dont use tomcat but use maybe jetty or something else to build and test my app?
Thank you

download STS > Import your project as maven project to the new workspace > mvn install (only once to download all your dependencies) > run AS > Server > baam!
For any other eclipse version pretty much the same but you need to open the server window and configure tomcat , basically open the server tab > new > select your tomcat installation path and then .. just run it on the server. You can even modify code while running your app.

I was able to make this work using some helpers from: Running Tomcat from within Eclipse always gives me 404 (but index.html works) and following these steps:
I suspected that there was something wrong with the initial set up in eclipse. So, I closed the project in eclipse using: Right Click project > Close Project
Then I deleted any files related with eclipse from the folder. These were: .settings, .project, .classpath
I then Re-imported the project as maven project.
I used Window > Show view > server view
In the server view I created a new server and pointed it to XAMPP > tomcat since I already had tomcat.
Right click on the project > Run As > Run on Server.
It should run properly at that point in the browser as well
Make sure to check Right Click Project > Properties > Deployment Assembly - There should be Maven Dependencies added to the project and the deploy path for that should be "WEB-INF/lib"

here is a my way to debug and run maven web project with eclipse. though code is not hot deployed but it works fine for me.
Steps are as follows
open command prompt and go to your project directory. Lets say it is /opt/myhome/myproj
run mvnDebug tomcat:run command, make sure you have mvn and mvnDebug at system path
A message will be appeared like one mentioned in screenshot attached below, this states that maven is waiting for remote connection.
Now we need to Remotely connect to maven from IDE. To do that
Right click on the project and select "DebugAs" ---> "Debug configuration"
Add an new entry under Remote Java application with highlighted details and then select Debug button.
switch back to your terminal and you will get a screen like one displayed below
your web app is ready to debug, put a break point and call it and your IDE will switch to debug perspective
We are done with it. now if you make some changes in your code. you need to stop it from terminal with Ctrl-C and re-execute mvnDebug tomcat:run and then Remote Debug from IDE.
As i mentioned in starting code is not hot deployable as in local debug mode but it is pretty much better approach than rebuilding war and deploy it to external tomcat instance.
I hope this targets your query

Related

How to debug WAR inside eclipse, NOT remote debug?

My originally question has been marked as duplicate as this question and asked to ask a new one. So here I repeat, I am not looking for a remote debug solution. What I am asking is how to debug WAR inside eclipse just as a JAVA application. Following is my original question.
I have seen many online tutorial explaining how to use eclipse to do remote debug of WAR file.
But what I want to know is how to do the debug inside eclipse just as debugging a JAVA application? I have Tomcat 7 configured in my eclipse as a server. And I have tested it with a sample servlet program successfully meaning I can set breakpoint in the source code and run into it.
My WAR application is built by gradle. I have imported the gradle project into my eclipse and build it ok inside eclipse by running gradle task inside "gradle tasks view". I added the project into the server. However, when I try to use "Debug as > Debug on Server", it fails and the breakpoint is not get hit. Anyone could share the experience to debug WAR inside eclipse?

How do I find out why Eclipse is stuck in an endless build cycle?

I've got Eclipse building a Maven project that I just imported. I have Build Automatically checked and Eclipse is constantly building. It builds and waits a few seconds and builds again without me making any changes. I noticed that this only happens when the server is running so I'll include some info on the setup here:
Have a local install of Tomcat.
Eclipse is set up to start Tomcat but points the Tomcat executables to a directory of its own making (Server Location is set to "Use workspace metadata").
Eclipse is set to "Automatically publish when resources change".
As far as I know, Eclipse (or Eclipse's embedded Maven) is building everything into the target directory at the root of my project. Is it possible that Eclipse doesn't realize that the target directory is not supposed to be scanned for changes?
There are zero references checked under the project properties -> Project References.
I'm at a loss as to what this might be. If there are other settings that someone would like me to confirm, please let me know.
This seems to be the same problem but none of the answers seem to apply to me. I'm not sure what the original poster's comment that "added annotation processing to my project which interfere the build process" means.
Does your code generate something in src/main/java or src/main/resources ?
Only then, eclipse scanner can interpret this as 'source change' and then build and deploy continuously.
Any change in 'src' should trigger build
Any change in 'target' should trigger deploy.
If your code is generating data in target (logging for e.g) you would see tomcat deploy happening continuously

Deployment-Error: Java-Webproject from netbeans to glassfish 4.0

Setup
I'm using Netbeans 7.4 on Mac OSX Mavericks and Glassfish 4.0 (build 89) on my dedicated server and JDK 1.7. To use the server locally I setup and ssh-tunnel. The following way:
ssh -L 4848:127.0.0.1:4848 -p 6122 glassfish#XXXXXXXXXX
This is working perfectly fine, I can access the server via localhost without any problems. To use this server I added a server in Netbeans, see prinscreen:
Problem
Now I'd like to deploy the project to the server (Right-Click Project -> Deploy) but I get following Error:
Building jar: /Users/tzhware7/NetBeansProjects/SkyLogicAddon/dist/SkyLogicAddon.war
Distributing /Users/tzhware7/NetBeansProjects/SkyLogicAddon/dist/SkyLogicAddon.war to [glassfish.ivo]
glassfish.ivo, deploy, null, false
/Users/tzhware7/NetBeansProjects/SkyLogicAddon/nbproject/build-impl.xml:1050: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 1 second)
Now I'd checked the line where the Error-Show's up, which is following (1049-1051). For me everything looks normal:
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
In advance I checked the serverlogs, which are empty - no error is shown. What am I doing wrong? Can someone advice me what to change? Thank you in advance!
Edit 1 - 08.01.2014
Allright, I didn't found a solution for solving the problem above, but following way worked at least to deploy the app manually.
Netbeans -> Right-Click on Project -> Clean/Build (now check your outputlog where it save's the project.
Now go to that path, you'll shoud find a .war file
Log into your glassfish-server -> Click Application's -> Click deploy -> upload the .war file -> Click again deploy
Now glassfish deploys the project for you. :)
Edit 2 - 17.01.2014
I could fix the problem, following was wrong. In netbeans I configured that the Target should be domain1, if you do this, it won't work. Let the target be empty, and everything works fine.
Thank you Tim B for your help!
If NetBeans can't talk to the server when you add it to the list then it silently fails. The server appears in the list but you can't click on the + and expand it out to see what it contains.
Check in your server list that NetBeans can actually see the server. Also keep in mind that NetBeans needs access to the admin port (usually 4848) not the normal web one, although it looks like your tunnel is correct for that.
You also need to turn on remote administration and set up the username and password etc. Try pointing a web browser to your localhost 6122 and check you can log in to the admin panel using the same username and password that netbeans is using.
To turn on remote administration:
https://blogs.oracle.com/quinn/entry/securing_adminstration_in_glassfish_server1
asadmin enable-secure-admin
You will also need to add an administrator username and password.

Can't Save "Is a Tomcat Project" setting in Eclipse Project Properties

I have a Spring MVC project that I've been deploying to Tomcat (installed both locally and on a server). I'm using Eclipse Indigo as my IDE. To deploy, I had been right clicking and choosing "run on server", which would run fine on localhost. For deploying a WAR to the actual server, I had been right clicking on Project, selecting Export, and going through the wizard to deploy a WAR file.
My Eclipse/Java is rusty, but I did remember that when I used it a couple of years back, I was using the Sysdeo plugin for Tomcat that would give me an option for Deploy to War right from the right click context. So, I poked around and found "Mongrel", which I installed. With that in place, I went to Mongrel under preferences, and set up my Tomcat version, so that I can click the little start/stop Tomcat icons and start/stop the server. This was successful.
What I can't now do for the life of me is, in Project Properties->Tomcat, choose "Is a Tomcat Project". I check the checkbox and then click Apply and/or OK to dismiss the window, and when I open it again, my setting is not recorded. I have tried checking the box and adding other options (like context name, path for a WAR file export, root sub-directory, and activating dev loader), but nothing I do "sticks".
Can someone tell me what I'm missing, or at least point me in the right direction? I'm stumped.
Thanks in advance.
I know this may be a late answer, but as I had the same issue today, I figure I could post my findings here.
I had the exact same problem as yours when I installed mongrel from the eclipse marcket place.
The solution for me was to uninstall mongrel, delete the plugin folder in the plugin directory of eclipse and then get the plugin from the project page on sourceforge.

Can't get eclipse to recognize my plugin

I exported my eclipse plugin through the "Export Wizard" in the manifest and seems like everything went well (no errors). It created a .jar file within a plugin directory in a zip file.
I thought putting the jar into my Eclipse plugin directory would install it (after re-launching eclipse) but that didn't work. Eclipse can't see the plugin (the perspective isn't showing up)
I tried with Help->Install new software->local archive but it keeps saying "no software found"
Can you help me getting my plugin ready to be installed on a fresh Eclipse copy?
Ps. my plugin uses other dependencies like EMF/GMF
In eclipse, go to your console window. From the drop down meny, select OSGI console. Run the command ss or ss <name of your plugin>
You will then see the state of your plugin and a number. The state will probably be "installed" which means if has been found, but some dependencies were not satisfied.
Run the command diag <number of your plugin> and you will see why it wasn't started.
For more details, see Wheres my bundle
Edit: A first step to verify that the plugin is working would be to start up a new eclipse instance with your plugin. In the run configuration dialog, there is a tab with all the plugins that should be started. Make sure yours is checked and it will start with the new eclipse instance.
If you are using Eclipse 3.4 or above, put your plugin in the 'dropins' directory.
To install via Help->Install new software you need to create an 'Update site' or a 'p2 repository'.
By far the most ellaborate descriptions of installing your plugin is provided by Vogella deployment of your plug-in
It covers all 3 possible ways in which you may install your plugin detailing the pros & cons of each of the following approaches :
1 . Installing your plug-in from your Eclipse IDE
2 . Export plug-in and put into dropins folder
3 . Create update site for your plug-in
Sometimes you just have to restart Eclipse. File -> Restart and try again. Worked for me because Eclipse was caching the results of my local update site.
Open plugin.xml
In "Overview" Tab in "Exporting section" go to "Export Wizard"
In "Export" window in "Destination" section choose "Install into host. Repository" and choose dir which will looks like "xxx/.metadata/.plugins/org.eclipse.pde.core/install/"
Press "Finish" button
Wait for Export to finish without any problems
Restart Eclipse

Categories

Resources