0
votes

I'm new to this Dropwizard thing, and to JAVA as a whole. I've tried to create a basic Dropwizard project (having connection with MySQL database through Hibernate). I'm using eclipse IDE for the same. I've followed all the steps to the T, but upon typing in this command in the console -> java -jar target/hotel2-0.0.1-SNAPSHOT.jar server config.yml. I get the following error:-

config.yml has an error: 
* Failed to parse configuration at: logging; Can not instantiate value of type [simple type, class io.dropwizard.logging.LoggingFactory] from String value (''); no single-String constructor/factory method at [Source: N/A; line: -1, column: -1] (through reference chain: com.drivedge.hotel2.HotelMgntConfiguration["logging"])  

Below are copies of my pom.xml and config.yml files:

config.yml -

## Configuration file for Hotel2 application.
---
# User login.
logging:
login: javaeeeee
# User  password.
password: crimson

#Server configuration.
server:
    applicationConnectors:
        - type: http
          port: 9090
        - type: https
          port: 9090
          keyStorePath: hotel2.keystore
          keyStorePassword: crimson

# Database settings.
database:
    # the name of the JDBC driver, mysql in our case
    driverClass: com.mysql.jdbc.Driver
    # the username
    user: root
    # the password
    password: drivedge12
    # the JDBC URL; the database is called Hotel2
    url: jdbc:mysql://localhost:3306/hotelmanagement  

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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <prerequisites>
        <maven>3.0.0</maven>
    </prerequisites>

    <groupId>com.drivedge</groupId>
    <artifactId>hotel2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>HotelMgnt</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <dropwizard.version>0.8.2</dropwizard.version>
        <mainClass>com.drivedge.hotel2.HotelMgntApplication</mainClass>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
            <version>${dropwizard.version}</version>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-hibernate</artifactId>
            <version>${dropwizard.version}</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>2.5.1</version>
</dependency>
<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>javax.persistence</artifactId>
    <version>2.0.0</version>
    <scope>compile</scope>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>${mainClass}</mainClass>
                        </transformer>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    </transformers>
                    <!-- exclude signed Manifests -->
                    <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>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <reportPlugins>
                        <plugin>
                            <artifactId>maven-project-info-reports-plugin</artifactId>
                            <version>2.4</version>
                            <configuration>
                                <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                                <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
                            </configuration>
                        </plugin>
                        <plugin>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <version>2.8.1</version>
                        </plugin>
                    </reportPlugins>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

my configuration file :-

package com.drivedge.hotel2;

import io.dropwizard.Configuration;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.db.DataSourceFactory;
import javax.validation.Valid;
import javax.validation.constraints.*;
//import org.apache.tomcat.jdbc.pool.DataSourceFactory;

public class HotelMgntConfiguration extends Configuration {
    /*// /**
    * A factory used to connect to a relational database management system.
    * Factories are used by Dropwizard to group together related configuration
    * parameters such as database connection driver, URI, password etc.
    */

   @NotNull
   @Valid
   @JsonProperty
   private DataSourceFactory database;

   /**
    * A getter for the database factory.
    *
    * @return An instance of database factory deserialized from the
    * configuration file passed as a command-line argument to the application.
    */

   public DataSourceFactory getDataSourceFactory() {
       return database;
   }

   public void setDatabase(DataSourceFactory database) {
        this.database = database;
    }
}

Where am I going wrong? I'm really new to all this Dropwizard stuff. Any help would be greatly appreciated!

1
Afte the edit config.yml still contains the problem entry logging:. Also consider asking another question and mark the answer that helped as accepted. This a question and answer site. By editing the same question and not marking the helpful answers you don't award the person that helped you. - zloster
If you have a different but related question, Please ask a new one, instead of editing the same one. On Stack Overflow we need each post to stand on its own. I've rolled back the edit for you. - Bhargav Rao

1 Answers

3
votes

Remove logging: from config.yml or configure logging like in example.