jshah jshah - 3 years ago 128
Scala Question

Dropwizard IntelliJ Setup Issue

I'm trying to setup Dropwizard hello world application and running into an issue. Here is the stack trace:

objc[30585]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java (0x1021cc4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1031fd4e0). One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.NullPointerException
at com.fasterxml.jackson.databind.node.TreeTraversingParser.<init>(TreeTraversingParser.java:71)
at com.fasterxml.jackson.databind.node.TreeTraversingParser.<init>(TreeTraversingParser.java:65)
at io.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:125)
at io.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:77)
at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:114)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:63)
at io.dropwizard.cli.Cli.run(Cli.java:70)
at io.dropwizard.Application.run(Application.java:72)
at com.example.HelloWorldApplication$.main(HelloWorldApplication.scala:18)
at com.example.HelloWorldApplication.main(HelloWorldApplication.scala)


Here is my Application:

package com.example

import io.dropwizard.Application
import io.dropwizard.setup.Bootstrap
import io.dropwizard.setup.Environment

class HelloWorldApplication extends Application[HelloWorldConfiguration] {
override def run(configuration: HelloWorldConfiguration, environment: Environment): Unit = {
val helloWorld = new HelloWorldResource()
environment.jersey().register(helloWorld)
}

override def initialize(bootstrap: Bootstrap[HelloWorldConfiguration]): Unit = {}
}

object HelloWorldApplication {
def main(args: Array[String]) = {
new HelloWorldApplication().run(args)
}
}


I run the application with these arguments in IntelliJ:
server src/main/resources/config.yml


Any tips to debug and get set up properly would be helpful.

Answer Source

Generate a jar file in the Scala project by going to Project Structure > Artifacts and adding a project jar.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download