Setting up Spring and Tomcat in eclipse? - eclipse

I am having some trouble getting Spring and Tomcat up and running and recognized by eclipse. I have looked around on google with no luck. Specifically, I am having trouble having eclipse recognize tomcat (I am running linux, and when I browse to the relevant jar file in the runtime environments configuration, eclipse wont allow me to select it). Could somebody please point me to (or describe here) how to get Spring and Tomcat working properly in eclipse and possible provide a "Hello World" example so I can test my first Spring application? Thank you very much.

Have a look at the Spring Tools Suite - essentially Eclipse with Spring specific extensions.

You must have WTP (Web Tools Platform). It is bundled in the Java EE version of Eclipse
Go to Window -> Preferences -> Server -> Runtime environment and click "add"
Choose and setup your server following the wizard
When finished, Go to Window > Show view > Other and locate Servers
It will appear in the bottom panel. Now you can double-click it to set some options of your preference
Right click your project > Debug > Debug on server (The project must be a "web project")
It's generally this. There might be some troubles in the last step, but use google or the link given by Chris for that.

Not familiar with Spring, but here's a link that helped me get Tomcat up and running in Eclipse:
http://www.windofkeltia.com/j2ee/wtp-tutorial.html

you can try eclipse web tools platform for doing this.
You can go to your project then choose
Debug As --> Debug On Server
I think the server adapter for tomcat is installed by default.
You can download the Java EE Distribution Of Eclipse to have this functionality out of the box.

Related

How to run/debug java web service project in eclipse

