文系プログラマによるTIPSブログ

文系プログラマ脳の私が開発現場で学んだ事やプログラミングのTIPSをまとめています。

Jetty WTP Pluginでeclipseでjetty8.1を動かす!

色々エラー出ちゃうんですよね〜


f:id:treeapps:20180426142529p:plain

javaのサーブレットコンテナといえばtomcatですが、
jettyという軽量でプラガブルなサーブレットコンテナが存在します。
Jetty - Servlet Engine and Http Server

jettyの利用実績

http://docs.codehaus.org/display/JETTY/Jetty+Powered
有名所ではgoogle app engineです。
solrにもjettyが内蔵されています。

eclipseでjettyを起動する

eclipseでtomcatを起動する場合、serversビューからWTPを起動します。
jettyの場合はeclipseのpluginをインストールする必要があります。

jetty wtp pluginをインストール

More bleeding edge versions of the plugin (each successful build on Hudson): http://download.eclipse.org/jetty/updates/jetty-wtp/development

http://wiki.eclipse.org/Jetty_WTP_Plugin/Jetty_WTP_Install

serversビューでserverを新規作成

f:id:treeapps:20130404235843p:plain
v8.1でserverを作成しようとしても、何故かtextboxにフォーカスが合わず、nextボタンが押せません。
代わりにv8.0 Serverを選択し、8.1を動かす事ができます。
では作成したserverを起動してみます。

2013-04-05 00:01:52.353:INFO:oejs.Server:jetty-8.1.10.v20130312
2013-04-05 00:01:52.369:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/webapps at interval 1
2013-04-05 00:01:52.373:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts at interval 1
2013-04-05 00:01:52.375:INFO:oejd.DeploymentManager:Deployable added: /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts/treefigure-web-front.xml
2013-04-05 00:01:53.158:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.w.WebAppContext{/treefigure-web-front,file:/Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/treefigure-web-front/},/Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/treefigure-web-front: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
    at org.eclipse.jetty.annotations.AnnotationConfiguration.createAnnotationParser(AnnotationConfiguration.java:154)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:105)
    at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:468)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1247)
・・・略・・・


ClassVisitorとやらがクラスパスに無いそうです。

不足jarをクラスパスに追加

jarが不足しているので、クラスパスに追加します。
serversをダブルクリックすると設定ウインドウが開きます。
f:id:treeapps:20130405000934p:plain
Add External Jarsで不足しているjarを追加します。
f:id:treeapps:20130405001314p:plain

追加するjarは以下にあり、jetty/lib以下にあります。

tree-macpro:etc tree$ cd /usr/local/jetty-distribution-8.1.10.v20130312/lib/annotations/
tree-macpro:annotations tree$ ll
total 496
-rw-rw-r--@ 1 tree  staff    26K  3 12 11:13 javax.annotation-1.1.0.v201108011116.jar ← これ
-rw-rw-r--@ 1 tree  staff   216K  3 12 11:13 org.objectweb.asm-3.1.0.v200803061910.jar

では再び起動してみます。

2013-04-05 00:16:25.953:INFO:oejs.Server:jetty-8.1.10.v20130312
2013-04-05 00:16:25.968:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/webapps at interval 1
2013-04-05 00:16:25.972:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts at interval 1
2013-04-05 00:16:25.974:INFO:oejd.DeploymentManager:Deployable added: /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts/treefigure-web-front.xml
DEBUG 2013-04-05 00:16:29,394 [main]   ContextRealPath=/Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/treefigure-web-front
  SERVER_SOFTWARE=jetty/8.1.10.v20130312, ServletContextName=/treefigure-web-front, MajorVersion=3, MinorVersion=0
