Camel Compatibility issues - spring

I am using the following camel packages in my Maven project:
camel-core
camel-jms
camel-jaxb
camel-quartz
camel-bindy
camel-ftp
And when all these are using version 2.8.0 my server starts up fine and the app works ok. But if I update the camel version to anything higher like 2.10.0 then I get the following exception on startup and not sure which of these is causing this issue:
Caused by: org.apache.camel.TypeConverterLoaderException: Failed to load type converters because of: Cannot find any type converter classes from the following packages: [org.apache.camel.component.file.remote]
Any help would be much appreciated?

Maybe another library of your project is using a different version of camel.
You can check the camel dependency tree of your project with this maven command:
mvn dependency:tree -Dverbose -Dincludes=camel-core
In verbose mode, the dependency tree shows dependencies that were omitted for being a duplicate of another, conflicting with another's version and/or scope, and introducing a cycle into the dependency tree.
Here are some reference links:
https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html

Related

Adding org.apache.kafka to dependencies with Gradle

I started a Gradle project with gradle init --type java-application using Kotlin as the build script DSL, and I just wanted to add org.apache.kafka library
dependencies {
// This dependency is used by the application.
implementation("com.google.guava:guava:28.0-jre")
implementation("org.apache.kafka:kafka_2.10:0.8.0")
// Use JUnit test framework
testImplementation("junit:junit:4.12")
}
But gradle build returned this:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find jmxtools.jar (com.sun.jdmk:jmxtools:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
> Could not find jmxri.jar (com.sun.jmx:jmxri:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar
What's this about? Conflicts with JCenter?
As already mentioned in the comments upgrading the kafka version will solve the problem (probs go to #cricket_007).
The root cause for that problem is actually not kafka itself but it's transitive dependency log4j in a version 1.2.15. This log4j version requires jmxtools and jmxri. Due to some licensing issues these artifacts are NOT available on maven central and jcenter. The good news is: You most likely don't need it at all. You simply override the log4j dependency to use 1.2.16 (or above) or exclude jmxtools and jmxri.
You can also find some more insights in this blog article: http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/
So 3 ways to solve this issue:
use a more recent kafka-version OR
use a log4j version > 1.2.15 OR
exclude jmxtools and jmxri
Hope that helps and make things more clear

maven-enforcer-plugin complains about dependencies that I cannot find in pom.xml files

I am encountering a problem with the maven-enforcer-plugin. It is complaining with the following (simplified) output:
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.company.project:interfaces:1.0.4 paths to dependency are:
+-com.company.project:product:1.0.14-SNAPSHOT
+-com.company.project:some_part_A:1.0.0
+-com.company.project:interfaces:1.0.4
and
+-com.company.project:product:1.0.14-SNAPSHOT
+-com.company.project:some_part_B:1.0.0
+-com.company.project:some_sub_part_BB:1.1.0
+-com.company.project:interfaces:1.0.4
and
+-com.company.project:product:1.0.14-SNAPSHOT
+-com.company.project:interfaces:1.0.6
The problem is with some_sub_part_BB:1.1.0. According to the plugin, this part has a dependency on version 1.0.4 of the interfaces. But this is not possible: version 1.0.0 of some_sub_part_BB used interfaces version 1.0.3, and version 1.1.0 of some_sub_part_BB went directly to using interfaces version 1.0.6. I do not have any artifacts of some_sub_part_BB that uses version 1.0.4.
I guess I'm looking at some bug of the plugin, but I would like to debug this issue to make sure what is going wrong. Is this an issue anyone has encountered before, or can someone provide me any pointers on how to debug this problem? (I am fairly new to Maven, and aside from checking all the pom.xml files I have no idea where to look further).
Side note: The idea is (was) that the interface version to be used is specified on the project level POM, so that all (sub-) parts agree on which interface to use. However, as you can see, the different parts also specify which interface they use, which I don't think is the correct way of doing this. I haven't figured out how to fix this (yet).
Turns out that this is not a bug: in the pom.xml file, you can overrule versions of artifacts in the section dependencyManagement. In my case, someone enforced version 1.0.4 of the interfaces. The enforcer plugin does not show this; it only became apparent to me after generating the dependency tree with the verbose flag, i.e. mvn dependency:tree -Dverbose.

Grails 2.3.1 on Mac ; ClassNotFound NoUniqueBeanDefinitionException

Recently, I upgraded a Grails project to 2.3.1 from 2.0.1. The project runs fine on my Window's machine, and on my coworker's Mac (pulled via Git). On my Mac, though, I get this error when I try to run-app, after it finishes installing plugins and compiling:
ClassNotFoundException: org.springframework.beans.factory.NoUniqueBeanDefinitionException
The full stack trace is at http://pastebin.com/iEvKBmG5, but that's the crux of the error.
If I run grails in interactive mode, the server starts up, but when I browse to a controller, I just get a white page.
What could be different between my environment on my Mac and the environment on my colleague's that causes this error? Here's what I've tried in order to fix the issue:
Deleting the contents of my ~/.grails folder (as well as less extreme variants clearing particular subfolders)
Deleting the project and pulling it back from git
grails clean
Reinstalling grails 2.3.1 (using gvm, so the commands I ran were gvm uninstall grails 2.3.1, gvm flush archives, gvm install grails 2.3.1)
Cloning the project contents into a different directory
Checking my dependency report to make sure that the version of spring pulled is greater than 3.2.1, in which the NoUniqueBeanDefinitionException class was added. See http://pastebin.com/0AVC0SA0 for full report.
Verifying that the NoUniqueBeanDefinitionException.class file is inside the spring-beans jar, located at ~/.gvm/grails/2.3.1/lib/org.springframework/spring-beans/jars/spring-beans-3.2.4.RELEASE.jar.
grails refresh-dependencies myApplicationDependencies.xml Resulting file at http://pastebin.com/5bG9Vv78.
Manually deleted the 3.1.2 release of spring-beans and other spring jars from my maven repository, since that was being listed in the dependencies. Maven just re-resolves it though.
Switching the dependency resolver to ivy and getting a dependency report. The 3.1.2 version of Spring is listed as "evicted."
Both my colleague and I are running Mac OS X Mavericks and the latest version of Java. Any thoughts welcome.
UPDATE
I've also double-checked to make sure that my project doesn't contain duplicate classes. To do that, I ran grails dev war and used jar scan with the -double flag to search for duplicate classes. None were found.
Again, I am pretty sure the system isn't actually trying to throw a NoUniqueBeanDefinitionException. I think it's just trying to find that class and can't for some reason.
----------------------------------------------
Scanned archives: 2
Errors: 0
Archives with hits: 0
Maybe a problem with some file name upper/lower case. Check all source file names are correctly names (camel case) and there are not to file with the same name but different case
es:
Controllers/MyGreatController.groovy
Controllers/MygreatController.groovy
Failing that, take a look at the output of grails dependency-report. Make sure that the version of Spring that your project is pulling in is above or equal to 3.2.1, since that's the version of Spring where the NoUniqueBeanDefinitionException class was added. That class is in the spring-beans module. Also, make sure that none of your other dependencies are pulling in an older version of spring-beans.
If they are, you can tell Grails to ignore that transitive dependency with the excludes configuration option in BuildConfig.groovy. For example, let's say you're pulling in the activiti-engine jar from the mavenRepo "https://maven.alfresco.com/nexus/content/groups/public/". Change the dependency declaration to exclude spring-beans, and you should be right as rain.
compile("org.activiti:activiti-engine:5.13") {
excludes "spring-beans"
}
See http://grails.org/doc/2.3.1/guide/conf.html#dependencyResolution.
I had a dependency (activiti 5.13) that included and older version of the spring-beans module as a dependency of its own. For some reason, the version was winning out on my Mac, but was getting trumped on other workstations by the newer spring jar. The workaround was to exclude spring-beans from that dependency in my BuildConfig.groovy file.
...
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
compile("org.activiti:activiti-engine:5.13") {
excludes "spring-beans"
}
// runtime 'mysql:mysql-connector-java:5.1.16'
}
That prevents Grails from transitively resolving that particular dependency of my dependency.
See the information under Disabling transitive dependency resolution at http://grails.org/doc/2.3.1/guide/conf.html#configurationsAndDependencies.

Maven java compile error can not access CommonClassA

Background:
I am developing Maven multi module project.
One of the module is common module needed by other all modules.
This module contain CommonClassA.java.
common module is properly compiled.
It is installed into maven local repository properly.
One of the class(Billtype.java) in other module (EmployeeBilling) refers this class(CommonClassA.java).
Maven Dependency for common module is properly specified in pom.xml of EmployeeBilling module.
Problem:
While compiling EmployeeBilling module it throws
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project EmployeeBilling: Compilation failure
[ERROR] \MyWorkspace\Biz\EmployeeBilling\src\main\java\com\employee\Billtype.java:[79,19] error: cannot access CommonClassA
[ERROR] -> [Help 1]**
Supporting details:
dependency defined in EmployeeBilling> pom.xml:
Other classes from common module seems accessible as no error observed
There are no other errors like Class not found/file not found.
The class CommonCLassA implements Serializable
Same error occurs from Eclipse as well as commond line
I am using M2E plugin
Tools:
jdk1.7.0_02
OS: Windows 7
Eclipse JUNO and apache-maven-3.1.0
Thanks in advance!
If project builds properly using eclipse compiler then it should work with Maven.
Few things to check if its not working with maven:
Manually check in repository that jar is installed properly and it contains your class file.
Try to build project using locally installed Maven instead of maven in eclipse.
Set -DskipTest=true while installing your jar, as it can cause issues at times.
If these steps don't work then show us your pom.
With no more information it's hard to find the cause. But I also had this problems now and then, and there are some things which could go wrong:
Are you using the right JAVA version (everywhere) ?
... and the right java PROVIDER? (Oracle, IBM, OpenJDK) In my case it's often this issue, I'm sometimes bound to IBM JDK, although I try to use Oracle where I can and this sometimes breaks my build.
Is the right maven dependency VERSION used? If you depend on it multiple times, and all in the same (lower than root) dept of dependencies, Maven will just "choose" a version. It could be that thát version is incompatible with your code of thát particular dependency
Skipping tests sometimes WORKS! It has something to do with maven phases and getting stuff ready for using it elsewhere.
Good luck :)
I had the same problem. Even the jar dependency has the required class files. Finally I deleted the local maven repo and restarted the build. Now it worked without any issue.
It looks like you are using an old version of maven-compiler-plugin (v2.3.2).
I suggest you upgrade it to 3.x. it won't magically fix your issue but it will definitely give you better / more detailed error message.

Tomcat Jersey SPI Error

I have a Jersey (1.4) app deployed on Tomcat 5.5, when Tomcat starts up I can see its loading all the resources and providers. But as soon as I access any of the web services I get this strange error
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/Errors$Closure
I spent good long time finding out what's going on but had no luck.
I converted maven project into eclipse project using mvn eclipse:eclipse -Dwtpversion=1.5.
Any ideas?
I got this error when I also had a nuxeo related dependancy in my maven pom.xml, which itself has a dependency on jersey libraries, but at an earlier version (1.1.5 to be specific).
I changed the pom to depend on the latest version of jersey-core, jersey-server and jersey-client dependencies and ran mvn eclipse:eclipse and the problem went away!
There must have been a class clash involved.

Resources