cannot parse configuration file error with packaged jar

850 views
Skip to first unread message

mp

unread,
May 8, 2015, 6:46:17 AM5/8/15
to dropwiz...@googlegroups.com
Hello

My first dropwizard application works great in intellij when i run/debug with the appropriate commandline args (server api.yaml), however when I package everything up into a fat jar I get the following error:


user@server:~/api$ java -jar api-jar-with-dependencies.jar server api.yaml
api.yaml has an error:
  * Failed to parse configuration at: server.connector; Could not resolve type id 'http' into a subtype of [simple type, class io.dropwizard.jetty.ConnectorFactory]: known type ids = [ConnectorFactory]
 at [Source: N/A; line: -1, column: -1] (through reference chain: APIConfiguration["server"]->io.dropwizard.server.SimpleServerFactory["connector"])


I suspect it must be a packaging thing... I've packaged up in maven with this:


            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>uk.co.epicuri.bookingapi.BookingAPIApplication</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>

> mvn clean compile assembly:single


I'm unsure what's actually happening here, can anyone shed any light please? Thanks in advance

Prajwal Tuladhar

unread,
May 8, 2015, 7:12:14 AM5/8/15
to dropwiz...@googlegroups.com
It's complaining that your YAML config file (sever section) is invalid.

Can you paste your YAML file?

--
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.



--
--
Cheers,
Praj

mp

unread,
May 8, 2015, 8:50:43 AM5/8/15
to dropwiz...@googlegroups.com
But it works from an IDE, so i think that's a red herring.

server:
  type: simple
  applicationContextPath: /v1
  adminContextPath: /admin
  connector:
    type: http
    port: 8085

logging:
  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: INFO

Prajwal Tuladhar

unread,
May 8, 2015, 9:09:13 AM5/8/15
to dropwiz...@googlegroups.com
server config syntax doesn't match with what DW is expecting. Take a look @ https://github.com/dropwizard/dropwizard/blob/v0.8.1/dropwizard-example/example.yml#L27-L52

And as for "working with IDE", if you check, it might not be listening to port 8085, rather defaulting DW application port (8080).

mp

unread,
May 8, 2015, 9:27:14 AM5/8/15
to dropwiz...@googlegroups.com
It's def working on the ide on 8085

INFO  [2015-05-08 09:37:22,131] org.eclipse.jetty.setuid.SetUIDListener: Opened APIApplication@7a6ebe1e{HTTP/1.1}{0.0.0.0:8085}

According to the link I should be doing

server:
  applicationContextPath: /v1
  adminContextPath: /admin
#  softNofileLimit: 1000
#  hardNofileLimit: 1000
  applicationConnectors:
    - type: http
      port: 8085

Similarly also works in IDE, but not when packaged in a jar.

mp

unread,
May 8, 2015, 9:45:41 AM5/8/15
to dropwiz...@googlegroups.com
Ok I got it working, though I'm not sure I understand why. It was indeed to do with the maven packaging of the jar, and there are some other posts on StackOverflow that point to the same issue (in gradle)

I changed the plugin to include all resources:

              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.6</version>
                <configuration>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>my.application</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Artem Prigoda

unread,
May 8, 2015, 11:03:08 AM5/8/15
to dropwiz...@googlegroups.com
It looks like you stepped on this issue #810

The recommended way to build Dropwizard application is through maven-shade-plugin. Check out the "Building Fat Jars" section of Getting Started.
You need to configure maven-assemply-plugin to merge META-INF/services entries in your jar.

Artem

mp

unread,
May 12, 2015, 7:36:22 AM5/12/15
to dropwiz...@googlegroups.com
Thanks for the Getting Started link, I completely missed the fact that it had a fat jar section. That's indeed how I ended up fixing it.
Reply all
Reply to author
Forward
0 new messages