0

私は現在、スタンドアロンのSpringアプリケーションを開発しています(コンテナーではありません)。このアプリケーションは、サーブレットとWebサービスを提供する必要があります。そこで、apachecxfとjettyを選択しました。

なんとか動作させることができましたが、Jettyの2つの別々のインスタンスを実行していました。1つはサーブレット用で、もう1つはcxf用です。だから私の質問は、CXFが使用するJettyサーバーのインスタンスをどのように指定するのですか?

以下は私の設定の抜粋です。

httpサーバーのセットアップ

<bean id="http-server" class="org.eclipse.jetty.server.Server"
    init-method="start" destroy-method="stop">

    <property name="connectors">
        <list>
            <bean class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <property name="port" value="8080" />
            </bean>
        </list>
    </property>
    <property name="handler">
        <bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
            <property name="handlers">
                <list>
                    <ref bean="ServletContainer" />
                    <bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
                </list>
            </property>
        </bean>
    </property>
</bean>

上記はサーブレットに適しています...

CXFのセットアップ

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<jaxws:endpoint id="WebService" implementor="com.MyWebServiceImp"
    address="/ws">
    <jaxws:features>
        <bean class="org.apache.cxf.feature.LoggingFeature" />
    </jaxws:features>
    <jaxws:properties>
        <entry key="faultStackTraceEnabled" value="false" />
        <entry key="exceptionMessageCauseEnabled" value="false" />
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:endpoint>

上記の設定では、システムは起動しますが、Webサービスはjettyサーバーに「公開」されておらず、ログに「異常」なものはありません。

私は、Googleで見つけられる、または見つけることができるすべてのことをほぼ試しました。私はこれに過去数日間を費やしたので、どんな情報や提案も大歓迎です。

ありがとう

4

1 に答える 1

1

これは少し異なる答えです。春から今までと同じようにアプリケーションを作成する必要がありますが、maven を使用してアプリを公開し、ここでアプリをビルドする方法は、pom.xml プラグインの構成です。

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>7.0.2.v20100331</version>
    <configuration>
        <webAppConfig>
            <contextPath>/yourapplication</contextPath>
            <descriptor>
                ${basedir}/src/main/webapp/WEB-INF/jetty/jetty-web.xml
            </descriptor>
        </webAppConfig>
        <scanIntervalSeconds>5</scanIntervalSeconds>
        <stopPort>9966</stopPort>
        <stopKey>foo</stopKey>
        <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>9080</port>
                <maxIdleTime>60000</maxIdleTime>
            </connector>
        </connectors>
    </configuration>
    <executions>
        <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <daemon>true</daemon>
            </configuration>
        </execution>
        <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Web xml はjetty-web.xml上記の pom で指定されています。したがって、cxf Web サービスを jetty サーバーに公開するのは簡単です。すべてが正しくセットアップされていると仮定するとmvn clean install、サービスを jetty に公開するだけです。

于 2012-05-08T10:37:24.853 に答える