DW newbie gets NPE when running first project.

797 views
Skip to first unread message

Geoffry Roberts

unread,
Mar 11, 2015, 11:33:48 AM3/11/15
to dropwiz...@googlegroups.com
All,

I have the world's simplest project.  It consists of main() and run() where run() does nothing.  I'm getting an NPE (NullPointerException) when I build and run.  All I want to do for now is to get the server to standup.

Confession: I am using gradle and not maven and why should that matter?

Thanks 

Does anyone recognize this error?  

public static void main(String[] args) throws Exception {

log.info("start==>");

new ReferralApplication().run(args);

}

@Override

public void run(ReferralConfiguration configuration, Environment environment)

throws Exception {}


Here's the error notice my run() call at the bottom of the stack:


WARN  [2015-03-11 15:29:54,926] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: Unknown HK2 failure detected:

MultiException stack 1 of 2

java.lang.NullPointerException

at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:109)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1041)

at org.jvnet.hk2.internal.ClazzCreator.methodMe(ClazzCreator.java:321)

at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:374)

at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)

at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)

at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2064)

at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)

at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)

at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:58)

at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:54)

at jersey.repackaged.com.google.common.collect.Iterators$8.transform(Iterators.java:860)

at jersey.repackaged.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)

at java.util.AbstractCollection.addAll(AbstractCollection.java:341)

at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169)

at jersey.repackaged.com.google.common.collect.Sets.newLinkedHashSet(Sets.java:292)

at org.glassfish.jersey.internal.inject.Providers.getClasses(Providers.java:388)

at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:187)

at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:222)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1129)

at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:274)

at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:368)

at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)

at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:82)

at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:70)

at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)

at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)

at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:121)

at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2064)

at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:711)

at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:653)

at org.glassfish.jersey.server.model.ComponentModelValidator.<init>(ComponentModelValidator.java:97)

at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:496)

at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:166)

at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:327)

at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)

at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)

at org.glassfish.jersey.internal.Errors.process(Errors.java:315)

at org.glassfish.jersey.internal.Errors.process(Errors.java:297)

at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)

at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:324)

at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:336)

at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)

at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)

at javax.servlet.GenericServlet.init(GenericServlet.java:244)

at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612)

at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395)

at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871)

at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)

at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)

at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:102)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)

at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)

at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)

at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:232)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)

at org.eclipse.jetty.server.Server.start(Server.java:387)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)

at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)

at org.eclipse.jetty.server.Server.doStart(Server.java:354)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)

at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:43)

at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)

at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76)

at io.dropwizard.cli.Cli.run(Cli.java:70)

at io.dropwizard.Application.run(Application.java:73)

at iop.referral.rest.ReferralApplication.main(ReferralApplication.java:71)




Tim Bart

unread,
Mar 11, 2015, 3:45:39 PM3/11/15
to dropwiz...@googlegroups.com
Which DW version?

Geoffry Roberts

unread,
Mar 11, 2015, 3:54:45 PM3/11/15
to dropwiz...@googlegroups.com
Which DW version? 0.8.0.

Artem Prigoda

unread,
Mar 11, 2015, 4:35:12 PM3/11/15
to dropwiz...@googlegroups.com
Thanks for the report.

Please, provide a sample project and gradle configuration on Github or Gist, so we can run it and expect output.
The exception you provided doesn't give enough information. At first glance seems like some Jersey jars are not loaded.

Artem 

Geoffry Roberts

unread,
Mar 25, 2015, 2:02:14 PM3/25/15
to dropwiz...@googlegroups.com
I finally got back to this project.  I'm still having the same problem but I have managed to narrow down on the cause.  There would appear to be a conflict between DW and the libraries I'm using.

We're using gradle here:

dependencies {

compile 'io.dropwizard:dropwizard-core:0.8.0'


// If I add in the following two dependencies, the NPE results and the server won't start.  Remove them and the server starts normally.

compile 'org.apache.hadoop:hadoop-client:2.6.0' 

compile 'org.apache.thrift:libthrift:0.9.0'

}


I'm asking if anyone recognizes the problem or what might be causing it?


Failure occurs at:

io.dropwizard.cli.ServerCommand...

43 server.start();  


Thanks 

Ryan Kennedy

unread,
Mar 25, 2015, 2:18:30 PM3/25/15
to dropwiz...@googlegroups.com
Are you using the maven enforcer plugin for your builds? It may sniff out library inconsistency problems.


Ryan

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Geoffrey Arnold

unread,
Mar 25, 2015, 3:43:43 PM3/25/15
to dropwiz...@googlegroups.com
If you haven't added any resources yet, you'll have to do an "environment.jersey().disable()" otherwise you'll get an NPE (caused by a CNFE)...

Geoffry Roberts

unread,
Mar 25, 2015, 3:51:21 PM3/25/15
to dropwiz...@googlegroups.com
Thanks Geoffrey,

But the with or without resources doesn't matter.  I've tried both ways.  The difference seems to be the aforementioned dependencies.


On Wednesday, March 11, 2015 at 11:33:48 AM UTC-4, Geoffry Roberts wrote:

Geoffrey Arnold

unread,
Mar 25, 2015, 3:52:19 PM3/25/15
to dropwiz...@googlegroups.com
Gotcha, worth a shot

Geoffry Roberts

unread,
Mar 26, 2015, 4:09:31 PM3/26/15
to dropwiz...@googlegroups.com
All,

I solved my problem and DW is at least starting properly.

It seems this was a transitive dependency issue brought on by jersey-client being on the classpath in triplicate.  I excluded two of these (see below) and solved the problem.

FROM: build.gradle

configurations {

compile.exclude group: 'org.apache.hadoop', module: 'hadoop-yarn-common'

compile.exclude group: 'org.apache.hadoop', module: 'hadoop-yarn-server-nodemanager'

}

On Wednesday, March 11, 2015 at 11:33:48 AM UTC-4, Geoffry Roberts wrote:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages