Vaadin is dropping error messages on dev environment

Hi,
Now I have some kind of an issue with the configuration of Vaadin itself, as I can see the following error messages in the console log:


WebSocket connection to 'ws://localhost:8080/app/PUSH?v-uiId=0&v-csrfToken=19ad1e55-5182-4668-8ae8-9923cee819dc&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.13.vaadin3-jquery&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true' failed: Error during WebSocket handshake: Unexpected response code: 500
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
Websocket closed, wasClean: false
Websocket failed. Downgrading to Comet and resending

and then in every couple of seconds I get


vaadinPush.js?v2017_02_01_09_36:26 GET http://localhost:8080/app/PUSH?v-uiId=0&v-csrfToken=19ad1e55-5182-4668-8ae8…plication%2Fjson%3B%20charset%3DUTF-8&X-atmo-protocol=true&_=1485941974997 500 (Internal Server Error)

Could you please point me out how to fix this?
Thank you for your help:
Gabor

Hi,

Could you share app.log files from your Tomcat ? Are there any related errors?

Nothing in the app.log, as you can see, but there is something in catalina.out

app.log (1.1M)

catalina.log (56.7K)

I see in catalina.log:


NoClassDefFoundError: org/eclipse/jetty/websocket/server/WebSocketServerFactory

Do you use Jetty or Tomcat? Is there any jetty jar in your tomcat instance?

If you use Jetty, have you installed WebSockets module for Jetty? It is required and If you cannot install WebSockets module then you can use fallback to the long-polling mechanism using cuba.web.pushLongPolling application property set to true. See also: Server Push Settings - CUBA Platform. Developer’s Manual

Yeah, you are right, it’s a Tomcat 8. I’m not using jetty directly… Now I have put


        compile(group: 'org.eclipse.jetty.websocket', name: 'websocket-client', version: '9.4.0.v20161208')

into the dependencies of the core and web modules, it downloads these jars:


Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/websocket/websocket-client/9.4.0.v20161208/websocket-client-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/jetty-util/9.4.0.v20161208/jetty-util-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/jetty-io/9.4.0.v20161208/jetty-io-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/jetty-client/9.4.0.v20161208/jetty-client-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/websocket/websocket-common/9.4.0.v20161208/websocket-common-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/jetty-http/9.4.0.v20161208/jetty-http-9.4.0.v20161208.jar
Download https://repo.cuba-platform.com/content/groups/work/org/eclipse/jetty/websocket/websocket-api/9.4.0.v20161208/websocket-api-9.4.0.v20161208.jar

However the above error is still in the log. Do I need to do something else?

If you use tomcat, please DO NOT add jetty jars to your project!

Please remove jetty dependency, undeploy your application, then deploy it again and attach list of JAR files inside your tomcat/shared/lib and tomcat/webapps/app-core/WEB-INF/lib and tomcat/webapps/app/WEB-INF/lib. It seems that there is jetty jar file in your classpath that leads to incorrect initialization of Atmosphere framework.

Removed the dependency, and cleared the build directory, cleaned up, rebuilt, and yes you are right, there is two jetty files in the tomcat/shared/lib:


jetty-io-9.2.18.v20160721.jar
jetty-util-9.2.18.v20160721.jar

Where could they come from?

shared_lib.txt (9.1K)

webapps_app-core_web-inf_lib.txt (276B)

webapps_app_web-inf_lib.txt (504B)

Let`s try to figure out where they come from using Gradle. In Studio use Build - Create Gradle wrapper.

Then execute using CMD:


> gradlew :app-web:dependencies > app-web.log
> gradlew :app-core:dependencies > app-core.log

And please share app-web.log and app-core.log files, it seems that some thirdparty library brings this transitive dependencies on jetty-* libs.

Very useful command!
Apparently it’s a package called “htmlunit” in core.


        compile('net.sourceforge.htmlunit:htmlunit-core-js:2.23')
        compile('net.sourceforge.htmlunit:neko-htmlunit:2.23')
        compile('net.sourceforge.htmlunit:htmlunit:2.23')

Now I’ll need to find out why is that there, if it is used, or could it be replaced with something else…

Thanks for your help Yuriy, it was really effective and useful!

app-core.log (426.0K)

app-web.log (229.7K)

Morning Yuriy,
so I have tracked down the htmlunit package and it’s used by my partner developer, who has written some webpage parsers in core module with the help of it. And apparently this is the reason that the issue occurs only development and staging environments, where all modules are running on the same machine so Vaadin will find the jetty in the shared lib, and gets confused, but on the live environment they are separated, and it’s not on the web module’s environment, therefore it works fine there.
My question is now is it possible to force these packages to be downloaded into the “app-core/WEB-INF/lib” dir somehow? Maybe then Vaadin wouldn’t see them on the devmachines…

Thanks for your help
Gabor

You can set jars that have to go to webapps/app-core/WEB-INF/lib using appJars() list in your build.gradle file inside of configure(coreModule) { section, but there you have to mention all jars of html unit and all its dependencies.

Also, if you actually do not use these features of html unit for WebSockets then you can exclude jetty jars from dependencies using Gradle exclude syntax: Learning the Basics

Amazing knowledge, thank you!
Now the jetty files are gone from shared/lib, also I have made absolutely sure that no file contains “jetty” in their names left in the whole tomcat directory structure (scanned it through with mc)
But now it still gives the same error message … :frowning:
What else could cause this issue?

catalina.log (30.4K)

Could you print file structure of your tomcat instance? You can print it using > tree tomcat command on Windows from build directory of your project.

Well, it’s a Linux, but if you mean the directory structure, it’s attached

tree.txt (238.7K)

I see in shared/lib


-rw-r--r-- 1 lordradi users    44053 Feb  3 15:04 websocket-api-9.2.18.v20160721.jar
-rw-r--r-- 1 lordradi users    36262 Feb  3 15:04 websocket-client-9.2.18.v20160721.jar
-rw-r--r-- 1 lordradi users   180261 Feb  3 15:04 websocket-common-9.2.18.v20160721.jar

It seems there are jetty jars. Did you really exclude them from your project?

:open_mouth: I have excluded only those two with “jetty” in their names… I’ll exclude these now as well!

…and now it works! :smiley:
Thank you again for your patience, and help!