Deploy Struts2 WebApp Within An Eclipse RCP Application Via Jetty

时间:2015-09-01 21:15:47

标签: java web-applications struts2 jetty eclipse-rcp

Now here's a mess for you...

I am currently working on an Eclipse RCP application plugin. The goal of this plugin is to serve up a webapp for users to interact with within an Eclipse ViewPart (SWT browser control).

I would like for this webapp to be powered by Struts2 and I already have Jetty at my disposal for serving things up.

Is there any way at all I can deploy a Struts2 WebApp in this way? If more info is needed please ask!

EDIT #1:

Some more detail. The only way I know how to deploy a struts2 application currently is via a war file (hosting on tomcat, that is). This is not something I can do in this case. I need to somehow deploy struts2 internally in an embedded way using the Jetty server provided with the Eclipse RCP framework.

RESULT:

As it turns out you can deploy a WAR file (struts2 app in this case) with embedded Jetty. I found Joakim Erdfelt doing it here: Embedding Jetty as a Servlet Container

1 个答案:

答案 0 :(得分:1)

Struts2 Web应用程序可以像Jetty一样在servlet容器中运行。 Jetty还有一个嵌入式选项。 Eclipse RCP使用Eclipse平台通过插件进行扩展和定制。有一篇文章using Eclipse RCP with embedded Jetty server

  

首先,让我们将jetty插件添加到我们的依赖项中。打开选项卡   插件配置中的依赖关系。然后添加这六个   插件到必需的插件

javax.servlet
org.eclipse.equinox.http.jetty
org.eclipse.equinox.http.regstry
org.eclipse.equinox.http.servlet
org.mortbay.jetty.server
org.mortbay.jetty.util
     

在您需要的应​​用程序启动时包含的插件列表中   将三个插件的自动启动值更改为true(如果是的话)   懒惰,您可以将默认行为转为自动启动,但这是   另一个问题):

org.eclipse.equinox.http.jetty
org.eclipse.equinox.http.regstry
org.eclipse.equinox.http.servlet
     

现在,如果您运行该应用程序,则可以检查您的服务器是否正常运行   通过访问http://localhost正确运行。这应该工作   完美无缺,除非您不允许在端口运行服务器   80或者已经有一个服务器在端口80中运行。

     

您可以通过在VM参数中添加参数来更改端口   运行配置。添加此值:   -Dorg.eclipse.equinox.http.jetty.http.port=8888。将8888更改为   你希望服务器运行的任何端口。

     

现在,如果您正在运行该应用程序,则可以从中访问它   你之前提到过的港口。

     

下一个任务是定义将服务的一个(或几个)servlet   服务器得到的任何请求。要做到这一点,你需要打开   插件配置中的 Extensions 标签,并添加新的   名为org.eclipse.equinox.http.registry.servlets的扩展程序。后   添加新的servlet。你需要提到的类名   servlet,以及它的别名。这里需要注意的是你需要添加斜杠   别名前面。例如,如果要创建servlet   可以从http://localhost:8888/webserviceInterface访问,然后是。{   别名值为/webserviceInterface。当然,你需要   实现一个servlet,它将完成你想要的工作。