Deal of the Day

Home » Main » Manning Forums » 2007 » Struts 2 in Action

Thread: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 15 - Pages: 2 [ 1 2 | Next ] - Last Post: Apr 9, 2011 2:08 PM by: sam_house
sengsational

Posts: 3
From: Charlotte
Registered: 12/2/08
Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Dec 2, 2008 7:31 PM
  Click to reply to this thread Reply

Here is are some step-by step instructions to getting the HelloWorld application running on Eclipse. This presumes you already have Eclipse set-up with a server and maybe WTP or whatever.

1) Download the source code for the book and unzip.
2) copy HelloWorld.war to HelloWorld.zip
3) Unzip the HelloWorld.zip file to a folder called WebContent and delete HelloWorld.zip
4) Validate that your WebContent has WEB-INF, index.html, etc.
5) In your Eclipse workspace folder, create a folder called HelloWorld, and move your WebContent folder into it.
6) Start Eclipse
7) Right-click in Project Explorer, New > Project > Web > Dynamic Web Project (next)
8) Project name: HelloWorld > (select your runtime and appropriate project facets) > (next)
9) Leave Context Root and Content Directory, but change Java Source Directory to WebContent/WEB-INF/src > (finish)
10) Right-click your project > Run As > Run On Server
11) Point browser at http://localhost:8080/HelloWorld
12) index.html will say "one moment please" while the jsp compiles, then the menu will come-up.

--Dale--

chad.davis


Posts: 235
Registered: 3/1/06
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Dec 2, 2008 8:43 PM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

Thanks for contributing to the forum with this post. We appreciate all the additional knowledge and help we can get from our readers.

stanlick


Posts: 307
From: St. Louis, MO
Registered: 2/27/04
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Dec 5, 2008 4:39 AM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

+1 for Dale!

onepd

Posts: 9
From: USA
Registered: 12/7/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Dec 8, 2008 9:34 AM   in response to: stanlick in response to: stanlick
  Click to reply to this thread Reply

There is very good tutorial
https://sourceforge.net/project/platformdownload.php?group_id=247291
it solves Struts 2/Spring/Hibernate integration problem.

ericyoung

Posts: 3
From: san diego
Registered: 5/12/09
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: May 16, 2009 12:07 AM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

Good job, Dale. I followed you and use netbeans. I can deploy it to jboss successfully. This is what I did: in netbeans, File -> New Project -> Java Web -> Web Application with Existing Sources. Almost everything was filled in by default. I used "menu" directory as the web page directory (instead of default chapterTwo, for example). Then copy other jsp folders (such as chapterTwo) into Web Pages folder in netbeans, Run it. Go to http://localhost:8080/HelloWorld/Menu.jsp and you will see the results.

KyCyclist

Posts: 1
Registered: 10/5/09
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Oct 6, 2009 12:29 AM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

In Step 8, what would be the "appropriate project facets" to set?

ico123

Posts: 91
From: Germany
Registered: 10/30/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Mar 5, 2010 4:14 AM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

Hello Everybody,

questions on deploying the sample app sources under eclipse
seem to come still frequently so I'd like to point to an older but excellent
howto provided by Dale aka 'sengsational' which I just used/verified today again.

With eclipse versioning up, these steps changed a little bit. So here is an
updated version of Dale's original:
(In variation this would be the list for setting up the Struts2InAction part of the downloaded package. HelloWorld works the same):

1) Download the source code for the book and unzip.
2) Copy Struts2InAction.war to Struts2InAction.zip
3) Unzip the Struts2InAction.zip file to a folder called WebContent and delete Struts2InAction.zip
4) Manually check/Validate that your WebContent has WEB-INF, index.html, etc.
5) In your Eclipse workspace folder, create a folder called Struts2InAction, and move your WebContent folder into it.
6) Start Eclipse
7) Right-click in Project Explorer, New > Project > Web > Dynamic Web Project (next)
8) Project name: Struts2InAction
[x] use defaults (this will make eclipse 'sit' on your given directory of the same name and take over everything therein.)
(Following proposals may vary)In my case:
Target runtime: Apache Tomcat v6.0
Dynamic web module version: 2.5
Configuation: Default Configuration for Apache tomcat v6.0
EAR membership: [grayed out]
Working sets [ ] Add project to working sets (not needed for sample apps)
>NEXT
9) Source folders on build path:
>mark entry 'src' >Edit
Change Java Source Directory to WebContent/WEB-INF/src
Default output folder: build/classes (leave default)
>NEXT
Context root: Struts2InAction (leave default proposal)
Content directory: WebContent (leave default proposal)
but:
[ ] Generate web.xml deployment descriptor
(uncheck to prevent overwriting of the web.xml that comes with the sample app)
>FINISH
10) Right-click your project > Run As > Run On Server
11) Point browser at http://localhost:8080/HelloWorld (no longer needed eclipse starts the page already with step 10)
12) index.html will say "one moment please" while the jsp compiles, then the menu will come-up.

Greetings

JavaNoobie

