2

数日前まで正常に実行されていたサーブレットがあります。しかし、私が変更したのは、Mavenに使用しているネクサスリポジトリだけです。mvn jetty:runを介してサーブレットを実行しています

しかし、ホームページを表示する代わりにサイトにアクセスしようとすると、次のように表示されます。

HTTP ERROR 500

Problem accessing /. Reason:

    jregex/Pattern

/favicon.icoなどの他のURLにアクセスできます。しかし、このjregex / Patternエラーについては何も見つかりません。また、コードでjregexライブラリが使用されているようには見えません。

ログにも問題はありません。ホームページへのリクエストは私のサーブレットに届いていないようですが、他のページへのリクエストは届いています。

これは、ArchLinuxとMacOSX10.7の両方で発生しています。

~/.m2私のフォルダを古いもの(古いnexusサーバーからの依存関係を持つ)に置き換えた後、それは機能するので、これはほぼ確実に依存関係の問題です。

時々私も得る:

HTTP ERROR: 503

Problem accessing /. Reason:

    SERVICE_UNAVAILABLE
4

4 に答える 4

2

ここのジェイソンは私のために働くものです、これは私が非常に頻繁に使用するものです、pom.xml(関連部分):

<dependencies>
        <!-- Jetty dependencies -->
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-embedded</artifactId>
            <version>6.1.26</version>
        </dependency>
    </dependencies>

    <build>
    <plugins>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>7.0.2.v20100331</version>
            <configuration>
                <webAppConfig>
                    <contextPath>/jetty-example</contextPath>
                    <descriptor>${basedir}/src/main/webapp/WEB-INF/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>
        </plugin>
    </plugins>
    </build>

これは、webappconfigで記述子として上記で指定された場所にあるweb.xmlです。

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>HelloWorld Application</display-name>
    <description>
       lalala
    </description>

    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>com.mypackage.jetty.Hello</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>

</web-app>

そしてサーブレット自体:

public final class Hello extends HttpServlet {

    private static final long serialVersionUID = 903359962771189189L;

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
      throws IOException, ServletException {

        response.setContentType("text/html");
        PrintWriter writer = response.getWriter();        
        writer.println("<html>");
        writer.println("<head>");
        writer.println("<title>Sample Application Servlet Page</title>");
        writer.println("</head>");
        writer.println("<body bgcolor=white>");

        writer.println("<table border=\"0\" cellpadding=\"10\">");
        writer.println("<tr>");
        writer.println("<td>");
        writer.println("</td>");
        writer.println("<td>");
        writer.println("<h1>W00w I totally work</h1>");
        writer.println("</td>");
        writer.println("</tr>");
        writer.println("</table>");

        writer.println("</body>");
        writer.println("</html>");
    }
} 

サーバーを実行して実行し、次のmvn jetty:run場所で確認できます。http://localhost:9080/jetty-example/hello

さらに、プラグイン部分に実行を追加し、プロジェクトの構築が完了したときに桟橋を開始できます。mvn jetty:run毎回手動で行う必要はありません。

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

さらに、データベース(さまざまな環境用)に使用するjetty構成ファイルを追加できます。webAppConfig次のように、jettyプラグインのにファイルの場所を追加します。

<webAppConfig>
      <contextPath>/my-tool</contextPath>
      <descriptor>${basedir}/src/main/webapp/WEB-INF/jetty/web.xml                          </descriptor>
      <jettyEnvXml>${basedir}/src/main/webapp/WEB-INF/jetty/jetty-env.xml                           </jettyEnvXml>
</webAppConfig>

そして、jetty-env.xmlのサンプルコンテンツ:

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"[]>
<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
      <!-- PRIMARY DATABASE     -->
      <New id="devDS" class="org.eclipse.jetty.plus.jndi.Resource">
            <Arg>primaryDS</Arg>
            <Arg>
                  <!-- i.e. Postgress   -->
                  <New class="org.postgresql.ds.PGSimpleDataSource">
                        <Set name="User">myuser</Set>
                        <Set name="Password">password</Set>
                        <Set name="DatabaseName">database</Set>
                        <Set name="ServerName">database.stackoverflow.com</Set>
                        <Set name="PortNumber">5432</Set>
                  </New>
            </Arg>
      </New>
      <!-- BACKUP DATABASE      
      <New id="devDS" class="org.eclipse.jetty.plus.jndi.Resource">         
      <Arg>backupDS</Arg>       
      <Arg>             
            .....       
      </Arg>    
        -->
</Configure>

あなたはこれでうまくいくはずです。

于 2012-05-15T22:08:53.893 に答える
1

まず、を変更する前後に作成されたear/ファイルを比較します。これにより、変更されたjarファイルが表示されます。すべてがオープンソースであると仮定して、Mavenリポジトリからソースをダウンロードして比較します。\warpom.xml

編集:JRegexは、Perl正規表現をサポートするJavaライブラリです。おそらく、Mavenリポジトリを変更すると、他のバージョンの依存関係がダウンロードされ、JRegexへのオプションの依存関係がいくつかあります。(あなたはそれをチェックすることができるはずです)。

依存関係にJRegexを追加して、何が起こるかを確認してください。(本番環境で急いでいる場合は、これが回避策になることに注意してください)

于 2012-05-17T10:35:58.847 に答える
0

実行しているmvnコマンドは何ですか?アーティファクトを手動でダウンロードして、ローカルアーティファクトでmvnを実行してみましたか?

最初にmvnを使用してアーティファクトをダウンロードします。これにより、すべての設定/許可設定が機能し、適切であることが検証されます。これを行うには、 Maven Dependency Plugin(v2.4)を使用して、依存関係をローカルファイルにダウンロードできます。詳細については、この投稿を参照してください

アーティファクトをローカルにダウンロードできることを確認したら、ローカルアーティファクトでjetty:runを実行してみてください。それが機能する場合は、リポジトリに問題があることがわかります。

それでも機能しない場合は、ミラー設定またはリポジトリ構成に問題がある可能性があります。たとえば、mvnにローカルにないプラグインまたは依存関係が必要な場合、mvnはサードパーティのリポジトリを参照します。settings.xmlファイルは、MvnCentralからダウンロードするように構成されていない可能性のあるローカルnexusサーバーにそれらすべてをミラーリングする場合があります。

依存関係/プラグインのダウンロードの問題も発生していないことを確認してください。settings.xmlからmvncentralを簡単にポイントして、nexusサーバーを完全にバイパスできます。

于 2012-05-15T20:09:34.870 に答える
0

FWIW、BeyondCompare(Scooter Software)などのツールでファイル比較をしていただけませんか

于 2012-05-18T14:34:41.933 に答える