Why won't basic spring 4 sample run with Eclipse kepler? - java

I am using the sample project code here that i've downloaded from the following:
http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/
Direct link here:
http://javahash.com/wp-content/uploads/2014/02/Spring4MVCHelloWorld.zip
I have Eclipse Kepler SR2 (J2EE), Tomcat 7 64-bit, Java 7.
The project does not appear to be a web project, so I add "Dynamic Web Module" version 3.0 and "Java" (version 1.7) to it. I right click, maven install, which appears to run fine. When I try to actually deploy it on tomcat, it does not give any errors in the console, but when the browser window pops up it shows a 404
http://localhost:8080/Spring4MVCHelloWorld/
HTTP Status 404 - /Spring4MVCHelloWorld/
--------------------------------------------------------------------------------
type Status report
message /Spring4MVCHelloWorld/
description The requested resource is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.39
That said, how do I get this "basic" example running in eclipse? Anyone able to get this working successfully? It feels like it should be more trivial than the 5 hours I've spent on trying to get this sample code working to no avail.
UPDATE:
Still continues to fail despite using Tomcat 7.0 server.
Download the sample, extract contents to workspace directory.
"Import Existing Project" in Eclipse
Since there is no "Run On Server" option, I right click on the imported project directory and hit "Properties".
I go to "Project Facets" and check 2 things: "Dynamic Web Module" (3.0) and "Java" (1.7) and hit apply then "Ok".
I right click on the project Spring4MVCHelloWorld and click "Maven"->"Update Project". Then I click "Run On Server".
There are no errors in the console, but the web browser that pops up in eclipse shows a HTTP STATUS 404.
I tried going to:
http://localhost:8080/Spring4MVCHelloWord/hello
and the same:
HTTP Status 404 - /Spring4MVCHelloWorld/hello
shows up, but the tomcat shows up as:
Apache Tomcat/7.0.53
Note that this is the 64-bit version. What steps am I missing? How do I get around this silent failing?

Apart from what Dimitri stated, your log seems to indicate that you are using
Apache Tomcat/6.0.39
That version of Tomcat does not support ServletContainerInitializer which your Spring web application depends on for configuration. Upgrade to a Tomcat version 7+.
It seems like the Maven update doesn't work for you (or for me).
First, go into Properties -> Deployment Assembly. You need to get rid of Web Content if it's there and add src/main/webapp (which is a maven convention). You also need to add the Maven Dependencies as shown below.
Finally, and this might not be necessary, delete the web.xml provided to you and re-create it by selecting and right clicking Deployment Descriptor in the Project Explorer and clicking Generate Deployment Descriptor Stub.
Also, make sure your Java Build Path in the Properties has a Java 7+ version of the JRE.

As far as I can see your controller only maps to /hello, which means your URL should be:
http://localhost:8080/Spring4MVCHelloWorld/hello
Another thing that might be interesting to you is that if your having problems with certain project facets (like Dynamic Web Module) not being recognized, you can usually fix them by righ clicking your project, opening the Maven menu and choosing Update Project.

Related

vaadin4spring security sample: failed to load widgetset

I am desperately trying to build a little Vaadin project with login secured pages/views. I have found vaadin4spring and thought I could start based on the security sample. However, after importing the project and running it, I am receiving the message (without any changes at the project):
Failed to load the widgetset:
./VAADIN/widgetsets/org.vaadin.spring.samples.security.Widgetset/org.vaadin.spring.samples.security.Widgetset.nocache.js?1424243461387
I have also tried to compile the widgetset manually, which wasn’t possible at the beginning (missing WebContent folder). After converting the project to use WebFacets and adding Dynamic Web Module the compilation was possible. But the widgetset related error message was still the same.
Can anybody help me with this problem? I have the feeling that it is just a little thing I am missing.
I think you have imported the sample somehow wrong, because you are talking about WebContent folder. I bet you are using eclipse (because of WTP related WebContent folder).
Delete the old project from workspace and possible settings files eclipse created
Choose File->Import->Maven->Existing Maven Project
You probably want to make one fresh install before you start to play with the project: from the top level "parent-pom" project, choose with right click: Run as -> Maven install. Get a cup of coffee, the build will take a while.
Enjoy!
To start e.g. the Security sample you seem to have tried, just execute the main method from org.vaadin.spring.samples.security.ApplicationInitializer. In eclipse, right click on the class and choose Run as Java Application and the app will launch with embedded Tomcat at http://localhost:8080/

Can't Create a JBoss Server in Eclipse