Posts: 21
Registered: 1/14/11
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 14, 2011 4:06 AM   in response to: ico123 in response to: ico123
  Click to reply to this thread Reply

Hey Ico,
I'm a newbie to the Struts2 framework and found the book to be very useful . However, im not being able to deploy the source code into eclipse with the above instructions.

I followed the exact same steps as listed by you in your post and used tomcat 6.0 with eclipse helios 3.6.1 .
On running the project i get the following message .


HTTP 404--

The requested resource (/Struts2InAction/) is not available.


--------------------------------------------------------------------------------


Should i be including or doing anything in addition to what you have mentioned in your reply.?
Thanks a lot in advance.

JavaNoobie

Posts: 21
Registered: 1/14/11
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 17, 2011 4:04 AM   in response to: sengsational in response to: sengsational
  Click to reply to this thread Reply

Bounce!!! :(

ico123

Posts: 91
From: Germany
Registered: 10/30/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 17, 2011 4:54 AM   in response to: JavaNoobie in response to: JavaNoobie
  Click to reply to this thread Reply

Hey,
successfully reproduced the deploying of the sample chapter code with tomcat 6 and eclipse Galileo
following the istructions of my former posting.
So it still kind of holds true :-)

will have to try with a newer version of eclipse though...
so stay tuned :-)

JavaNoobie

Posts: 21
Registered: 1/14/11
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 17, 2011 4:57 AM   in response to: ico123 in response to: ico123
  Click to reply to this thread Reply

> Hey,
> successfully reproduced the deploying of the sample
> chapter code with tomcat 6 and eclipse Galileo
> following the istructions of my former posting.
> So it still kind of holds true :-)
>
> will have to try with a newer version of eclipse
> though...
> so stay tuned :-)
Thanks for the reply ,ico..

I'm Still not being able to deploy the project.
Did you use the same version of eclipse that i had tried to use??
Should i add any additional spring configuration information?
Any help would be really useful
Thanks,
:)

Message was edited by:
JavaNoobie

ico123

Posts: 91
From: Germany
Registered: 10/30/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 17, 2011 5:21 AM   in response to: ico123 in response to: ico123
  Click to reply to this thread Reply

successfully created a new project Struts2InAction4 with the sample code under Helios now.
Again doing the same steps as given above.

So the source code plua the eclipse installation are freshly downloaded.
Only Tomcat is still v6.0.18.

hm beats me

You can try following additional checks:

a) while giving the name for the project: make sure it is identical with the name of the directory where
your Struts2InAction4 Directory resides.

b) Did you make sure you have a Tomcat installation configured in your eclipse? Can you tray to deploy some sample servlet under this Tonmcat server inside of eclipse? This would make sure that eclipse and the Tomcat server work correctly "as a team".

c) there is a view in eclipse called servers: is there an entry Tomcat v6.0 Server at localhost?
this indicates that eclipse is aware of a tomcat installation and can configure/use it.

d) There are buttons in this "server" view called "publish to the server" and "start the server"
can you hit these? does the tomcat come up if you mark the Tomcat v6 entry and hit start?
see the view "console" for messages on tomcat start up.

In general what you want to do is:
1.) get a ready installed Tomcat configured to be run from within eclipse. (eclipse steers Tomcat: it deploys your project and starts/stops Tomcat with a mouse click)
2.) get eclipse to create a new *dynamic web project* and get this project "connected" with tomcat so that
eclipse will deploy it and deal with it like stated in 1.)

ico123

Posts: 91
From: Germany
Registered: 10/30/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 17, 2011 6:35 AM   in response to: ico123 in response to: ico123
  Click to reply to this thread Reply

Another approach is to simply deploy the 'Struts2InAction.war'
that comes out of the SampleApplication.zip

To do that copy Struts2InAction.war to the webapps folder of your current Tomcat 6.0 directory.
restart Tomcat and try

http://localhost:8080/Struts2InAction
or
http://localhost:8080/Struts2InAction/Menu.action

to see the sample Application come up.

thereby you can prove that tomcat works correctly with the struts2 sample app.

I just did that with a Tomcat 6.0.29.

There should be no further Libraries or whatever needed to get this going.

Generally what you can do is think of different approaches to find a solution.
Such as trying out a simple HelloWorld-Servlet just to ensure the 'basics' things work fine.
You may find the "missing detail" somewhere on the way doing so.
And you will gain Knowledge anyway. ;-)

Sorry for I can't think of what more to recommend.

Hope this helps.

JavaNoobie

Posts: 21
Registered: 1/14/11
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 28, 2011 12:38 AM   in response to: ico123 in response to: ico123
  Click to reply to this thread Reply

Thanks Ico,
I did manage to run it on a fresh install. thanks for the guidance and sorry for the delay.

ico123

Posts: 91
From: Germany
Registered: 10/30/08
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Posted: Jan 28, 2011 4:42 AM   in response to: JavaNoobie in response to: JavaNoobie
  Click to reply to this thread Reply

Glad to hear you made it! Good!

Thanks for your feed back! :-)
(It's always comforting to get feedback when trying to help.)

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor