Error trying to build a executable spring boot jar - activemq

I'm just trying to build a executable jar using Spring Boot, based on Joel example https://github.com/joeldudleyr3/spring-observable-stream, but I'm getting the following error:
exception is java.lang.NoSuchMethodError: org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration.getDefaultRoutingType()Lorg/apache/activemq/artemis/api/core/RoutingType;
at this line of code:
CordaRPCClient(rpcAddress).start(username, password)
Obs.: Invoking via JavaExec task it works perfectly.

It's a jar issue. which doesn't have this method. This method has been moved around look for this jar having package name as: org.apache.activemq.artemis. in client and common. not sure here but that's the culprit for you either go for version 1.X or 2.X just check which one has this method.
force compile to version 2.X for both client and common in your gradle file you will be good to go.

I fixed this by adding the following to my build.gradle file's dependencies block:
dependencies {
...
compile "org.apache.activemq:artemis-commons:2.0.0"
compile "org.apache.activemq:artemis-core-client:2.0.0"
...
}

Related

creating a Minecraft PVP client: error message when running minecraft [duplicate]

What are the possible causes of a "java.lang.Error: Unresolved compilation problem"?
Additional information:
I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process.
I would expect to see LinkageErrors or ClassNotFound errors if interfaces changed. The above error hints at some lower level problem.
A clean rebuild and redeployment fixed the problem. Could this error indicate a corrupted JAR?
(rewritten 2015-07-28)
Summary: Eclipse had compiled some or all of the classes, and its compiler is more tolerant of errors.
Long explanation:
The default behavior of Eclipse when compiling code with errors in it, is to generate byte code throwing the exception you see, allowing the program to be run. This is possible as Eclipse uses its own built-in compiler, instead of javac from the JDK which Apache Maven uses, and which fails the compilation completely for errors. If you use Eclipse on a Maven project which you are also working with using the command line mvn command, this may happen.
The cure is to fix the errors and recompile, before running again.
The setting is marked with a red box in this screendump:
try to clean the eclipse project
you just try to clean maven by command
mvn clean
and after that following command
mvn eclipse:clean eclipse:eclipse
and rebuild your project....
Your compiled classes may need to be recompiled from the source with the new jars.
Try running "mvn clean" and then rebuild
The major part is correctly answered by Thorbjørn Ravn Andersen.
This answer tries to shed light on the remaining question: how could the class file with errors end up in the jar?
Each build (Maven & javac or Eclipse) signals in its specific way when it hits a compile error, and will refuse to create a Jar file from it (or at least prominently alert you). The most likely cause for silently getting class files with errors into a jar is by concurrent operation of Maven and Eclipse.
If you have Eclipse open while running a mvn build, you should disable Project > Build Automatically until mvn completes.
EDIT:
Let's try to split the riddle into three parts:
(1) What is the meaning of "java.lang.Error: Unresolved compilation
problem"
This has been explained by Thorbjørn Ravn Andersen. There is no doubt that Eclipse found an error at compile time.
(2) How can an eclipse-compiled class file end up in jar file created
by maven (assuming maven is not configured to used ecj for
compilation)?
This could happen either by invoking Maven with no or incomplete cleaning. Or, an automatic Eclipse build could react to changes in the filesystem (done by Maven) and re-compile a class, before Maven proceeds to collect class files into the jar (this is what I meant by "concurrent operation" in my original answer).
(3) How come there is a compile error, but mvn clean succeeds?
Again several possibilities: (a) compilers don't agree whether or not the source code is legal, or (b) Eclipse compiles with broken settings like incomplete classpath, wrong Java compliance etc. Either way a sequence of refresh and clean build in Eclipse should surface the problem.
I had this error when I used a launch configuration that had an invalid classpath. In my case, I had a project that initially used Maven and thus a launch configuration had a Maven classpath element in it. I had later changed the project to use Gradle and removed the Maven classpath from the project's classpath, but the launch configuration still used it. I got this error trying to run it. Cleaning and rebuilding the project did not resolve this error. Instead, edit the launch configuration, remove the project classpath element, then add the project back to the User Entries in the classpath.
I got this error multiple times and struggled to work out. Finally, I removed the run configuration and re-added the default entries. It worked beautifully.
Just try to include package name in eclipse in case if you forgot it
Import all packages before using it, EX: import java.util.Scanner before using Scanner class.
These improvements might work and it will not give Java: Unresolved compilation problem anymore.
Also make sure to check compiler compliance level and selected jdk version is same
As a weird case, I encountered such an exception where the exception message (unresolved compilation bla bla) was hardcoded inside of generated class' itself. Decompiling the class revealed this.
I had the same issue using the visual studio Code. The root cause was backup java file was left in the same directory.
Removed the backup java file
When the build failed, selected the Fix it, it cleaned up the cache and restarted the workSpace.

