I have an issue with logging in a maven plugin for my applicaton. The maven plugin uses log4j with slf4j as facade, and I have configured (in the plugin) a special file logger for outputs.
When I run my plugin application (local, not as a plugin), the output is written to the file as intended.
However, when I use the maven plugin in another project and build it with mvn clean install, the output is only on the console. It seems not to be a problem of configuration as I do find my logger and (file-)appender.
My assumption is that maven absorbs the slf4j output to display it on its own console. Can anybody confirm or determine this respective tell me how to fix it? I appreciate any help.
It would be helpful to see your actual POM file. However, there are a few potential problems that I know about.This dependency is required because the
The maven-javadoc-plugin:2.10.3 has a dependency on maven-core:2.2.1, which has direct or indirect dependencies on sl4j-nop:1.5.3 and slf4j-jdk14:1.5.6. I introduced a dependency on maven-core:3.3.9, which didn't have this problem. The artifact maven-javadoc-plugin:2.10.3 also has a dependency on log4j:log4j. I placed an exclusion on the dependency for maven-javadoc-plugin so that it didn't include log4j:log4j.
See https://bradleyaross.wordpress.com/2016/05/05/java-logging-frameworks/ and the referenced GitHub libraries, especially the pom.xml files for the parent module and tutorials-common.
Related
We migrated our maven code to gradle. When we build, we are getting error as Could not resolve all files for configuration ':***-war:compileClasspath'.
Could not find mockito-core.jar (org.mockito:mockito-core:2.8.9).
We are not referring to this jar itself.. neither we are able to locate in our code nor in pom...
How to figure out?
how to configure gradle to compile code if jar doesn't exist and pom exists in the repository or locally ?
If you can't work out where it's coming from and you don't use it at all, then you can exclude the dependency from all the configurations:
configurations.all*.exclude group: "org.mockito", module: "mockito-core"
If the dependency isn't appearing in the dependency report, then I'm somewhat at a loss as to why Gradle is complaining about it. The only other option I can think of is that some plugin is adding it in a non-standard way.
I have a rest service running on dropwizard. Dropwizard requires slf4j to be configured with logback. When launching this service directly from my maven project in eclipse, the service starts up with the proper logback binding. When I do a maven package with the maven shade plugin, however, the resulting jar is still pulling log4j onto the classpath, which is resulting in slf4j choosing org.slf4j.impl.Log4jLoggerFactory instead of the logback binding.
I have made sure to exclude every transitive instance of log4j in my pom, as well as slf4j-log4j12 (mvn dependency:tree shows neither of these in my hierarchy), yet somehow it still always shows up in my uber jar after running mvn clean package.
How can I figure out what is causing log4j to always exist on my classpath?
I'm working in eclipse and I have a problem that I can't import my personal java libraries.
I created the libraries and 'installed' them into my local maven repo (using mvn install). This created a subdirectory related to the 'version' name that was in the POM file from when I ran the command. Which seemed fine.
So in this directory there where the usual jar files and other stuff.
When I released this file I manually changed the name of the version in the POM. going from 0.0.1-SNAPSHOT to 0.0.1-RELEASE
This seems to have worked as I would have expected.
However I can't seem to find import the new release jar.
Using the maven repositories browser in eclipse I can see that the new artifact is in the 'local' repository.
I try to add the dependency in the following methods:
Select the main project -> Maven -> add dependency.
This adds the dependency details into the pom but with a type value detail of <type>pom.lastUpdated</type>
Select the project pom.xml file -> Maven -> add dependency.
This time the artifact for the 0.0.1-RELEASE is greyed out I can select it, but I guess nothing is actually happening.
The original 0.0.1-SNAPSHOT it selectable, and if I use this I do not have a <type> detail in the pom.
I don't understand why there is a difference in the RELEASE and SNAPSHOT artifacts, as they have both been generated in the same way, and clearly they are both visible in the browser, the contents of the directory on disk are the same. The file names and contents are identical with the exception of the word RELEASE or SNAPSHOT.
I know that I can simply add in the RELEASE jar to my build path, but this seems to be a ridiculous thing to have to do if I intend to use maven (or do I need to do this).
I don't want to use an external repo for storing my artifacts, and I'm not too keen to go to the trouble of installing nexus (or similar) on my local machine (just because I've had trouble with it in the past).
What am I missing so as I can get my maven project to see my local repository and all its artifacts.
Thanks in advance.
David
ps I've already tried things such as mvn dependency:purge-local-repository which definitely pulled in / updated all the local jar dependencies.
So I've managed to work around my problem.
As such this solution is ridiculous, and breaks all the purpose of maven.
So I found (from running maven from the cli) that there was an error in the parent of the project I was attempting to use.
The parent was missing a direct link to the scm plugin (version error).
Once I solved this problem, I then returned to the sub project, and got a lot of errors from missing stuff from the parent.
Essentially it was not 'seeing' all the log4j dependencies.
The solution (well non-solution really).
Add all the log4j dependencies to the sub project.
Edit in SCM and surefire test plugins (as it also started to fail the test code due to missing junit).
So this is great.
I have to define all my dependencies on log4j and in my sub / child project's pom.xml file.
I also need to define them all in my parent's pom.
As it then still refused to run tests in my new project (that used the above as a dependency), and refused to find log4j also. I then decided to add all of these as dependencies for my current project.
Great.
I thought the whole point of maven was I could define my dependency on log4j in my my logging library that I use (which is the dependency), and then it would 'automagically' pull in all the required from this dependency.
Clearly not.
As stated at the start. This is NOT AN ANSWER it is a crazy work around.
My logging library that I use should be able to define its own requirement on a specific log4j version (such as moving from log4j to log4j2), and then when I include this as a maven dependency any change to the required dependency should be seen automatically.
But No : I have to import the dependency on log4j in my other projects also. So now if I had updated my logging library from log4j to log4j2 I would need to go to all my project that use this library and update their pom's to ensure that I have the correct version of log4j.
Seems the whole point of maven has just been lost!
Can someone please tell me where I am going wrong!
David.
I'm trying to override a dependency version through a maven profile. I did a test installing the war and it works. The problem is when I run the war using maven tomcat plugin. I wanted to check which version of the jar is used, but I have no idea where it reads the jars from. I cannot find anything useful on available documentation..
Any help?
I believe this page will help you to understand: http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/adjust-embedded-tomcat-version.html
Use the dependencies section in plugin section
HTH
I am confused why my web application is getting a Jar in its Maven Dependencies even if I think its not on the pom.xml file.
Here's my complete pom.xml which the applications gets objectify-2.2.3.jar
However I need to put a new version of this jar and I am not sure why my application gets this jar.
Do just a
mvn dependency:tree
on the console and check the output.
I suppose this jar is referenced by one of your direct dependencies.
Some IDEs can show the full dependency tree. I know this could be done with IntelliJ IDEAs maven view. I think Eclipse has a similar view.
There is also a maven plugin for this.