SpringRoo project cannot be deployed on tomcat

688 views Asked by At

I started to work on a new project using the following environment:

  • Ubuntu 12.04
  • java version "1.6.0_27"
  • Eclipse Java EE IDE for Web Developers. Version: Helios Service Release 1
  • SpringSource Tool Suite Version: 2.9.2.RELEASE
  • tomcat 6 (which I can start, stop from Eclipse IDE)
  • PostgresSql database + pgAdmin III

I followed the expected tutorials:

  • docs.spring.io/spring-roo/reference/html/beginning.html
  • docs.spring.io/spring-roo/reference/html/base-dbre.html

I managed to create my project, and generate all Business Objects using the reverse engineering process. I also managed to create Controllers Objects using the Web MVC process.

The problem I have is that I cannot make my project work on tomcat. I cannot create a server and add my project to it : I right click on the server tab, New => New server => I select tomcat 6 => I check runtime environment: linked to /opt/tomcat6 and using workbench default JRE as expected => I click on Next button: then I cannot see my project into the list. So I cannot add it to the server To try another way, I exported my project into a war file that is located in /opt/tomcat6. When I update the war file, it seems that my application is updated on webapps BUT I think the war file is not correct because here is its content:

-- log.roo
-- pom.xml
-- .settings/
-- src/ And here
-- ++ main/
-- ++ ** java/
-- ++ ** resources/
-- ++ ** webapp/
-- ++ ** -- images/
-- ++ ** -- styles/
-- ++ ** -- WEB-INF/
-- ++ ** -- ++ classes/
-- ++ ** -- ++ i18n/
-- ++ ** -- ++ layouts/
-- ++ ** -- ++ spring/
-- ++ ** -- ++ tags/
-- ++ ** -- ++ views/
-- ++ ** -- ++ web.xml

When I go on my local host:8080/MyProject/, I have a 404 error ... which I think is expected according to the directory content ... ??? ...

Searching from the Web, I red about the Project Facets... I saw a post where someone were told to right click on the project => Configure => Convert to faceted form...

As long there were tree dots at the end of "Convert to faceted form...", I clicked on this menu ... which actually converted the project -_-

I don't know if it is an additional problem or if it's a good thing ... but at present time it doesn't solve my problem.

By the way, I can now select facets for my project ... but which one ??? that is another question ...

One more clue:

I saw I have 100 times the same error when looking at "Problems" tab of Eclipse:

Description Resource Path Location Type
javax.servlet cannot be resolved to a type category.tagx /MyProject/src/main/webapp/WEB-INF/tags/menu line 1 JSP Problem

However, I have the expected following content in my pom.xml:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

In the "Error Log" tab, I also have the following error (which should not be related to my problems ?): Error Project facet grails.app has not been defined. It is used in plugin com.springsource.sts.server.tc.core.

I also have this message (which may certainly be related to my problem ?):

Info build: Abort due to missing classpath/inpath/aspectpath entries
Info /MyProject : Project 'MyProject' is missing required source folder: 'src/test/resources'
Info /MyProject : Project 'MyProject' is missing required source folder: 'src/test/java'

Those folders are existing ... but I'm not using them, so I removed them from the "Sources" tab of the build path management window. It generated a lot of errors in the "Error Log" tab. Here are few examples that may help you to help me:

