ninjaframework / ninja-appengine

Google App Engine support for Ninja Framework
Apache License 2.0
40 stars 21 forks source link

Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/server/ServerContainer #29

Closed miketeo closed 6 years ago

miketeo commented 6 years ago

Hi, I have created a new appengine project using mvn archetype:generate -DarchetypeGroupId=org.ninjaframework -DarchetypeArtifactId=ninja-appengine-blog-archetype

On running mvn appengine:devserver -Pdevserver, I have encountered the following exception: Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/server/ServerContainer

The following properties are used in the pom.xml:

        <ninja.version>6.2.1</ninja.version>
        <ninja-appengine.version>1.9.60</ninja-appengine.version>
        <appengine.version>1.9.60</appengine.version>
overengineered commented 6 years ago

I'm facing the same problem. I'm new to Java server development, so not sure what's relevant to report. I'm running macOS 10.13.5,

openjdk version "1.8.0_152-release"
OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
OpenJDK 64-Bit Server VM (build 25.152-b01, mixed mode)

I've tried mvn jetty:run with the same result.

@miketeo Did you manage to overcome this?

raphaelbauer commented 6 years ago

It works (at least for me) with mvn appengine:devserver -Pdevserver. jetty:run won't work.

overengineered commented 6 years ago

When I generate appengine guestbook archetype it works on my machine. However if I add

    <dependency>
        <groupId>org.ninjaframework</groupId>
        <artifactId>ninja-appengine-module</artifactId>
        <version>1.9.60</version>
    </dependency>

guestbook project also stops working with java.lang.NoClassDefFoundError: javax/websocket/server/ServerContainer

overengineered commented 6 years ago

I've tried running another machine (macOS again) where java -version is

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

I'm again stuck on the same problem. All the Ninja tests pass, then server is started

[INFO] Running /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/bin/java -XstartOnFirstThread -D--enable_all_permissions=true -Dappengine.fullscan.seconds=5 -Duse_jetty9_runtime=true -classpath /Users/juozask/.m2/repository/com/google/appengine/appengine-java-sdk/1.9.60/appengine-java-sdk/appengine-java-sdk-1.9.60/lib/appengine-tools-api.jar -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+UseParNewGC -XX:MaxNewSize=256m -XX:NewSize=256m -XX:SurvivorRatio=128 -XX:+UseTLAB -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled com.google.appengine.tools.development.DevAppServerMain --allow_remote_shutdown --no_java_agent /Users/incognito/code/ninja/target/test1-1.0-SNAPSHOT

And it fails with non-descriptive callstack

[INFO] Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/server/ServerContainer
[INFO]  at java.lang.Class.getDeclaredMethods0(Native Method)
[INFO]  at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
[INFO]  at java.lang.Class.getDeclaredMethods(Class.java:1975)
[INFO]  at org.eclipse.jetty.annotations.ResourceAnnotationHandler.doHandle(ResourceAnnotationHandler.java:70)
[INFO]  at org.eclipse.jetty.annotations.AnnotationIntrospector$AbstractIntrospectableAnnotationHandler.handle(AnnotationIntrospector.java:71)
[INFO]  at org.eclipse.jetty.annotations.AnnotationIntrospector.introspect(AnnotationIntrospector.java:96)
[INFO]  at org.eclipse.jetty.annotations.AnnotationDecorator.introspect(AnnotationDecorator.java:61)
[INFO]  at org.eclipse.jetty.annotations.AnnotationDecorator.decorate(AnnotationDecorator.java:67)
[INFO]  at org.eclipse.jetty.util.DecoratedObjectFactory.decorate(DecoratedObjectFactory.java:77)
[INFO]  at org.eclipse.jetty.servlet.ServletContextHandler$Context.createListener(ServletContextHandler.java:1471)
[INFO]  at org.eclipse.jetty.server.handler.ContextHandler$Context.addListener(ContextHandler.java:2357)
[INFO]  at org.eclipse.jetty.servlet.ServletContextHandler$Context.addListener(ServletContextHandler.java:1462)
[INFO]  at ninja.servlet.NinjaServletContainerInitializer.onStartup(NinjaServletContainerInitializer.java:35)
[INFO]  at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
[INFO]  at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
[INFO]  at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
....
overengineered commented 6 years ago

OK. I finally got it work. After generating archetype I manually downgrade ninja version:

<properties>
    <ninja.version>6.1.0</ninja.version>
    <ninja-appengine.version>1.9.54</ninja-appengine.version>
    <appengine.version>1.9.54</appengine.version>
    <appengine.generated.dir>target/${project.artifactId}-${project.version}/WEB-INF/appengine-generated</appengine.generated.dir>
</properties>

Since ninja 6.2.0 there's Programmatic initializing of NinjaFramework so that a web.xml is not required and it causes problems on my system. Without it I can run ninja with app engine.

@raphaelbauer do you know if there's a possibility to disable this programmatic initializing, so that appengine-web.xml is specifying initialization?

raphaelbauer commented 6 years ago

I can reproduce the problem. We just released version 1.9.65 that should fix the issue (and also features Ninja 6.3.0). Please try that version and check whether that works for you... Thanks!

overengineered commented 6 years ago

It works, thanks!

raphaelbauer commented 6 years ago

👍 Thanks for testing!