1

I have 2 Dynamic Web Projects:

  • cms
  • Demo

Using Struts2 I want project Demo to use actions of the project CMS.

In Demo's "Java Build Path" configuration, in the "Project" tab I added the CMS project.

enter image description here

Now in the struts.xml of Demo I have

<action name="hello" class="cms.helloworld.action.HelloWorldAction" method="execute">

where the package cms.helloworld.action is a CMS project package.

enter image description here

Eclipse see it correctly, in fact with ctrl+right click on the class name it open me the correct Java file.

Now, in Demo's deployment assembly configuration I added the CMS project, so that also Tomcat can find the relative classes.

enter image description here

But when I run the project on tomcat server the log says:

Grave: Dispatcher initialization failed Unable to load configuration. - action

Caused by: Action class [cms.helloworld.action.HelloWorldAction] not found

It can't find the action on CMS project.

What am I doing wrong?

4

1 回答 1

1

您应该将两个项目合并为一个,并struts.xml放入src. 据我所知,Eclipse 无法将另一个 Web 项目作为模块引用,即您必须WebContent在构建期间手动复制,这就是为什么您不应该引用其他 Web 项目并且主项目不是 Java EE 项目的原因。如果您决定开发一个,您还应该考虑到 Tomcat 服务器无法处理 Java EE 项目,为此您应该选择功能齐全的 Java EE 应用程序服务器。即使您只能选择一个 Web 模块。

于 2013-08-07T07:50:40.080 回答