Error Problems occurred when invoking code from plug-in: "org.eclipse.jdt.core".
java.lang.NullPointerException: type must not be null
at org.eclipse.jst.ws.jaxws.utils.ContractChecker.nul lCheckParam(ContractChecker.java:40)
at org.eclipse.jst.ws.jaxws.utils.internal.annotation s.impl.AnnotationInspectorImpl.<init>(AnnotationIn spectorImpl.java:76)
at org.eclipse.jst.ws.jaxws.utils.annotations.Annotat ionFactory.createAnnotationInspector(AnnotationFac tory.java:350)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.J axWsWorkspaceResource.newAnnotationInspector(JaxWs WorkspaceResource.java:206)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.AbstractModelSynchronizer.processCompilationUn it(AbstractModelSynchronizer.java:115)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.handleAddedCompilatio nUnit(OnEventModelSynchronizer.java:354)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:278)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:302)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:302)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.handleChangedProject( OnEventModelSynchronizer.java:176)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.elementChanged(OnEven tModelSynchronizer.java:86)
at org.eclipse.jdt.internal.core.DeltaProcessor$3.run (DeltaProcessor.java:1557)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner .java:42)
at org.eclipse.jdt.internal.core.DeltaProcessor.notif yListeners(DeltaProcessor.java:1547)
at org.eclipse.jdt.internal.core.DeltaProcessor.fireP ostChangeDelta(DeltaProcessor.java:1381)
at org.eclipse.jdt.internal.core.DeltaProcessor.fire( DeltaProcessor.java:1357)
at org.eclipse.jdt.internal.core.JavaModelOperation.r un(JavaModelOperation.java:769)
at org.eclipse.core.internal.resources.Workspace.run( Workspace.java:1975)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:47 77)
at org.eclipse.jst.jsp.core.internal.validation.JSPBa tchValidator.validate(JSPBatchValidator.java:532)
at org.eclipse.wst.validation.Validator$V2.validate(V alidator.java:1159)
at org.eclipse.wst.validation.internal.ValManager.val idate(ValManager.java:704)
at org.eclipse.wst.validation.internal.ValBuilderJob$ Visitor.visit(ValBuilderJob.java:334)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:68)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:79)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:48)
at org.eclipse.wst.validation.internal.ValBuilderJob. deltaBuild(ValBuilderJob.java:211)
at org.eclipse.wst.validation.internal.ValBuilderJob. run(ValBuilderJob.java:179)
at org.eclipse.wst.validation.internal.ValBuilderJob. runInWorkspace(ValBuilderJob.java:126)
at org.eclipse.core.internal.resources.InternalWorksp aceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.j ava:54)


Error Exception occurred in listener of Java element change notification
java.lang.NullPointerException: type must not be null
at org.eclipse.jst.ws.jaxws.utils.ContractChecker.nul lCheckParam(ContractChecker.java:40)
at org.eclipse.jst.ws.jaxws.utils.internal.annotation s.impl.AnnotationInspectorImpl.<init>(AnnotationIn spectorImpl.java:76)
at org.eclipse.jst.ws.jaxws.utils.annotations.Annotat ionFactory.createAnnotationInspector(AnnotationFac tory.java:350)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.J axWsWorkspaceResource.newAnnotationInspector(JaxWs WorkspaceResource.java:206)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.AbstractModelSynchronizer.processCompilationUn it(AbstractModelSynchronizer.java:115)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.handleAddedCompilatio nUnit(OnEventModelSynchronizer.java:354)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:278)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:302)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.recursevilyHandleComp ilationUnits(OnEventModelSynchronizer.java:302)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.handleChangedProject( OnEventModelSynchronizer.java:176)
at org.eclipse.jst.ws.jaxws.dom.runtime.persistence.s ync.OnEventModelSynchronizer.elementChanged(OnEven tModelSynchronizer.java:86)
at org.eclipse.jdt.internal.core.DeltaProcessor$3.run (DeltaProcessor.java:1557)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner .java:42)
at org.eclipse.jdt.internal.core.DeltaProcessor.notif yListeners(DeltaProcessor.java:1547)
at org.eclipse.jdt.internal.core.DeltaProcessor.fireP ostChangeDelta(DeltaProcessor.java:1381)
at org.eclipse.jdt.internal.core.DeltaProcessor.fire( DeltaProcessor.java:1357)
at org.eclipse.jdt.internal.core.JavaModelOperation.r un(JavaModelOperation.java:769)
at org.eclipse.core.internal.resources.Workspace.run( Workspace.java:1975)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:47 77)
at org.eclipse.jst.jsp.core.internal.validation.JSPBa tchValidator.validate(JSPBatchValidator.java:532)
at org.eclipse.wst.validation.Validator$V2.validate(V alidator.java:1159)
at org.eclipse.wst.validation.internal.ValManager.val idate(ValManager.java:704)
at org.eclipse.wst.validation.internal.ValBuilderJob$ Visitor.visit(ValBuilderJob.java:334)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:68)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:79)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:48)
at org.eclipse.wst.validation.internal.ValBuilderJob. deltaBuild(ValBuilderJob.java:211)
at org.eclipse.wst.validation.internal.ValBuilderJob. run(ValBuilderJob.java:179)
at org.eclipse.wst.validation.internal.ValBuilderJob. runInWorkspace(ValBuilderJob.java:126)
at org.eclipse.core.internal.resources.InternalWorksp aceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.j ava:54)


