LoginSignup
5
7

More than 5 years have passed since last update.

EclipseのTomcatプロジェクト名を変更した際は、server.xmlも変更すること

Posted at

EclipseのTomcatプラグインでtomcatが起動できなくなりました。ibatisとspringのjarを追加して、関連するプラグインを入れたりしていたのでそれが原因がかと思いましたがものすごい初歩的なことでした。

下記のエラー文は最初に記述されたものです。実際はいくつもエラーが出ていて縦に長いログになっていました。そのため、Eclipseのコンソールからはみ出ていた下記のエラー文に気が付かなかったです。ログをもっとしっかりと読まないといけないですね。

重大: 静的リソースの起動中のエラーです
java.lang.IllegalArgumentException: ドキュメントベース /Users/user_name/Downloads/apache-tomcat-7.0.54/webapps/TestStrut が存在しない、又は読めないディレクトリです
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:136)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5089)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

EclipseでTomcatプロジェクトを作成した際は、自動でtomcatのserver.xmlを書き換えてくれるのですが、プロジェクトを削除したり、プロジェクト名を変更した場合は自分でserver.xmlを書き換えなければいけないです。

上記の例でいうとTomcatプロジェクト名をTestStrutからTestStrutsと最後にsを付けるだけの変更した場合でもserver.xmlを書き換えます。server.xmlの一番下の方に下記のような記述がありますので、過去のプロジェクト名が書かれているところを現在のに直します。

<!-- server.xml -->
<Context
    path="/TestStrut" reloadable="true"
    docBase="/Users/uesr_name/Downloads/apache-tomcat-7.0.54/webapps/TestStrut"
    workDir="/Users/uesr_name/Downloads/apache-tomcat-7.0.54/webapps/TestStrut/work" />

path,docBase,workDir属性の末尾にプロジェクト名がありますね。今回はここにsを付け足すだけで、tomcatが無事起動するようになりました。

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7