spring tool suiteからmevenプロジェクトを実行したら反応がなかった
事象
STSからインポート>既存mavenプロジェクトでインポートしたプロジェクトを実行したら、コンソール上は何も処理の表示がされずに404ページが返ってきた
エラー内容
コンソール上の表示
8 25, 2017 9:08:34 午後 org.apache.catalina.startup.Catalina load 情報: Initialization processed in 665 ms 8 25, 2017 9:08:39 午後 org.apache.catalina.startup.Catalina start 情報: Server startup in 4330 ms
これだけしかコンソール上に表示されないので、適当にググってみても欲しい情報が得られず頭を悩ませていたところ、思い出した。
サーバーのログがあるじゃん!!
ということで更新日付を頼りに行きついたのがここ
~\develop\sts-bundle\pivotal-tc-server-developer-3.2.6.RELEASE\base-instance\logs\catalina.2017-08-25.log
ログをたどってみると以下の内容が出てた。
25-Aug-2017 20:42:14.720 警告 [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:todo' did not find a matching property. 25-Aug-2017 20:42:14.742 重大 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/todo]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@65963f1b] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4860) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4992) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@6a3833bf] at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:709) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 13 more Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) ... 16 more Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(Unknown Source) at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(Unknown Source) at java.util.zip.InflaterInputStream.read(Unknown Source) at sun.misc.IOUtils.readFully(Unknown Source) at java.util.jar.JarFile.getBytes(Unknown Source) at java.util.jar.JarFile.getManifestFromReference(Unknown Source) at java.util.jar.JarFile.getManifest(Unknown Source) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111) ... 17 more 25-Aug-2017 20:42:14.742 重大 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor 設定記述子 [E:\develop\sts-bundle\pivotal-tc-server-developer-3.2.6.RELEASE\base-instance\conf\Catalina\localhost\todo.xml] を配備中のエラーです java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/todo]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
エラーが出てた!とりあえず嬉しい。
原因
Javaのエラーは積み上げ式に最後に発生したエラー順に表示されるので、見るべき根元のエラーはここ。
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(Unknown Source) at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(Unknown Source) at java.util.zip.InflaterInputStream.read(Unknown Source) at sun.misc.IOUtils.readFully(Unknown Source) at java.util.jar.JarFile.getBytes(Unknown Source) at java.util.jar.JarFile.getManifestFromReference(Unknown Source) at java.util.jar.JarFile.getManifest(Unknown Source) at
ZipException?なんだそりゃ?とりあえずググる。
すると、jarファイルのバージョンがおかしくなっているらしい?
解決策
repositoryディレクトリを一度削除して、もう一度mavenから持ってこさせるといいらしい。
場所
C:\Users\[ユーザー名]\.m2\repository
で、STSを再起動。
プロジェクト右クリック>maven>プロジェクトの更新
プロジェクトを実行してみる。
コンソール上には以下の処理が・・・!
8 25, 2017 9:08:34 午後 org.apache.catalina.startup.Catalina load 情報: Initialization processed in 665 ms date:2017-08-25 21:08:37 thread:localhost-startStop-1 X-Track: level:INFO logger:o.springframework.web.servlet.DispatcherServlet message:FrameworkServlet 'appServlet': initialization started date:2017-08-25 21:08:38 thread:localhost-startStop-1 X-Track: level:INFO logger:o.s.w.s.m.m.a.RequestMappingHandlerMapping message:Mapped "{[/],methods=[GET || POST]}" onto public java.lang.String todo.app.welcome.HelloController.home(java.util.Locale,org.springframework.ui.Model) date:2017-08-25 21:08:38 thread:localhost-startStop-1 X-Track: level:INFO logger:o.s.w.s.m.m.a.RequestMappingHandlerAdapter message:Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Aug 25 21:08:37 JST 2017]; parent: Root WebApplicationContext date:2017-08-25 21:08:38 thread:localhost-startStop-1 X-Track: level:INFO logger:o.s.w.s.m.m.a.RequestMappingHandlerAdapter message:Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Aug 25 21:08:37 JST 2017]; parent: Root WebApplicationContext date:2017-08-25 21:08:38 thread:localhost-startStop-1 X-Track: level:INFO logger:o.s.web.servlet.handler.SimpleUrlHandlerMapping message:Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0' date:2017-08-25 21:08:38 thread:localhost-startStop-1 X-Track: level:INFO logger:o.s.web.servlet.handler.SimpleUrlHandlerMapping message:Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0' date:2017-08-25 21:08:39 thread:localhost-startStop-1 X-Track: level:INFO logger:o.springframework.web.servlet.DispatcherServlet message:FrameworkServlet 'appServlet': initialization completed in 1217 ms 8 25, 2017 9:08:39 午後 org.apache.catalina.startup.Catalina start 情報: Server startup in 4330 ms date:2017-08-25 21:08:41 thread:tomcat-http--3 X-Track:cc9a264402a14c5699de856f76767f09 level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[START CONTROLLER] HelloController.home(Locale,Model) date:2017-08-25 21:08:41 thread:tomcat-http--3 X-Track:cc9a264402a14c5699de856f76767f09 level:INFO logger:todo.app.welcome.HelloController message:Welcome home! The client locale is ja_JP. date:2017-08-25 21:08:41 thread:tomcat-http--3 X-Track:cc9a264402a14c5699de856f76767f09 level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[END CONTROLLER ] HelloController.home(Locale,Model)-> view=welcome/home, model={serverTime=2017/08/25 21:08:41 JST} date:2017-08-25 21:08:41 thread:tomcat-http--3 X-Track:cc9a264402a14c5699de856f76767f09 level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[HANDLING TIME ] HelloController.home(Locale,Model)-> 35,577,062 ns date:2017-08-25 21:20:56 thread:tomcat-http--11 X-Track:22cfa0d25e754da7ae431367ff64877c level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[START CONTROLLER] HelloController.home(Locale,Model) date:2017-08-25 21:20:56 thread:tomcat-http--11 X-Track:22cfa0d25e754da7ae431367ff64877c level:INFO logger:todo.app.welcome.HelloController message:Welcome home! The client locale is ja_JP. date:2017-08-25 21:20:56 thread:tomcat-http--11 X-Track:22cfa0d25e754da7ae431367ff64877c level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[END CONTROLLER ] HelloController.home(Locale,Model)-> view=welcome/home, model={serverTime=2017/08/25 21:20:56 JST} date:2017-08-25 21:20:56 thread:tomcat-http--11 X-Track:22cfa0d25e754da7ae431367ff64877c level:TRACE logger:o.t.gfw.web.logging.TraceLoggingInterceptor message:[HANDLING TIME ] HelloController.home(Locale,Model)-> 690,688 ns
無事起動。めでたしめでたし。
springのweb開発を触りだしてから一番最初にくらったトラブルだったんだけど、対処の仕方を見事に忘れてた・・・