Why Netbeans jetty plugin doesn't run but jett

2019-08-01 12:11发布

问题:

I'm learning swagger, created maven project running jetty plugin, when I ran the project from Netbeans, got the following error message :

ant -f C:\\JettyServerInstance\\jettybase -Druntime.encoding=UTF-8 -Dnpn.boot= -Dserver.debug.transport=dt_socket -Dstop.key=netbeans -Dstop.port=8180 -Ddebug.args.line=-Xdebug -Dserver.debug.port=4000 -Dstart.jar=C:\\jetty/start.jar -Dtarget=run run
pre-run:
run:
2015-07-21 14:53:27.271:INFO::main: Logging initialized @507ms
2015-07-21 14:53:27.335:WARN:oejx.XmlConfiguration:main: Property 'threads.min' is deprecated, use 'jetty.threadPool.minThreads' instead
2015-07-21 14:53:27.336:WARN:oejx.XmlConfiguration:main: Property 'threads.max' is deprecated, use 'jetty.threadPool.maxThreads' instead
2015-07-21 14:53:27.336:WARN:oejx.XmlConfiguration:main: Property 'threads.timeout' is deprecated, use 'jetty.threadPool.idleTimeout' instead
2015-07-21 14:53:27.355:WARN:oejx.XmlConfiguration:main: Property 'jetty.dump.start' is deprecated, use 'jetty.server.dumpAfterStart' instead
2015-07-21 14:53:27.355:WARN:oejx.XmlConfiguration:main: Property 'jetty.dump.stop' is deprecated, use 'jetty.server.dumpBeforeStop' instead
2015-07-21 14:53:27.388:WARN:oejx.XmlConfiguration:main: Property 'jetty.port' is deprecated, use 'jetty.http.port' instead
2015-07-21 14:53:27.388:WARN:oejx.XmlConfiguration:main: Property 'http.timeout' is deprecated, use 'jetty.http.idleTimeout' instead
2015-07-21 14:53:27.445:INFO:oejs.Server:main: jetty-9.3.1.v20150714
2015-07-21 14:53:27.458:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///C:/JettyServerInstance/jettybase/webapps/] at interval 1
2015-07-21 14:53:27.507:INFO:oejs.ServerConnector:main: Started ServerConnector@6d78f375{HTTP/1.1,[http/1.1]}{0.0.0.0:80}
2015-07-21 14:53:27.507:INFO:oejs.Server:main: Started @743ms
--- handle target=/
--- handle target=/
--- handle target=/
--- handle target=/
--- handle target=/
--- handle target=/jeeserver/manager
handle cp=/swagger-ui
handle cmd=deploy
PROJECT TYPE=null
!!! deploy started for cp=/swagger-ui; webDir=C:\swagger-ui
deploy: success
--- handle target=/
--- handle target=/
--- handle target=/jeeserver/manager
handle cp=/swagger-ui
handle cmd=start
start command for cp=/swagger-ui; webDir=C:\swagger-ui
2015-07-21 14:53:28.211:WARN:oejs.HttpChannel:qtp231685785-20: //localhost/jeeserver/manager?cmd=start&cp=/swagger-ui&dir=/C%3A/swagger-ui
java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.eclipse.jetty.cdi.websocket.WebSocketCdiInitializer not found
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.getNonExcludedInitializers(AnnotationConfiguration.java:853)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:440)
    at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:485)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1330)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:734)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:511)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.jetty.custom.handlers.CommandManager.start(CommandManager.java:485)
    at org.jetty.custom.handlers.CommandManager.start(CommandManager.java:468)
    at org.jetty.custom.handlers.CommandManager.handle(CommandManager.java:127)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:302)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:238)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:57)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
2015-07-21 14:53:28.212:WARN:oejs.HttpChannel:qtp231685785-20: //localhost/jeeserver/manager?cmd=start&cp=/swagger-ui&dir=/C%3A/swagger-ui
java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.eclipse.jetty.cdi.websocket.WebSocketCdiInitializer not found
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.getNonExcludedInitializers(AnnotationConfiguration.java:853)
    at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:440)
    at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:485)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1330)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:734)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:511)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.jetty.custom.handlers.CommandManager.start(CommandManager.java:485)
    at org.jetty.custom.handlers.CommandManager.start(CommandManager.java:468)
    at org.jetty.custom.handlers.CommandManager.handle(CommandManager.java:127)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:302)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:238)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:57)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
--- handle target=/swagger-ui
BUILD STOPPED (total time: 28 seconds)

