sengsational (3) [Avatar] Offline
#1
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)
smilie 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 (234) [Avatar] Offline
#2
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Thanks for contributing to the forum with this post. We appreciate all the additional knowledge and help we can get from our readers.
stanlick (307) [Avatar] Offline
#3
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
+1 for Dale!
onepd (9) [Avatar] Offline
#4
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
There is very good tutorial
https://sourceforge.net/project/platformdownload.php?group_id=247291
it solves Struts 2/Spring/Hibernate integration problem.
ericyoung (3) [Avatar] Offline
#5
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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 (1) [Avatar] Offline
#6
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
In Step 8, what would be the "appropriate project facets" to set?
ico123 (91) [Avatar] Offline
#7
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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)
smilie 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 (21) [Avatar] Offline
#8
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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 (21) [Avatar] Offline
#9
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Bounce!!! smilie
ico123 (91) [Avatar] Offline
#10
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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 smilie

will have to try with a newer version of eclipse though...
so stay tuned smilie
JavaNoobie (21) [Avatar] Offline
#11
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
> 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 smilie
>
> will have to try with a newer version of eclipse
> though...
> so stay tuned smilie
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,
smilie

Message was edited by:
JavaNoobie
ico123 (91) [Avatar] Offline
#12
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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 (91) [Avatar] Offline
#13
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
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. smilie

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

Hope this helps.
JavaNoobie (21) [Avatar] Offline
#14
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Thanks Ico,
I did manage to run it on a fresh install. thanks for the guidance and sorry for the delay.
ico123 (91) [Avatar] Offline
#15
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Glad to hear you made it! Good!

Thanks for your feed back! smilie
(It's always comforting to get feedback when trying to help.)
sam_house (1) [Avatar] Offline
#16
Re: Getting HelloWorld to Run in Eclipse: a step-by-step tutorial
Thank you very much for your instructions. They worked for me like magic after I got all the correct versions of container and jre installed. Appreciate your time and help.