Open jdimeo opened 6 years ago
Thanks! I was able to reproduce the error with the Eclipse Java compiler. I've added a Maven profile for compilation with it: https://github.com/arteam/dropwizard-nologback/commit/fc0a613dc367444a56ac96cbd51964530b2c9273 and got the same result as you. I will think about a fix in Dropwizard 1.2.* for this issue, because right now it seems the framework relies on implementation-specific behavior in the javac compiler.
Ahhh.. I failed to clean first before running mvn test
, so I understand now! if I compile with standard javac, it works, if I compile with Eclipse (which I realized I can even embed Eclipse-compiled classes in a maven jar if I don't clean before mvn install
) I can break it because of Eclipse-specific compilation behavior. Fascinating! I haven't come across this kind of thing before (usually the compiler differences are immaterial as an "end user" of these kinds of frameworks/libs).
Would using the fully qualified class name for Level
instead of an import at the top of the class be a sufficient work around?
Update: I cloned Dropwizard, removed all classic logback imports at the top of Application and BootstrapLogging and used fully qualified class names, mvn install
ed Dropwizard 1.2.1-SNAPSHOT locally and pointed this example app to those .jars, and Eclipse still appears to be throwing the error, so that didn't appear to be a valid workaround.
@arteam Download the demo dropwizard-nologback, running in eclipse IDE. Build is failing.
The project was not built since its build path is incomplete. Cannot find the class file for ch.qos.logback.classic.Level. Fix the build path then try building this project The type ch.qos.logback.classic.Level cannot be resolved. It is indirectly referenced from required .class files
The type ch.qos.logback.classic.Level cannot be resolved. It is indirectly referenced from required .class files
Yes, I am aware of that issue. Maybe we can fix it in Dropwizard 2.0.
Thanks @arteam for the update
@arteam @jdimeo I have migrated from maven to gradle project. It's working with eclipse. Also switched to log4j 1.x due to my project req:.
Here is the buld.gradle file apply plugin: 'java'
sourceCompatibility = 1.8
project.ext { dropwizardVersion = '1.3.0' }
repositories { mavenCentral() }
dependencies {
compile ("io.dropwizard:dropwizard-core:$dropwizardVersion") {
exclude group: 'org.eclipse.jetty.orbit'
exclude group:"ch.qos.logback", module:"logback-core"
exclude group:"ch.qos.logback", module:"logback-classic"
exclude group:"ch.qos.logback", module:"logback-access"
exclude group:"org.slf4j", module:"log4j-over-slf4j"
}
compile "log4j:log4j:1.2.17"
compile "org.slf4j:log4j-over-slf4j:1.7.21"
testCompile "io.dropwizard:dropwizard-testing:1.3.0"
}
@arteam My logs are still not going to file appender with nologback dependencies exclusion. It only logs one message "2018-06-26/12:39:19.693/PDT INFO [main] [] [org.hibernate.validator.internal.util.Version.
@arteam so this means Logback is mandatory for dropwizard as of now and we can't switch to something else, right? The documentation has details for specifying external logging. Is this still valid?
Getting build path issues while trying to Exclude Logback from the dropwizard-core artifact.
Any help is highly appreciated as I would need to use a separate logging framework in my application
For anyone else having the same problem as @reksomu371 described above, make sure to look at this project's pom.xml. In addition to excluding the logback dependencies from dropwizard as shown in their documentation, you need to add log4j dependencies. Your application may still run without the correct logging dependencies, but if you're missing anything like I was, you'll just see the one "Hibernate Validator" message come out wherever you've configured your appender to write to.
For more context, see https://github.com/dropwizard/dropwizard/pull/2112
When cloning this repo and running
mvn test
with no changes, there are test failures:Is it possible the specific version of Java I'm running is somehow "smarter" at realizing the class is missing even though it's not actually used or loaded? I imagine you would've experienced similar test failures but I can't figure out what's wrong on my end... thank you for your help and time on this!