2013-10-30 96 views
0

当我通过在jetty/webapps中复制应用程序来部署应用程序时,它部署正常。但我想从外部目录中部署它。对于我已经创建了以下myconf.xml:无法将外部应用程序部署到码头9.0.6.v20130930

<?xml version="1.0"?> 
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> 

<Configure id="myapp" class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Set name="server"> 
     <Ref refid="Server" /> 
    </Set> 
    <Set name="contextPath">/myapp</Set> 
    <Set name="war"> 
     <SystemProperty name="myapp.war" /><!-- points to the external war --> 
    </Set> 
</Configure> 

然后码头是跑了:

的java -XX:-UseSplitVerifier罐子start.jar myconf.xml。

在我看到,部署应用程序,它访问数据库等等,但是当我尝试去实现它我拿到404任何帮助,高度赞赏:)

最好的问候,尤金控制台。

回答

0

这不是你如何使用Jetty。

选项1:标准自动部署

  1. 既然你不定制与部署任何东西,只是删除myconf.xml完全。
  2. 将您的myapp.war复制到${jetty.home}/webapps/目录中。
  3. Start Jetty。 $ java -jar start.jar

这就是被称为Automatic Web Application Deployment

选项2:标准上下文部署

现在,如果你想定制的部署,(例如说你想调整它监听的上下文路径,或者如果你想禁用extractWar过程或有自定义初始化参数,你甚至要更改默认的servlet的行为,等...),然后执行以下操作...

  1. 复制现有myconf.xml${jetty.home}/webapps/myapp.xml(注名更改)
  2. 复制你myapp.war${jetty.home}/webapps/myapp.war(注意,这个文件的基本名称应与您的XML)
  3. 编辑您的${jetty.home}/webapps/myapp.xml改变部署行为(例如:<Set name="contextPath">/app/1</Set>
  4. 开始码头。 $ java -jar start.jar

这就是被称为Configuring Specific WebApp Deployment

方案3:自定义的语境部署

如果你想保持你的战争文件的地方比${jetty.home}/webapps/等,你仍然需要做到以下几点:

  1. 复制现有myconf.xml${jetty.home}/webapps/myconf.xml
  2. 把你的myapp.war留在你想要的地方。例如/opt/webapps/myapp.war
  3. 编辑您的${jetty.home}/webapps/myconf.xml以设置contextPathwar条目。
  4. Start Jetty。 $ java -jar start.jar
<?xml version="1.0"?> 
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" 
    "http://www.eclipse.org/jetty/configure_9_0.dtd"> 

<Configure id="myapp" class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Set name="server"> 
     <Ref refid="Server" /> 
    </Set> 
    <Set name="contextPath">/myapp</Set> 
    <Set name="war"> 
     <SystemProperty name="/opt/webapps/myapp.war" /> 
    </Set> 
</Configure> 

选项4:码头基地自动部署(可在码头9.1+)

还有另一种技术,获得的起始与码头9.1,使用拆分${jetty.home}${jetty.base}概念+的从上面自动部署。假设您已将jetty-distribution-9.1.x解包到/opt/jetty/中,并且您的webapp +配置为/opt/myapps/。您可以执行以下命令。

[user]$ cd /opt/myapps 

[myapps]$ java -jar /opt/jetty/start.jar --add-to-start=server,deploy,websocket,ext,resources 
server   initialised in ${jetty.base}/start.ini (appended) 
server   enabled in  ${jetty.base}/start.ini 
deploy   initialised in ${jetty.base}/start.ini (appended) 
deploy   enabled in  ${jetty.base}/start.ini 
MKDIR: ${jetty.base}/webapps 
server   enabled in  ${jetty.base}/start.ini 
websocket  initialised in ${jetty.base}/start.ini (appended) 
websocket  enabled in  ${jetty.base}/start.ini 
server   enabled in  ${jetty.base}/start.ini 
ext    initialised in ${jetty.base}/start.ini (appended) 
ext    enabled in  ${jetty.base}/start.ini 
MKDIR: ${jetty.base}/lib 
MKDIR: ${jetty.base}/lib/ext 
resources  initialised in ${jetty.base}/start.ini (appended) 
resources  enabled in  ${jetty.base}/start.ini 
MKDIR: ${jetty.base}/resources 

[myapps]$ ls -l 
total 16 
drwxrwxr-x 3 user group 4096 Oct 31 08:32 lib/ 
drwxrwxr-x 2 user group 4096 Oct 31 08:32 resources/ 
-rw-rw-r-- 1 user group 369 Oct 31 08:30 start.ini 
drwxrwxr-x 2 user group 4096 Oct 31 08:30 webapps/ 

[myapps]$ cat start.ini 
--module=server 
threads.min=10 
threads.max=200 
threads.timeout=60000 
jetty.dump.start=false 
jetty.dump.stop=false 

--module=deploy 
--module=websocket 
--module=ext 
--module=resources 

[myapps]$ java -jar /opt/jetty/start.jar --list-config | grep -E "jetty.(base|home)=" 
jetty.home=/opt/jetty 
jetty.base=/opt/myapps 

[myapps]$ cp /home/user/project/myapp/target/myapp-1.0.war /opt/myapps/webapps/myapp.war 

[myapps]$ java -jar /opt/jetty/start.jar 
2013-10-31 08:35:58.919:INFO:oejs.Server:main: jetty-9.1.0.RC0 
2013-10-31 08:35:58.939:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/opt/myapps/webapps/] at interval 1 
2013-10-31 08:35:59.109:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /myapp, did not find org.apache.jasper.servlet.JspServlet 
2013-10-31 08:35:59.189:INFO:oejsh.ContextHandler:main: Started [email protected]{/myapp,file:/tmp/jetty-myapp.war-_myapp-any-/webapp/,AVAILABLE}{/myapp.war} 

你会发现的是,你有2个位置可以使用。

  • ${jetty.home} - 在您的码头分布位于
  • ${jetty.base} - 在您的应用程序的具体配置和战争都位于

这是一个非常强大的选项,我只碰了面的能力。

+0

你确定我无法避免将战争复制到$ {jetty.home}/webapps /?那么WebAppContext的战争属性的目的是什么?并且您提供的链接(配置特定WebApp部署)意味着外部战争位置(/opt/myapp/myapp.war) – user656449

+0

更新您的额外问题的答案。 –

相关问题