3

我有一个正在运行的 Mule 应用程序,我想在其上设置 Jetty 以响应 http 请求。以下配置:

<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>

...当我启动应用程序时工作,并将选择的浏览器指向http://localhost:8080 - 根据 test:component,显示的所有内容都是“已接收”。

我想要做的是更新这个,而不是看到“收到”,我想去我定义 index.html 文件的地方。我的假设是我必须将 test:component 更改为出站端点 - 这是正确的吗?我将在哪里指定路径(相对或绝对)?

4

2 回答 2

1

我必须添加一个 jetty:connector 实例:

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

这是 jettyConfig.xml 的内容,因为简单示例有错误:

<?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>
于 2009-09-16T20:34:10.760 回答
1

这对我不起作用。

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

I think, what happens is that one instance is being created on port defined in jettyConfig and then another through Mule. Changing the port in jettyConfig yields two identically behaving instances on two different ports.

The simplest solution is to remove the addConnector Call from jettyConfig.xml and let Mule assign the port.

It is also not needed to specify host and port on the endpoint. This suffices:

<jetty:endpoint address="http://localhost:8080" name="serverEndpoint" path="services/Foo" synchronous="false" />
于 2010-04-22T22:07:21.597 回答