2009-09-15 63 views
3

我有一个工作骡应用程序,我想设置Jetty来响应http请求。以下配置:当我启动应用程序,以及所选择的点浏览器http://localhost:8080Mule/Jetty设置

<jetty:endpoint address="http://localhost:8080" 
       name="jettyEndpoint" 
       host="localhost" 
       port="8080" path="/" 
       synchronous="true" /> 

<service name="jettyUMO"> 
    <inbound> 
    <jetty:inbound-endpoint ref="jettyEndpoint" /> 
    </inbound> 
    <test:component appendString="Received" /> 
</service> 

...作品 - 这被显示为“已接收”,每次测试都:组件。

我想要做的就是更新它,以便不要看到“收到”,而是要去我定义index.html文件的位置。我的假设是,我必须更改测试:组件出站端点 - 是否正确?我在哪里指定路径(相对或绝对)?

回答

1

我不得不添加一个码头:连接器实例:

<jetty:connector name="httpConnector" 
       configFile="conf/jettyConfig.xml" 
       useContinuations="true" /> 

这里的jettyConfig.xml的内容,因为simple example有错误:

<?xml version="1.0"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> 

<Configure id="Server" class="org.mortbay.jetty.Server"> 
    <Call name="addConnector"> 
    <Arg> 
     <New class="org.mortbay.jetty.nio.SelectChannelConnector"> 
     <Set name="port">8080</Set> 
     </New> 
    </Arg> 
    </Call> 

    <Set name="handler"> 
    <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection"> 
     <Set name="handlers"> 
     <Array type="org.mortbay.jetty.Handler"> 
      <Item> 
      <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/> 
      </Item> 
      <Item> 
      <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/> 
      </Item> 
     </Array> 
     </Set> 
    </New> 
    </Set> 

    <Call name="addLifeCycle"> 
    <Arg> 
     <New class="org.mortbay.jetty.deployer.WebAppDeployer"> 
     <Set name="contexts"><Ref id="Contexts"/></Set> 
     <Set name="webAppDir">path/webapps</Set> 
     </New> 
    </Arg> 
    </Call> 
</Configure> 
1

这并没有为我工作。

> [04-22 17:25:22] WARN log [main]: 
> failed [email protected]:8080 
> java.net.BindException: Address already in use 
>   at sun.nio.ch.Net.bind(Native Method) 

我想,会发生什么是在jettyConfig中定义的端口上创建一个实例,然后通过Mule创建另一个实例。在jettyConfig中更改端口会在两个不同的端口上产生两个相同的行为实例。

最简单的解决方案是从jettyConfig.xml中删除addConnector Call,并让Mule分配端口。

也不需要指定端点上的主机和端口。这就足够了:

<jetty:endpoint address="http://localhost:8080" name="serverEndpoint" path="services/Foo" synchronous="false" />