java module-info.java with kotlin package

This is all I did:
open IntelliJ community version, create new JavaFX application, select Gradle build and Kotlin language.
just use default package names com.example.demo1
after project created, build
Now it reports error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\test\demo1\build\classes\java\main
Caused by: java.lang.module.InvalidModuleDescriptorException: Package com.example.demo1 not found in module
I noticed module-info.java is in java folder but all other source are in kotlin folder. Does that mean java file doesn't know the kotlin package?
If I remove module-info.java, it builds and runs. But module file is required to build artifacts, right?

IntelliJ Gradle "Unable to find Method"

The Error:
Failed to sync Gradle project '-'
Error:Unable to find method 'org.gradle.internal.logging.progress.DefaultProgressLoggerFactory.(Lorg/gradle/internal/logging/progress/ProgressListener;Lorg/gradle/internal/time/TimeProvider;)V'.
You can see, a constructor inside a class, which is found in the logging jar (gradle_home/lib/grade-logging-version.jar) is missing.
So, I think the Class-Path does not contain this jar file.
Gradle Version: 3.5
Running using the Command Line works.
I have already tried this:
Gradle sync failed: Unable to find method
to-find-method, it does not work for me.
I have tried to use different versions.
I can't see any difference when enabling
"Use default gradle wrapper"
"Use gradle wrapper task configuration"
"Use local gradle distribution".
I had the exact same problem today.
The only way I was able to get it to work was to remove my IntelliJ IDEA IDE, get the latest from the website (with JDK) and put it in a new folder (i.e. no overwriting existing files).
After that, I deleted the .idea folder from the project and reimported it cleanly into the "new" IntelliJ.
I suspect upgrading IntelliJ from Version <= 2016.x caused the issue, since a new installation / clean extraction from archive caused it to work on the fly.

IntelliJ Spring Boot: How to create an executable jar

I'm trying to create an executable jar from IntelliJ.
First I got the Java Security Exception and I changed sqljdbc4-4.0 to unsigned. First problem solved.
Then I got Manifest not found. Added META-INF dir to output. Second problem solved.
Next I got the BeanCreationException (unsolved):
Caused by: org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
In IntelliJ it is working.
I think the resources are not in the output. (application.properties, ...)
In which way do I add the resources or where are they stored in the jar.
I'm using gradle and on the spring boot homepage are only instructions for maven.
You should use spring-boot-maven-plugin or spring-boot-gradle-plugin, depending on your preferred build system.
EDIT:
Just run ./gradlew build
I suggest to dive into this getting started guide. It clarifies a lot of stuff for beginners.
A typical Spring boot project is a Maven project or a Gradle-Project (I only know how to do it with Maven, for Gradle see [luboskrnacs answer][1]). So you just need to run the maven targetpackageand pick the jar form the (created)target` folder
use a shell, go to the project root directory (where the pom.xml file is) and type
mvn clean package
cd target
the there is the xxx.jar file.

Idea not recognizing thrift types from another module in same gradle project

I have the following project structure
datatypes/
build.gradle
src/main/thrift/service.thrift
service/
build.gradle
/src/main/java/ServiceImpl.java
build.gradle
settings.gradle
I am using yodle/gradle as a gradle plugin to generate java sources from thrift and compiling those. The sources and jar files are being generated in datatypes as expected.
in service/build.gradle, I have a dependency defined as:
dependencies {
compile project(':datatypes')
}
Running gradle build works perfectly fine; my only issue is while working in idea. After importing this as gradle module, I can't get the types defined in thrift to be recognized in ServiceImpl.java.
How do I get idea to include the jar in datatypes/build/libs/ as dependency for service?
Thanks!
The issue really is that the default thrift generated java source path set by yodle/griddle plugin is inside the build/ folder. I just added the following in my datatypes/build.gradle
thriftGenDir = 'src/main'
and now the java code is generated in src/main/gen-java which is picked up as source for dataypes by idea, and uses it to define types for anyone who depends on datatypes.