2013-04-05 00:16:29.400:WARN:oejuc.AbstractLifeCycle:FAILED jsp: java.lang.NoClassDefFoundError: javax/annotation/security/RunAs
java.lang.NoClassDefFoundError: javax/annotation/security/RunAs
    at org.eclipse.jetty.annotations.RunAsAnnotationHandler.doHandle(RunAsAnnotationHandler.java:55)
    at org.eclipse.jetty.annotations.AnnotationIntrospector$AbstractIntrospectableAnnotationHandler.handle(AnnotationIntrospector.java:71)
    at org.eclipse.jetty.annotations.AnnotationIntrospector.introspect(AnnotationIntrospector.java:96)
・・・略・・・

またエラーです。今度はRunAsとやらがクラスパスに無いそうです。
先ほど追加したjarと同じ場所にjavax.annotation.vXXX.jarがあるので、これも先ほどと同手順で追加します。

tree-macpro:annotations tree$ ll
total 496
-rw-rw-r--@ 1 tree  staff    26K  3 12 11:13 javax.annotation-1.1.0.v201108011116.jar
-rw-rw-r--@ 1 tree  staff   216K  3 12 11:13 org.objectweb.asm-3.1.0.v200803061910.jar ← これ

再度起動します。今度こそ・・・

2013-04-05 00:19:14.208:INFO:oejs.Server:jetty-8.1.10.v20130312
2013-04-05 00:19:14.230:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/webapps at interval 1
2013-04-05 00:19:14.233:INFO:oejdp.ScanningAppProvider:Deployment monitor /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts at interval 1
2013-04-05 00:19:14.235:INFO:oejd.DeploymentManager:Deployable added: /Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/contexts/treefigure-web-front.xml
DEBUG 2013-04-05 00:19:17,639 [main]   ContextRealPath=/Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/treefigure-web-front
  SERVER_SOFTWARE=jetty/8.1.10.v20130312, ServletContextName=/treefigure-web-front, MajorVersion=3, MinorVersion=0