But when : Use "Custom -> jetty:run", it works fine and I can see the webpage, the output look like this :

cd C:\swagger-ui; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_45" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven\\bin\\mvn.bat\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 install\""
Scanning for projects...

------------------------------------------------------------------------
Building swagger-ui 2.1.0-M1
------------------------------------------------------------------------

--- maven-dependency-plugin:2.1:copy (default) @ swagger-ui ---

--- maven-resources-plugin:2.5:resources (default-resources) @ swagger-ui ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 0 resource

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ swagger-ui ---
Nothing to compile - all classes are up to date

--- maven-resources-plugin:2.5:testResources (default-testResources) @ swagger-ui ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\swagger-ui\src\test\resources

--- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ swagger-ui ---
No sources to compile

--- maven-surefire-plugin:2.10:test (default-test) @ swagger-ui ---
Surefire report directory: C:\swagger-ui\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


--- maven-war-plugin:2.1.1:war (default-war) @ swagger-ui ---
Packaging webapp
Assembling webapp [swagger-ui] in [C:\swagger-ui\target\swagger-ui-2.1.0-M1]
Processing war project
Copying webapp resources [C:\swagger-ui\src\main\webapp]
Webapp assembled in [31 msecs]
Building war: C:\swagger-ui\target\swagger-ui-2.1.0-M1.war

--- maven-install-plugin:2.3.1:install (default-install) @ swagger-ui ---
Installing C:\swagger-ui\target\swagger-ui-2.1.0-M1.war to C:\Users\mmn0707\.m2\repository\org\webjars\swagger-ui\2.1.0-M1\swagger-ui-2.1.0-M1.war
Installing C:\swagger-ui\pom.xml to C:\Users\mmn0707\.m2\repository\org\webjars\swagger-ui\2.1.0-M1\swagger-ui-2.1.0-M1.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 2.431s
Finished at: Tue Jul 21 14:54:04 EDT 2015
Final Memory: 12M/304M
------------------------------------------------------------------------
cd C:\swagger-ui; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_45" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven\\bin\\mvn.bat\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 jetty:run\""
Scanning for projects...

------------------------------------------------------------------------
Building swagger-ui 2.1.0-M1
------------------------------------------------------------------------

>>> jetty-maven-plugin:9.3.1.v20150714:run (default-cli) @ swagger-ui >>>

--- maven-dependency-plugin:2.1:copy (default) @ swagger-ui ---

--- maven-resources-plugin:2.5:resources (default-resources) @ swagger-ui ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 0 resource

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ swagger-ui ---
Nothing to compile - all classes are up to date

--- maven-resources-plugin:2.5:testResources (default-testResources) @ swagger-ui ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\swagger-ui\src\test\resources

--- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ swagger-ui ---
No sources to compile

<<< jetty-maven-plugin:9.3.1.v20150714:run (default-cli) @ swagger-ui <<<

--- jetty-maven-plugin:9.3.1.v20150714:run (default-cli) @ swagger-ui ---
Configuring Jetty for project: swagger-ui
webAppSourceDirectory not set. Trying src\main\webapp
Reload Mechanic: automatic
Classes = C:\swagger-ui\target\classes
2015-07-21 14:54:07.905:INFO::main: Logging initialized @3114ms
Context path = /
Tmp directory = C:\swagger-ui\target\tmp
Web defaults = org/eclipse/jetty/webapp/webdefault.xml
Web overrides =  none
web.xml file = null
Webapp directory = C:\swagger-ui\src\main\webapp
2015-07-21 14:54:07.972:INFO:oejs.Server:main: jetty-9.3.1.v20150714
2015-07-21 14:54:08.335:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@67fe380b{/swagger-ui,[file:///C:/swagger-ui/src/main/webapp/, jar:file:///C:/Users/mmn0707/.m2/repository/org/webjars/swagger-ui/2.1.8-M1/swagger-ui-2.1.8-M1.jar!/META-INF/resources],AVAILABLE}{file:///C:/swagger-ui/src/main/webapp/}
2015-07-21 14:54:08.522:INFO:oejs.ServerConnector:main: Started ServerConnector@53093491{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-07-21 14:54:08.522:INFO:oejs.Server:main: Started @3731ms
Started Jetty Server

Why ? How to fix it so I can run it from Netbeans -> Run ?

回答1:

Don't enable the cdi jetty module, it's highly experimental in the Jetty 9.3.1 release.

really just a testbed for discussions on next servlet rev - Servlet 4.0