question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Have a Combined Javalin/Selenium Project

See original GitHub issue

When trying to make a project with a combination of Javalin and Selenium server, I run into a weird error when attempting to start the Javalin server.

I’ve created a very simple project that should give a good example.

With this defined as your pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>example</groupId>
   <artifactId>javalin-and-selenium</artifactId>
   <version>1.0.0-SNAPSHOT</version>

   <properties>
      <java.version>1.8</java.version>
      <maven.compiler.source>${java.version}</maven.compiler.source>
      <maven.compiler.target>${java.version}</maven.compiler.target>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   </properties>

   <dependencies>
      <dependency>
         <groupId>io.javalin</groupId>
         <artifactId>javalin</artifactId>
         <version>2.0.0.RC1</version>
      </dependency>
      <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-server</artifactId>
         <version>3.13.0</version>
         <exclusions>
            <exclusion>
               <groupId>log4j</groupId>
               <artifactId>log4j</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-classic</artifactId>
         <version>1.2.3</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>log4j-over-slf4j</artifactId>
         <version>1.7.25</version>
      </dependency>
   </dependencies>
</project>

And this defined as example.Main:

package example;

import io.javalin.Javalin;

public class Main {
  public static void main(String[] args) {
    Javalin.create().start();
  }
}

You should get an error similar to the below when running #main:

11:03:21.103 [main] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
11:03:21.120 [main] INFO org.eclipse.jetty.util.log - Logging initialized @1230ms to org.eclipse.jetty.util.log.Slf4jLog
11:03:21.149 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.Server@7382f612[9.4.8.v20171121] added {QueuedThreadPool@qtp385242642{STOPPED,8<=0<=250,i=0,q=0},AUTO}
11:03:21.157 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.Server@7382f612[9.4.8.v20171121] added {org.eclipse.jetty.server.LowResourceMonitor@3d04a311,AUTO}
11:03:21.415 [main] INFO io.javalin.Javalin - 
 _________________________________________
|        _                  _ _           |
|       | | __ ___   ____ _| (_)_ __      |
|    _  | |/ _` \ \ / / _` | | | '_ \     |
|   | |_| | (_| |\ V / (_| | | | | | |    |
|    \___/ \__,_| \_/ \__,_|_|_|_| |_|    |
|_________________________________________|
|                                         |
|    https://javalin.io/documentation     |
|_________________________________________|
11:03:21.415 [main] INFO io.javalin.Javalin - Starting Javalin ...
11:03:21.468 [main] DEBUG org.eclipse.jetty.util.DecoratedObjectFactory - Adding Decorator: org.eclipse.jetty.util.DeprecationWarning@97e1986
11:03:21.497 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE} added {org.eclipse.jetty.server.session.SessionHandler1566502717==dftMaxIdleSec=-1,MANAGED}
11:03:21.513 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.session.SessionHandler1566502717==dftMaxIdleSec=-1 added {org.eclipse.jetty.servlet.ServletHandler@5419f379,MANAGED}
11:03:21.514 [main] DEBUG org.eclipse.jetty.util.DecoratedObjectFactory - Adding Decorator: org.eclipse.jetty.util.DeprecationWarning@7dc7cbad
11:03:21.514 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE} added {org.eclipse.jetty.servlet.ServletHandler@4f933fd1,MANAGED}
11:03:21.536 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.servlet.ServletHandler@4f933fd1 added {io.javalin.core.util.JettyServerUtil$initialize$$inlined$apply$lambda$1-59fa1d9b@69a2b0b0==io.javalin.core.util.JettyServerUtil$initialize$$inlined$apply$lambda$1,jsp=null,order=-1,inst=true,AUTO}
11:03:21.537 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.servlet.ServletHandler@4f933fd1 added {[/*]=>io.javalin.core.util.JettyServerUtil$initialize$$inlined$apply$lambda$1-59fa1d9b,POJO}
11:03:21.541 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerList@59f99ea[i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE}, o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE}, io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1] added {i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE},AUTO}
11:03:21.541 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerList@59f99ea[i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE}, o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE}, io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1] added {o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE},AUTO}
11:03:21.542 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerList@59f99ea[i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE}, o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE}, io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1] added {io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1,AUTO}
11:03:21.543 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerWrapper@6f7fd0e6 added {org.eclipse.jetty.server.handler.HandlerList@59f99ea[i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE}, o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE}, io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1],MANAGED}
11:03:21.543 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerWrapper@6f7fd0e6 added {org.eclipse.jetty.server.handler.HandlerWrapper@47c62251,MANAGED}
11:03:21.544 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.handler.HandlerWrapper@47c62251 added {org.eclipse.jetty.server.handler.HandlerList@59f99ea[i.j.c.u.initialize$httpHandler$1@23ceabc1{/,null,UNAVAILABLE}, o.e.j.s.ServletContextHandler@d2cc05a{/,null,UNAVAILABLE}, io.javalin.core.util.JettyServerUtil$initialize$notFoundHandler$1670035812==dftMaxIdleSec=-1],MANAGED}
11:03:21.544 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.server.Server@7382f612[9.4.8.v20171121] added {org.eclipse.jetty.server.handler.HandlerWrapper@47c62251,MANAGED}
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/io/WriteFlusher$Listener
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.jetty.server.ServerConnector.<init>(ServerConnector.java:96)
	at io.javalin.core.util.JettyServerUtil.initialize(JettyServerUtil.kt:87)
	at io.javalin.Javalin.start(Javalin.java:125)
	at ca.grrbrr.example.Main.main(Main.java:7)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.io.WriteFlusher$Listener
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 16 more

I’m sure this issue is related to Selenium and Javalin both utilizing jetty, but I’m having a hard time figuring out how, why and what I could do to get around this issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Jitsusamacommented, Jul 6, 2018

FYI; that looks like it has fixed everything. I’m wondering if Selenium uses it’s jetty stuff for some weird corner features that I don’t even utilize. Thanks for taking the time to respond to this issue @tipsy!

0reactions
tipsycommented, Jul 5, 2018

Seems like you’ve got this one under control, have fun!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Have a Combined Javalin/Selenium Project #285
When trying to make a project with a combination of Javalin and Selenium server, I run into a weird error when attempting to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found