INFO  2013-04-05 00:19:17,965 [main] Loading validation rules file from '/WEB-INF/validator-rules.xml'
INFO  2013-04-05 00:19:18,034 [main] s2-frameworkのバージョンは2.4.45です。
INFO  2013-04-05 00:19:18,035 [main] s2-extensionのバージョンは2.4.45です。
INFO  2013-04-05 00:19:18,035 [main] s2-tigerのバージョンは2.4.45です。
DEBUG 2013-04-05 00:19:18,071 [main] 環境変数#Envにファイル(env.txt)から値(ct)が設定されました
DEBUG 2013-04-05 00:19:18,114 [main] S2Containerを作成します。path=hotdeploy.dicon
DEBUG 2013-04-05 00:19:18,118 [main] S2Containerを作成します。path=convention.dicon
DEBUG 2013-04-05 00:19:18,183 [main] S2Containerを作成しました。path=convention.dicon
DEBUG 2013-04-05 00:19:18,183 [main] S2Containerを作成します。path=customizer.dicon
DEBUG 2013-04-05 00:19:18,187 [main] S2Containerを作成します。path=default-customizer.dicon
DEBUG 2013-04-05 00:19:18,190 [main] S2Containerを作成します。path=std-customizer.dicon
DEBUG 2013-04-05 00:19:18,196 [main] S2Containerを作成します。path=std-customizer-tiger.dicon
DEBUG 2013-04-05 00:19:18,209 [main] S2Containerを作成しました。path=std-customizer-tiger.dicon
DEBUG 2013-04-05 00:19:18,236 [main] S2Containerを作成しました。path=std-customizer.dicon
DEBUG 2013-04-05 00:19:18,243 [main] S2Containerを作成しました。path=default-customizer.dicon
DEBUG 2013-04-05 00:19:18,252 [main] S2Containerを作成しました。path=customizer.dicon
DEBUG 2013-04-05 00:19:18,252 [main] S2Containerを作成します。path=creator.dicon
DEBUG 2013-04-05 00:19:18,278 [main] S2Containerを作成しました。path=creator.dicon
DEBUG 2013-04-05 00:19:18,280 [main] S2Containerを作成しました。path=hotdeploy.dicon
DEBUG 2013-04-05 00:19:18,298 [main] S2Containerを作成します。path=app.dicon
DEBUG 2013-04-05 00:19:18,302 [main] S2Containerを作成します。path=convention.dicon
DEBUG 2013-04-05 00:19:18,307 [main] S2Containerを作成しました。path=convention.dicon
DEBUG 2013-04-05 00:19:18,307 [main] S2Containerを作成します。path=aop.dicon
DEBUG 2013-04-05 00:19:18,326 [main] S2Containerを作成しました。path=aop.dicon
DEBUG 2013-04-05 00:19:18,326 [main] S2Containerを作成します。path=j2ee.dicon
DEBUG 2013-04-05 00:19:18,329 [main] S2Containerを作成します。path=jta.dicon
DEBUG 2013-04-05 00:19:18,343 [main] S2Containerを作成しました。path=jta.dicon
DEBUG 2013-04-05 00:19:18,343 [main] S2Containerを作成します。path=jdbc.dicon
DEBUG 2013-04-05 00:19:18,360 [main] S2Containerを作成しました。path=jdbc.dicon
DEBUG 2013-04-05 00:19:18,365 [main] S2Containerを作成しました。path=j2ee.dicon
DEBUG 2013-04-05 00:19:18,365 [main] S2Containerを作成します。path=s2jdbc.dicon
DEBUG 2013-04-05 00:19:18,368 [main] S2Containerを作成します。path=s2jdbc-internal.dicon
DEBUG 2013-04-05 00:19:18,377 [main] S2Containerを作成しました。path=s2jdbc-internal.dicon
DEBUG 2013-04-05 00:19:18,405 [main] S2Containerを作成しました。path=s2jdbc.dicon
DEBUG 2013-04-05 00:19:18,406 [main] S2Containerを作成しました。path=app.dicon
INFO  2013-04-05 00:19:18,494 [main] Running on [ENV]ct, [DEPLOY MODE]Hot Deploy
INFO  2013-04-05 00:19:18,498 [main] init start
INFO  2013-04-05 00:19:18,500 [main] prepareLibraries start
INFO  2013-04-05 00:19:18,512 [main] marshall factory: /org.seasar.mayaa.provider.ProviderFactory
INFO  2013-04-05 00:19:18,810 [main] loaded library - /META-INF/fmt-1_0.tld - http://java.sun.com/jstl/fmt
INFO  2013-04-05 00:19:18,949 [main] loaded library - /META-INF/fmt.tld - http://java.sun.com/jsp/jstl/fmt
INFO  2013-04-05 00:19:19,015 [main] loaded library - /META-INF/fn.tld - http://java.sun.com/jsp/jstl/functions
INFO  2013-04-05 00:19:19,068 [main] loaded library - /META-INF/sql.tld - http://java.sun.com/jsp/jstl/sql
INFO  2013-04-05 00:19:19,105 [main] loaded library - /META-INF/permittedTaglibs.tld - http://jakarta.apache.org/taglibs/standard/permittedTaglibs
INFO  2013-04-05 00:19:19,116 [main] loaded library - /META-INF/fmt-1_0-rt.tld - http://java.sun.com/jstl/fmt_rt
INFO  2013-04-05 00:19:19,125 [main] loaded library - /META-INF/sql-1_0.tld - http://java.sun.com/jstl/sql
INFO  2013-04-05 00:19:19,183 [main] loaded library - /META-INF/c.tld - http://java.sun.com/jsp/jstl/core
INFO  2013-04-05 00:19:19,205 [main] loaded library - /META-INF/x-1_0-rt.tld - http://java.sun.com/jstl/xml_rt
INFO  2013-04-05 00:19:19,214 [main] loaded library - /META-INF/x-1_0.tld - http://java.sun.com/jstl/xml
INFO  2013-04-05 00:19:19,227 [main] loaded library - /META-INF/c-1_0.tld - http://java.sun.com/jstl/core
INFO  2013-04-05 00:19:19,235 [main] loaded library - /META-INF/sql-1_0-rt.tld - http://java.sun.com/jstl/sql_rt
INFO  2013-04-05 00:19:19,267 [main] loaded library - /META-INF/scriptfree.tld - http://jakarta.apache.org/taglibs/standard/scriptfree
INFO  2013-04-05 00:19:19,277 [main] loaded library - /META-INF/c-1_0-rt.tld - http://java.sun.com/jstl/core_rt
INFO  2013-04-05 00:19:19,324 [main] loaded library - /META-INF/x.tld - http://java.sun.com/jsp/jstl/xml
INFO  2013-04-05 00:19:19,603 [main] loaded library - /META-INF/f.tld - http://sastruts.seasar.org/functions
INFO  2013-04-05 00:19:19,615 [main] loaded library - /META-INF/s.tld - http://sastruts.seasar.org
INFO  2013-04-05 00:19:19,651 [main] loaded library - /META-INF/tlds/struts-bean-1.1.tld - http://jakarta.apache.org/struts/tags-bean
INFO  2013-04-05 00:19:19,713 [main] loaded library - /META-INF/tlds/struts-nested.tld - http://struts.apache.org/tags-nested
INFO  2013-04-05 00:19:19,725 [main] loaded library - /META-INF/tlds/struts-tiles-1.1.tld - http://jakarta.apache.org/struts/tags-tiles
INFO  2013-04-05 00:19:19,787 [main] loaded library - /META-INF/tlds/struts-nested-1.1.tld - http://jakarta.apache.org/struts/tags-nested
INFO  2013-04-05 00:19:19,801 [main] loaded library - /META-INF/tlds/struts-logic.tld - http://struts.apache.org/tags-logic
INFO  2013-04-05 00:19:19,852 [main] loaded library - /META-INF/tlds/struts-html-1.1.tld - http://jakarta.apache.org/struts/tags-html
INFO  2013-04-05 00:19:19,896 [main] loaded library - /META-INF/tlds/struts-html.tld - http://struts.apache.org/tags-html
INFO  2013-04-05 00:19:19,903 [main] loaded library - /META-INF/tlds/struts-bean.tld - http://struts.apache.org/tags-bean
INFO  2013-04-05 00:19:19,909 [main] loaded library - /META-INF/tlds/struts-tiles.tld - http://struts.apache.org/tags-tiles
INFO  2013-04-05 00:19:19,919 [main] loaded library - /META-INF/tlds/struts-logic-1.1.tld - http://jakarta.apache.org/struts/tags-logic
DEBUG 2013-04-05 00:19:19,973 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/annotations/javax.annotation-1.1.0.v201108011116.jar
DEBUG 2013-04-05 00:19:19,973 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/annotations/org.objectweb.asm-3.1.0.v200803061910.jar
DEBUG 2013-04-05 00:19:19,973 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/com.sun.el-2.2.0.v201108011116.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/javax.el-2.2.0.v201108011116.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jsp/org.eclipse.jdt.core-3.7.1.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jndi/javax.activation-1.1.0.v201105071233.jar
DEBUG 2013-04-05 00:19:19,974 [main] scan jar: /usr/local/jetty-distribution-8.1.10.v20130312/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
INFO  2013-04-05 00:19:20,529 [main] loaded library - /mayaa.mld - http://mayaa.seasar.org
DEBUG 2013-04-05 00:19:20,529 [main] /web.xml is read by URL (file:/Volumes/750G/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/treefigure-web-front/WEB-INF/web.xml)
INFO  2013-04-05 00:19:20,573 [main] prepareLibraries end
INFO  2013-04-05 00:19:20,574 [main] init end
2013-04-05 00:19:20.596:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080

よし!起動しました!
serversはv8.0で作成しましたが、jetty8.1が起動できました。

jetty9.0は動くか

残念ながらv9.0はserverが作成できませんでした
残念。

Tomcatハンドブック 第2版

Tomcatハンドブック 第2版