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

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.

Related

Gradle in Spring Boot project not recognizing Java jdk in Path

I have a spring boot application where the gradle version is 7.0.
I had to change my openjdk 16 to openjdk 11 because I want to use keycloak with the project.
After I updated the Path, my java 11 gets recognized:
But my gradle is still stuck on the other version:
Edit: I have noticed that the error is in my build.gradle file:
Things I have tried:
restarting my pc
deleting cache folders for vscode
putting a JAVA_HOME into my path and link it and reverted it(I checked everytime with a new powershell window to make sure that it has updated and it always worked)
test another spring project (The other spring boot app does not have this gradle issue)
Anything else I can try?
I would look closely at the other spring boot app that does not have this gradle issue. VSCode has a habit of keeping cached versions of files around, but really you want the gradle files to be interrupted so it downloads new dependencies. I would look into that next, if you can't figure out what makes your other project work and this one not.

Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Setup:
Intellij IDEA community edition 2020.2
Spring Bott starter parent: 2.3.5
Java 11
WRAPPER_VERSION: 0.5.6
mvn 2
Hi,
I googled a lot e.g. here but I just can't fix it.
I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java.
e.g. It reports:
Cannot resolve symbol String
I tried:
invalidate caches and restart
delete .idea folder and reimport
checked sdk setup
mvn reimport
mvn clean and then rebuild (while the build is always successful)
I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.
UPDATE:
I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed
When I execute Analyze->inspect code I get the following:
I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.
IntelliJ Ultimate 2020.3
Spring Boot Starter Parent 2.4.2
Java 15
Maven 4.0.0
Maven Wrapper 0.5.6
The easiest solution is to generate your project again with Spring Starter.
After you set up everything you need at pom file -> Generate -> Download it.
Open with your IDE and copy-paste all code sources which you have already written.

pom error - org.apache.maven.archiver.MavenArchiver.getManifes

I am getting error in pom file - org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
in my pom i am using maven-war-plugin 3.0.0 , IDE- STS , java 7
encountered the same issue after updating the maven-jar-plugin to its latest version (at the time of writing), 3.0.2.
Eclipse 4.5.2 started flagging the pom.xml file with the org.apache.maven.archiver.MavenArchiver.getManifest error and a Maven > Update Project.. would not fix it.
Easy solution: downgrade to 2.6 version
Indeed a possible solution is to get back to version 2.6, a further update of the project would then remove any error. However, that's not the ideal scenario and a better solution is possible: update the m2e extensions (Eclipse Maven integration).
Better solution: update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to any of the following URLs:
https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/ or
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
Then follow the update wizard as usual. Eclipse would then require a restart. Afterwards, a further Update Project.. on the concerned Maven project would remove any error and your Maven build could then enjoy the benefit of the latest maven-jar-plugin version.
Additonal notes
The reason for this issue is that from version 3.0.0 on, the concerned component, the maven-archiver and the related plexus-archiver has been upgraded to newer versions, breaking internal usages (via reflections) of the m2e integration in Eclipse. The only solution is then to properly update Eclipse, as described above.
Also note: while Eclipse would initially report errors, the Maven build (e.g. from command line) would keep on working perfectly, this issue is only related to the Eclipse-Maven integration, that is, to the IDE.
Upgrade your m2e extensions instead downgrade.
(In Eclipse IDE) From Help > Install New Software.., add a new repository (via the Add.. option)
Specify name for your plugin and add path http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
once you are done with installation, please restart eclipse and update your project.

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.

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