0

I'd like to run my Spring application using STS, but I have no idea how to do that. I see the tc server instance, and I can run it, but this does not start my application. I've tried dragging my project workspace onto it, but that hasn't worked either. I've right-clicked and read/checked out all of the options on the context-sensitive menu, but I don't see anything to run my project inside tc server. Does anyone know how?

EDIT:

This is what I get when running the project. I see nothing about my project's war at all. It is included as a "web module" when I check out the tc server settings though. And it does have a web.xml and all of that other good stuff. The project works fine in maven's tomcat goal and inside IDEA. I am just having problems getting it to run in eclipse.

Mar 30, 2012 3:35:51 PM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tc Runtime property decoder using memory-based key
Mar 30, 2012 3:35:51 PM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tcServer Runtime property decoder has been initialized in 206 ms
Mar 30, 2012 3:35:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 30, 2012 3:35:52 PM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init
INFO: Started up JMX registry on 127.0.0.1:6969 in 65 ms
Mar 30, 2012 3:35:52 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 741 ms
Mar 30, 2012 3:35:52 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 30, 2012 3:35:52 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.6.3.RELEASE/7.0.23.A.RELEASE
Mar 30, 2012 3:35:52 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\Users\me\Documents\workspace-sts-2.9.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\trainingdividend.xml
Mar 30, 2012 3:35:52 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:trainingdividend' did not find a matching property.
Mar 30, 2012 3:35:52 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Users\me\Documents\workspace-sts-2.9.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\insight.war
Mar 30, 2012 3:35:52 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
INFO: Context [localhost|insight] will not be woven
Mar 30, 2012 3:35:53 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 30, 2012 3:36:03 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
Mar 30, 2012 3:36:05 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 30, 2012 3:36:05 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 13468 ms
Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
Fire Emblem
  • 5,961
  • 3
  • 24
  • 37
  • 1
    You don't see Run As > Run on Server? – bvulaj Mar 30 '12 at 18:11
  • I didn't see that option before, but I see it now. I had to add the Web Module facet to the project first. Now that I've done that, that option finally shows up. It's strange that the maven eclipse:eclipse goal did not do this for me automatically. Now when I run the server, it still doesn't pick it up though. I get a 404 error :/ I wonder what's wrong. This is a lot easier to do in IDEA :/ – Fire Emblem Mar 30 '12 at 18:48

2 Answers2

2

If you are missing the Run As > Run on Server option, then chances are your project does not have the Dynamic Web Module facet.

digitaljoel
  • 26,265
  • 15
  • 89
  • 115
  • Yes, this is partly right. Thank you. I now have the option, but I think it's still not loading it correctly. I will paste the output of tc server – Fire Emblem Mar 30 '12 at 18:51
  • You could try using the m2e plugin instead of doing mvn eclipse:eclipse and see if it does a better job of creating the project. I'm assuming the packaging specified in your pom is war. – digitaljoel Mar 30 '12 at 19:09
  • Yes, that seems like a sensible thing to do. I first tried to "import" the project - and that didn't work like I expected it to. Then I tried the maven goal, and that worked out for most things. I will try that next since the application isn't running in the server - it just ignores it. I have no idea why. – Fire Emblem Mar 30 '12 at 19:12
  • Also, are you manually entering the URL? If so are you sure you are going to a path that exists in your app? – digitaljoel Mar 30 '12 at 19:13
  • I am both manually entering the URL, and I am also letting eclipse pick it for me. It's not working. I am 100% sure this project works. It works when I run tomcat using a maven goal. It also works in IDEA. I just need to learn eclipse, so I figured I would start using Eclipse on this project to learn it. – Fire Emblem Mar 30 '12 at 19:28
  • more info on your project would be helpful, i.e. what is the URL eclipse is opening, what is the Context Root (see project properties > Web Project Settings) and do they match? What is in the console for tcServer when you launch the server and when you hit the URL? – digitaljoel Mar 30 '12 at 19:33
  • The project url eclipse is trying to go to is `http://localhost:8080/trainingdividend/`. The context root was actually set to `null` (Why didn't maven's eclipse plugin pick that up?!). I changed it to `/trainingdividend`. It still doesn't work. I pasted the console output above. – Fire Emblem Mar 30 '12 at 19:37
  • Actually, the context root keeps reseting to null, even after I apply the changes.... – Fire Emblem Mar 30 '12 at 19:45
  • I think I may have solved it. I'm going to download the exact same java version/update as the tc server. It's complaining about versions in the `Markers` tab, and I didn't notice that before. Maybe that will fix it. – Fire Emblem Mar 30 '12 at 19:55
  • Nope. That got rid of the red X icon, but didn't fix it :/ In the project properties, the "Java" Facet was set to 1.7 even though the maven project specified 1.6. It didn't end up making a difference though. I am shocked that Eclipse can't just get it to work. Why doesn't it auto-detect everything like IDEA? :( – Fire Emblem Mar 30 '12 at 20:05
  • Look at INFO: Deploying web application archive C:\Users\me\Documents\workspace-sts-2.9.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\insight.war and see what's in that war file. Also look at the Deployment Assembly in project properties and make sure Maven Dependencies are in there (along with your other expected source files and any other projects). Finally, have you tried m2e yet or are you still working against eclipse:eclipse generated project? If importing from m2e, make sure to delete .project, .classpath, and .settings first. – digitaljoel Mar 30 '12 at 21:05
  • It turns out that deleting STS, my workspace, and all of my project file and starting over solved the problem. I imported the maven project and it works now. The thing is, I imported the project this exact same way before I tried the eclipse:eclipse goal, and I had major problems... but this time, I am using STS 2.9.1 and not 2.9.0. Could that have been the problem? I hope not, but it could be. Anyway, it works now. Thank you so much for all the help. – Fire Emblem Mar 30 '12 at 21:13
  • Glad you got it working. Not sure on 2.9.0 vs. 2.9.1. I've used both without issue. I have seen a problem in eclipse before (not often) where a project configure gets totally messed up and I have to totally remove it and reimport to get it working though. – digitaljoel Mar 30 '12 at 21:23
0

I was running into 404 errors in my J2ee project, created using Dynamic WebModules. Initially I thought it was a context problem, as the url that STS was attempting to run was quite wrong. However the project the context was correct. But needed to get rid of the errors shown in the markers tab (which may not stop attempts to run as Server) before I made any progress.

After resolving obvious code, jar,path errors, I then check if I can export a war file correctly. If not, it is usually an issue in the DEPLOYMENT ASSEMBLY portion of the projects properties (at least in my Java project). Specifying the class files and jars from required projects is needed to get the correct war file structure. Once accomplished, bye bye 404s

coopr
  • 36
  • 2