JSoup Initialisation NPE

Hi guys,

I’m trying to rollout a Vaadin 7 application and am getting the same error on startup over and over. It started off being intermittant and stopping and starting the server a couple of times resolved the issue; but now it’s happening every time :frowning:

java.lang.NoClassDefFoundError: Could not initialize class org.jsoup.nodes.Entities$EscapeMode
	at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:208)
	at org.jsoup.nodes.Document.<init>(Document.java:17)
	at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:27)
	at org.jsoup.parser.HtmlTreeBuilder.parseFragment(HtmlTreeBuilder.java:43)
	at org.jsoup.parser.Parser.parseFragment(Parser.java:105)
	at org.jsoup.nodes.Element.append(Element.java:343)
	at com.vaadin.server.BootstrapHandler.setupMainDiv(BootstrapHandler.java:330)
	at com.vaadin.server.BootstrapHandler.handleRequest(BootstrapHandler.java:146)
	at com.vaadin.server.AbstractCommunicationManager.handleOtherRequest(AbstractCommunicationManager.java:2334)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:330)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1367)
	at waffle.servlet.NegotiateSecurityFilter.doFilterPrincipal(Unknown Source)
	at waffle.servlet.NegotiateSecurityFilter.doFilter(Unknown Source)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:350)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:722)

2013-03-08 09:23:12.307:WARN:oejs.ServletHandler:/tradestore/
java.lang.NoClassDefFoundError: Could not initialize class org.jsoup.nodes.Entities$EscapeMode
	at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:208)
	at org.jsoup.nodes.Document.<init>(Document.java:17)
	at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:27)
	at org.jsoup.parser.HtmlTreeBuilder.parseFragment(HtmlTreeBuilder.java:43)
	at org.jsoup.parser.Parser.parseFragment(Parser.java:105)
	at org.jsoup.nodes.Element.append(Element.java:343)
	at com.vaadin.server.BootstrapHandler.setupMainDiv(BootstrapHandler.java:330)
	at com.vaadin.server.BootstrapHandler.handleRequest(BootstrapHandler.java:146)
	at com.vaadin.server.AbstractCommunicationManager.handleOtherRequest(AbstractCommunicationManager.java:2334)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:330)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1367)
	at waffle.servlet.NegotiateSecurityFilter.doFilterPrincipal(Unknown Source)
	at waffle.servlet.NegotiateSecurityFilter.doFilter(Unknown Source)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:350)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:722)

Don’t suppose anyone’s run into this problem before/can provide some help?

Thanks in advance.

Looks like jSoup is not in the classpath.

It does look like that, but JSoup is definitely on the classpath…

In fact, the stack trace I posted is actually the second time the application is accessed, the first time the exception starts with…

java.lang.ExceptionInInitializerError
	at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:18)

The reason looks to be that JSoup is statically reading in a resource using the classloader, and not finding it, giving back null, which is then passed to the Properties.load(), giving a NPE. As the class can’t be loaded the second time you access it you get a NoClassDefFound error.

So the problem then becomes, why can Jetty not find the properties file…

JSoup is loading using

            InputStream in = Entities.class.getResourceAsStream(filename);
            properties.load(in);

where the filename is “entities-base.properties”.

I’m now totally out of my depth, all I know is that Jetty’s classloader for servlets has a slightly different resolution pattern.