Error File not found: '/MyProject/src/main/java/__2F_MyProject_2F_src_2F_main_2F_webapp_2F_WEB_2D_ INF_2F_tags_2F_form_2F_fields_2F_select_2E_tagx.ja va'
org.eclipse.core.internal.resources.ResourceExcept ion: Resource '/MyProject/src/main/java/__2F_MyProject_2F_src_2F_main_2F_webapp_2F_WEB_2D_ INF_2F_tags_2F_form_2F_fields_2F_select_2E_tagx.ja va' does not exist.
at org.eclipse.core.internal.resources.Resource.check Exists(Resource.java:326)
at org.eclipse.core.internal.resources.Resource.check Accessible(Resource.java:200)
at org.eclipse.core.internal.resources.File.getConten ts(File.java:291)
at org.eclipse.jdt.internal.core.util.Util.getResourc eContentsAsCharArray(Util.java:1186)
at org.eclipse.jdt.internal.core.CompilationUnit.getC ontents(CompilationUnit.java:649)
(...)
at org.eclipse.core.internal.events.ResourceDelta.acc ept(ResourceDelta.java:48)
at org.eclipse.wst.validation.internal.ValBuilderJob. deltaBuild(ValBuilderJob.java:211)
at org.eclipse.wst.validation.internal.ValBuilderJob. run(ValBuilderJob.java:179)
at org.eclipse.wst.validation.internal.ValBuilderJob. runInWorkspace(ValBuilderJob.java:126)
at org.eclipse.core.internal.resources.InternalWorksp aceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.j ava:54)
  • Now I have the following error in the "Problems" tab:

    Description Resource Path Location Type classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath) MyProject Unknown Java Problem

However, I have the expected content in my pom.xml:

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
2

There are 2 answers

0
eruiz On

It seems an Eclipse problem. Try to create you project from scratch and run using Maven Tomcat plugin: "mvn clean install tomcat:run"

0
Cédric VIDREQUIN On

The final solution:

wiki.eclipse.org/WTP_Tomcat_FAQ#If_I_start_my_Tomcat_server_and_try_to_display_Tomcat.27s_default_page.2C_why_do_I_see_a_directory_listing_or_404_error_page.3F
    then
    wiki.eclipse.org/WTP_Tomcat_FAQ#What_configuration_option_determines_whether_the_Tomcat_server_uses_a_separate_instance_or_the_instance_from_the_Tomcat_installation.3F

In STS, in the "Servers" tab, right click on your server => Open.

In the "Servers location" part, you have some radio buttons:

  • Use workspace metadata (does not modify Tomcat installation)
  • Use Tomcat installation (takes control of Tomcat installation)
  • Use custom location (does not modify Tomcat installation)

The first one was selected in my case, instead of the second one. The server path was leading to my workspace .metada directory (/xxx/.metadata/.plugins/org.eclipse.wst.server.core/tmp0). The Deploy path was "wtpwebapps".

In fact, my project probably works since the beginning ... but I never tried to reach my project page directly... trying to reach the root tomcat page first. That was a mistake...

If you want to make it work, try this :

  • shutdown the server if running
  • remove all project from this server
  • rigth click on it => open
  • in the "Servers location" part, select "Use Tomcat installation (takes control of Tomcat installation)"
  • change the server path value (in my case : "/opt/tomcat6")
  • change the deploy path value (in my case "webapps")
  • add again your projects to the server
  • run it

This works !!!