Grails 2.3.1 on Mac ; ClassNotFound NoUniqueBeanDefinitionException - macos

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.

Related

How to fix CVE-2019-8457 vulnerability in Spring Boot

How to fix CVE-2019-8457 vulnerability in Spring Boot application, since none of my known dependencies includes SQLite3 in Spring Boot 2.6.6, jdk18-slim docker image
CVE-2019-8457
db5.3:5.3.28+dfsg1-0.8
HIGH
SQLite3 from 3.6.0 to and including 3.27.2 is vulnerable to heap out-of-bound read in the rtreenode() function when handling invalid rtree tables.
use alpine version of container images which mostly does not have high and critical vulnerabilities
Please inspect the dependency tree of your project to check if there is a transitive dependency defined on sqlite3. You may not be using sqlite3 directly in the project dependencies, there is a chance that some other library has defined it as a dependency.
For maven.
mvn dependency:tree
For gradle.
gradle dependencies
Once you find it, use exclusion pattern to exclude the older version of sqlite3 and explicitly declare a dependency of sqlite3 with the fixed version of sqlite3 version.

AEM Mocks missing artifact for latest version

I have added the latest version of AEM Mocks (2.7.2) as a Maven dependency in my AEM project. When I try to build my project, I get an error saying that this artifact cannot be found: com.day.commons:day-commons-gfx:jar:2.1.28. So I looked online, found it and added it as a dependency. But now I get the same error when trying to build. Does this artifact still exist? When trying various recent versions of AEM Mocks, I found that they all depend on this missing artifact.
For now, I downgraded to version 2.3.0, which works fine without that artifact but I would like to use the most recent version if possible.
Can anyone please help? Thanks!
This artifact is defined as a workaround, it is explained here in comment:
https://github.com/wcm-io/wcm-io-testing/blob/develop/aem-mock/core/pom.xml#L254:
Workaround for AEM 6.5: The new uber-jar does no longer contain the package com.day.imageio.plugins
It works without any issues for me, so I would check if you have correctly configured Maven repositories. To do it, in your Maven project root type:
mvn help:evaluate
and then:
${project.repositories}
It should list your project effective repositories. Ensure that there is Central Repository (https://repo.maven.apache.org/maven2/) listed. If it is there, then maybe your corporate network cuts requests to external repositories or it was temporarily down.

MULE 3.8.1 Hibernate 4.3.11 - org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile

I am developing an application for MULE ESB CommunityEdition (3.8.1 version).
I have included (provided by MULE) SPRING 4.1.6.RELEASE in project.
For persistence layer I set up Hibernate 4.3.11.FINAL.
My code is based on this idea (https://www.ricston.com/blog/jpa-mule/).
So basically i have included in the project (besides MULE dependencies):
hibernate-entitymanager (4.3.11.Final)
hibernate-core (4.3.11.Final)
hibernate-jpa-2.1-api (1.0.0.Final)
spring-orm (4.1.6.RELEASE)
And everything was working perfectly fine until i started to use Java 8 API...
Whatever I do: any lambda, stream or anything I am still getting error:
org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile
What I did until now:
tried to add org.javassist dependency (in version from 3.18.0-GA to 3-22.0-GA) - nothing happened,
tried to exclude org.reflections.0.9.9 dependency (mule is including that in some its core dependencies): also nothing happened
I spent on this about 5 hours I am really close to give it up... I really need hibernate cause this project will include many db operations
What else Can i Try to do?
Problem solved!!
I was using mvn dependency:tree to check if there are any org.javassist dependencies in project.
And there weren't...
Then I checked the folder: {mule_home}/lib/opt and there was an old version of org.javassist library!
So: I downloaded latest org.javassist jar and I put it in the {mule_home}/lib/user folder.
Now it works like a charm :)
Please check if your Anypoint Studio is pointing correct JDK.
Check below
Preference> Installed JRE >> It should have JDK 1.8 checked.

can't find my maven artifacts

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.

POM file for integrating Grails with Maven, with dependencies in BuildConfig.groovy

I've got a Grails application as part of a larger Java source bas that's all built with Maven. I'd like to include the Grails app in the Maven continuous integration, nightly builds, etc.
(Ideally I'd also like it to be part of a Maven parent-project hierarchy, so I could pick up live code changes from other projects without having to install them into my local repository. I would also like a pony.)
I tried running "grails create-pom", setting "pom true" in BuildConfig.groovy, and using the POM to manage my dependencies. However, this left me stuck in org.xml.sax.Locator classloader hell. So I went back to using BuildConfig.groovy for my dependencies.
I understand that "pom true" is a recent (Grails 2.1.0) feature, and it should be possible to integrate Grails into a Maven build while still managing dependencies in BuildConfig.groovy. Problem is, I can't find any documentation on what should go into the POM in that case. What do I put in my POM?

Resources