I'm using eclipse indigo and I'm trying to follow this tutorial to set up jBoss. It says...
When installing software from this site, some different categories are shown to install - I have chosen the first one which is “Abridged JBoss tools 3.3”
which I have installed. Then, it says:
The next step after the plugins have been installed is again to install the application server itself.
Which I have (jBoss 4.2.2.GA). So now I'm supposed to do this:
Now, define the server runtime in Eclipse. Open "Window => Preferences" and navigate to the "Server => Runtime Environments" node. Press the "Add" button and in the "New Server Environment" dialog, choose "JBoss Community => JBoss 7.1 runtime". Press the "Next >" button. In the next dialog, enter the path to the directory where you have unpacked the JBoss server earlier.
And I'd love to do that, but I don't see the jBoss Runtime Option. I only see "Basic" and then HTTP Preview and HTTP Server (also J2EE Runtime). Plus, I don't have a JBoss perspective, which I should have, and JBoss Central didn't show up when I restarted eclipse. I tried searching my jBoss folder for runtime environments...I got nothing. It's like I don't have the JBoss Tools.
Apparently, this tutorial is exactly what I need to do to set up my server (says my co-worker). But I'm failing and I'm not sure why. I did set-up a JBoss server once before on a different (and also, now broken) laptop with no problem, but now I'm having trouble since nothing seems to be working correctly. Does anyone else know why this is failing/what's going on?
In eclipse, after clicking on "ADD" you can "download additionnal server adapters" on the top right of your frame! try to click on this and select "JBOSS" if it was not present!
By default i had Jboss in the list...
hope this helps!

Webapp shows 404 page after project renaming

I have been working on this web application using Eclipse and m2e (maven plugin for Eclipse).
After a while I decide to change the project name in eclipse doing: Right click on project >> refactor >> rename
Following this I see a few errors coming up, mostly to do with classpath configuration & java versions mismatch. I fix them, adding the maven dependencies to the build path, and updating the java versions to be used during compilation & run time.
I rebuild my web app & restart my server (Tomcat in this case). Open my browser to go to my app's root url. And I get a 404 page (everything looks fine in the console btw).
I've been going through my buildpath and classpath config to double check if anything was coming from there but everything seems fine. I'm confused and unsure where to look at.
Thanks in advance
This really depends on your Setup. If you are using the default path, it is (as Kal said) myserver/newappname.
If you are using a url that you have configured in webserver for easier readability like (myapp.myserver.com) you would have to change the redirection in your server from your old appname to the new one.
Actually,
404 HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested.
1. Check your path with newapplication name.
2. See inside your server, Is there a resource with (newNameApp.war)?
3. As you are using maven, try to build the project and see the log, by which name war is generated, and where the war got placed.
I faced the same situation and simply restarted Eclipse and no more 404 afterward

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.

Unable to associate project with a runtime server in eclipse IDE

I had created a dynamic web project. AS of now it has a jsp file which am trying to run. When I tried to associate the project with a specific runtime(tomcat 6.0), it is not happening.
I right clicked on the project/properties/Targeted Runtimes. It doesn't show any runtimes(I have added tomcat 6.0 in servers). When I click the checkbox 'Show all runtimes', everything comes in disabled mode.
What could be the problem ?
Attached screenshot of the problem.
Update: I even tried to create a new runtime and associate it with the project( project/properties/Targeted Runtimes/new). Even the newly created runtime is getting disabled and am unable to associate it with the project.
To add a project to a runtime you must have a match between your project and your runtime; you have to check:
project facet: to run on tomcat it must be a Dynamic Web Project
java version: you can't run for example a java 7 project on a java 6 runtime
web project version: you can't run a project that doesn't match the Java EE version deployable in the runtime
Once you've validated the match between your project and the runtime, you need the project to target the runtime, as follows:
Open the project in Package Explorer, Project Explorer, or Navigator.
Right-click on the project, and select "Properties".
Click on "Targeted Runtimes" in the properties window.
Select the checkbox of the validated runtime that is to be targeted.
Confirm by clicking "OK".
The new runtime will be associated with that project. If a runtime that you want to select is not displayed or is disabled, you may need to uninstall one or more of the currently installed project facets. This can be done within the same Properties dialogue.
This is what worked for me. I'm just posting my method because it might help somebody else.
Right-click on project
Click on Properties
Go to Project Facets
Uncheck Dynamic Web Module checkbox
Click on Runtimes in the tabs on the right. Apache Tomcat vX.x should be available now
Check Apache Tomcat vX.x
Click Apply and Close
Repeat the previous steps 1-3
Check Dynamic Web Module checkbox
Apache Tomcat vX.x under Runtimes should still be enabled
Click Apply and Close
I know it's already answered question, but I like to share my solution with new users if I can help..
For me the problem was because of the Dynamic wen Project version,
3.0 work with java 1.7 ( I was using 3.1) . If it didn't work you can access .settings folder in your project,
org.eclipse.wst.common.project.facet.core.xml file
and set the version that you need.
<installed facet="jst.web" version="3.0"/>
Hope I can help new users
I have Found a fix for this problem.
Go to Preferences and Check your Targeted runtime, If No Runtime is displayed you can Configure it through Feacts. Select Dinamic Web module to 3.0 or 3.1
You can Also refer to this Video for Detailed Explanation. :
https://youtu.be/0W6s0hXbmNE

Categories

Resources