I have a Java Web Service project which was just handed over to me by a colleague who just resigned (no one is assisting me in my new company). Im new to Java (J2EE) and my background is .Net + frontend + azure so I am pretty much very confused with setting up and running the java project. Also, Since my background is .Net Im referencing everything with how things work in Visual Studio from running a project, setting up a project to setting up and debugging a WCF project which I realized now is very different from eclipse + java.
I would really appreciate if someone could explain to me how I can run this project which is supposedly a java web service (as I was told)?
First I have a project that is like this:
Im assuming that the project boxed as blue is the webservice (and the rest are just libraries)? Is this correct? if so how do I run and debug the project using eclipse
Second when I click on debug as -> debug on server this is all I see:
Another colleague told me to install JBOSS (I haven't installed a server in eclipse) because that is what they used. Is there good documentation (step-by-step guide) on how to install JBOSS to run in eclipse. Im assuming that JBOSS + eclipse is like IIS express + Visual studio. Are there also other alternatives to JBOSS + eclipse like perhaps tomcat + ecplise that I can configure.
I really really find it hard to setup the java web service project in eclipse I have little to no prior experience with java j2ee programming especially with web services so any clarifications with my questions would be much appreciated. To sum up:
How would I really know that the project is a java webservice?
If so, how do I run the project and host the project using debugging in eclipse with tomcat or jboss?
I would appreciate if anyone can point me to the right direction of figuring out the source code
From here we can only guide you, you will have to go through some tutorials to understand how java projects work.
Your project is a webservice project according to your web.xml file because its having context params for rest.
the context param sets a front url to your webservice which in this case is gametime.
Check these tutorials and you will understand how it works
http://www.mkyong.com/tutorials/jax-rs-tutorials/
Create simple examples given in the above tutorial and then you can execute your's program
Jboss is a application server which we use to run our app.
You can install jboss in eclipse or you can use it externally also.
To install eclipse and jboss you can follow the link
http://theopentutorials.com/tutorials/java-ee/installing-jboss-tools-in-eclipse/
The other option is to download eclipse and jboss seperately
and use them.
Go to jbosshome/bin
If you download both of them seperately
then in that case for jboss
Invoke the add-user.sh or add-user.bat script. ...
Choose to add a Management user. ...
Choose the realm for the user. ...
Enter the desired username and password. ...
Choose whether the user represents a remote JBoss Enterprise Application Platform 6 server instance. ...
Enter additional users. ...
Create users non-interactively.
After this go to eclipse and follow steps of below link to add jboss to eclipse
http://www.mastertheboss.com/eclipse/jboss-eclipse/jboss-and-eclipse
A Java web application among other things has a predefined directory structure including folders named WEB-INF, WEB-CONTENT etc.
On how to deploy a web application to Tomcat via Eclipse you can follow the steps in this tutorial.

Running GWT on tomcat in eclipse

I am trying to get a GWT Project running on a Tomcat 7 server in eclipse. I installed Tomcat and i can run other web application out of eclipse on Tomcat without a problem.
Now i generated a gwt maven project for eclipse with the following command and importet it as maven project to eclipse:
"mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin"
I can run this now as Web application (with the google plugin) and i can build a "war" with maven and deploy this with the Tomcat management console on the server. Both is working. But if i choose the option in eclipse "Run on server" and choose tomcat than just the html is loaded but not the application itself. See the screenshot: It doesn't find the "GWTModule.nocache.js".
This file is available in the target folder. What do i have to change to tell tomcat to look in the correct directory?
Tomcat is not able to run GWT code in development mode. You can use Tomcat for server side code, but in this case you need to run GWT development mode with -noserver option (to prevent built-in Jetty instance from running). See this article for more details.
I would recommend using the wtp plugin for eclipse. If you do this you can add your project/resource to tomcat when adding a new server. Here are the steps to use if you already have your project imported into eclipse.
Window -> Show View -> Servers
In Servers
New -> Server -> Choose apache tomcat
Point to the location of your tomcat installation/download
Next
At this point you should be able to add your gwt-maven project which will add the target/project.war to the tomcat modules.
Save it
Click on the newly added server, then click the modules tab at the bottom kind of hard to see.
This should have your project shown in the list of web modules.
Start your tomcat instance then on your gwt application right click and choose Run As -> Web application. Make sure your configuration settings are correct and when the development server starts it should give you the development url to browse to.
You can configure some aspects of tomcat in the overview tab, I would recommend making sure that "Modules auto reload by default" is checked so that tomcat will watch the filesystem for class changes.

Integrating JBOSS and Eclipse

I have JBOSS server. I used to make web applications using just notepad++. I used to create the necessary folders like web-inf and files like web.xml. For larger projects doing all this and manually compiling has become cumbersome. I want to use eclipse for that. I saw this tutorial - http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html . But I don't understand how to make a server. I already have a server. What I want to do is write JSPs and Servlets in eclipse and the build should automatically be deployed in jboss server.
How to to this?
Install JBoss Tools
After that follow the instructions from here to get started and deploy apps to JBoss Server.
To automatically deploy apps after the build you could use a build tool such as ANT or Maven.
I wrote a tutorial for this some time ago: Setting up web development environments with Eclipse
It shows how to setup JBoss within Eclipse (in addition, it also shows how to setup Tomcat and Weblogic), and also shows how to build a simple sample Servlet to verify the proper installation.
If you already use JBoss on the server side, then have a look at the client side as well: http://www.jboss.org/developer
(I haven't tried it myself, but...)
Just open eclipse then go to:
"Help-> Check For Updates" It will check for eclipse updates and installs new availables.
Now "Help -> Eclipse Market Place" Search for "Jboss tools" from search result select one(as your eclipse version) and install it. It will add adapter for new jboss versions.
Now add new server from server view select Jboss version then next add your Home directory of jboss. Then finish.
Step 1 is optional but it sometime it helps.

Tomcat issues inside eclipse

I am very new to Tomcat and web development in general and apologize for what may be a very silly question.
Consider 2 situations:
1.
I start Tomcat outside of Eclipse.
I use eclipse to create a war file.
I deploy it via admin console.
All is ok
2.
I start Tomcat via Eclipse
I can't access admin console
http://localhost:8080/manager/html greets me with 404 error
Same page is behaving properly when Tomcat is started outside of Eclipse
Please advise
Why might the issue be?
Why might the issue be?
You need to configure Eclipse to take control of your Tomcat installation. To do so:
double click on the Tomcat Server in the Servers view
under Server Locations, select Use Tomcat installation
This is illustrated on the screenshot below:
Eclipse creates a new Tomcat configuration separate to your Tomcat installation, in the 'Servers' project. This allows Eclipse to deploy webapps without interfering with anything you've done in your installation (via the manager app or by editing config files manually).
You can reconfigure Eclipse so that it uses the config from your Tomcat installation (see Pascal's answer), or to re-enable the manager app - but read the WTP Tomcat FAQ first as there are good reasons for it working the way it does. I don't recall ever needing to do this - the 'Servers' tab in Eclipse lets you deploy/start/stop/debug/configure apps as required.

How to redeploy the web app using the Eclipse IDE

Im new to Eclipse. I use Tomcat as my run time server, but every time I modified the jsp pages, Eclipse was still displaying the older one. Just wondering how to redeploy the application so the changes can be reflected.
Eclipse: Eclipse IDE for Java EE Developers 1.2.1.20090918-0703
Tomcat: Tomcat 6.0
Thanks
Doubleclick the server instance in question in the Servers view to open its configuration. Now, in the right top you should see a section called Publishing. Open it to verify and configure autopublishing settings.
Eclipse should do that automatically for you.
Otherwise, on the Servers view (Menu Window->Show View->Servers), you can right click on your Tomcat instance and hit "Publish" or "Restart"
Make sure you have the "JST Server Adapters" ("Web, XML and Java EE Development category") feature installed.
Eclipse's publishing functionality requries the project to be a "web project", and in some cases requires additional configurations.
Go to Windows > Preferences > Server > Runtime environments and add your tomcat
Either try using publishing, or (better I think) use the FileSync plugin. There you can tell which folders from your project should be copied (live) to what directory on your machine (the tomcat/webapps/yourapp). With a little more effort the filesync configuration can be made machine independent (only using one parameter as TOMCAT_ROOT), in case you want to check-in the project to a repository where others will use it.
Get the Tomcat plugin. It was nice because you can install Tomcat on your system and then associate your web app with that instance of Tomcat. The plugin will let you stop/start Tomcat and define a server such that when you do a build it knows how to deploy the changes. There may be some newer plugin but the Tomcat plugin worked for me and was fairly simple to install and use. Here is a page from IBM on using Eclipse and Tomcat. Inside that page it points you to the following: http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/