JBehave Serenity Jenkins issue - maven

I am trying to run Jbehave Serenity test in jenkins server but getting below error java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lorg.jbehave.core.reporters.Format; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lorg.jbehave.core.reporters.Format; is in unnamed module of loader org.apache.maven.surefire.booter.IsolatedClassLoader #7ef0e035).
Tried updating serenity plugins based on: Error while running JUnit Test, it did not resolve. We are still using Java 8

Related

Grails Example applications not working for Angular, Vue and React

I am in the learning process of Grails, and I have gotten the default example application HelloWorld work.
Running, building on Windows with WSL2 in OpenSUSE Leap 15.4.
Grails version 5.2.5
I then proceeded to try different profiles when creating the grails application, with Angular, React and Vue.
These did not go so well. Either something is missing from my configuration, JDK, Gradle, etc., and/or perhaps the generated projects need to be updated to use newer JDK and Gradle.
Perhaps I should report these problems on the Grails Profile GitHub.
https://github.com/grails-profiles/angular/issues
https://github.com/grails-profiles/react/issues
https://github.com/grails-profiles/vue/issues
Web
grails create-app grails-test-web --profile=web
Building and running the application works with both JDK-11/Gradle-7.2 and JDK-17/Gradle-7.6
Angular
grails create-app grails-test-angular --profile=angular
The project was created with Gradle-5.1.1, and I used JDK-11 to build it.
It will not build.
./gradlew bootRun --parallel
FAILURE: Build failed with an exception.
* Where:
Build file '/home/djviking/workspace/grails-test-angular/server/build.gradle' line: 19
* What went wrong:
A problem occurred evaluating project ':server'.
> Failed to apply plugin [class 'org.springframework.boot.gradle.plugin.SpringBootPlugin']
> Spring Boot plugin requires Gradle 6.8.x, 6.9.x, or 7.x. The current version is Gradle 5.1.1
Then I upgraded to Gradle 6.8.1, but that did not work either
> Configure project :server
Cannot resolve reloading agent JAR: Failed to resolve imported Maven boms: Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.7.5 because no repositories are defined.
Required by:
project :server
FAILURE: Build failed with an exception.
* Where:
Build file '/home/djviking/workspace/grails-test-angular/server/build.gradle' line: 19
* What went wrong:
A problem occurred evaluating project ':server'.
> Receiver class grails.util.Environment does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.
React
grails create-app grails-test-react --profile=react
The project was created with Gradle-6.9, and I used JDK-11 to build it.
It will not build/start
./gradlew server:bootRun
./gradlew client:start
Cannot resolve reloading agent JAR: Failed to resolve imported Maven boms: Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.7.5 because no repositories are defined.
Required by:
project :server
FAILURE: Build failed with an exception.
* Where:
Build file '/home/svmoe/workspace/grails-test-react/server/build.gradle' line: 20
* What went wrong:
A problem occurred evaluating project ':server'.
> Receiver class grails.util.Environment does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.
Vue
grails create-app grails-test-vue --profile=vue
The project was created with Gradle-6.9, and I used JDK-11 to build it.
It will not build the project.
./gradlew server:bootRun
./gradlew client:serve
> Configure project :server
Cannot resolve reloading agent JAR: Failed to resolve imported Maven boms: Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.7.5 because no repositories are defined.
Required by:
project :server
FAILURE: Build failed with an exception.
* Where:
Build file '/home/svmoe/workspace/grails-test-vue/server/build.gradle' line: 20
* What went wrong:
A problem occurred evaluating project ':server'.
> Receiver class grails.util.Environment does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.
Works with JDK 17, when I changed Gradle Wrapper to Gradle 7.6
./gradlew server:bootRun
I can access the URL, and I get a JSON structure.
Grails application running at http://localhost:8080 in environment: development
./gradlew client:serve
I can not access the URL from this. Neither on localhost.
App running at:
- Local: http://HOSTNAME:3000/
- Network: http://HOSTNAME:3000/

"mvn clean install" unable to resolve junit imports

I had written a JUnit test case for a Service class in Spring Boot web application.
I have spring-boot-starter-test in my pom.xml but when I run "mvn clean install" the junit related imports are not resolving. The error is as below.
cannot find symbol
[ERROR] symbol: class Before
[ERROR] location: package org.junit
maven build is failing with this error.
When I run build project in eclipse it is working fine as I've added the junit library in project build path. but maven build is failing.

Spring boot testing : NoClassDefFound exception

I'm using the latest version of Spring boot and an old test fails.
I'm having
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class
Caused by: java.lang.NoClassDefFoundError: MyClass
My config is
spring boot 2.7.2
gradle 7.5
a structure using idiomatic gradle (multiproject and composite build)
The subproject failing is the spring-boot-application. The class not found exists inside the src/main/java
The test failing is under src/test/java, annotated with
#SpringJUnitConfig(classes = ApplicationServiceAspectTestConfigSuccessListener.class) because it is using #Inject fields.
I understand it is not perfect (unit testing depending on injection ; prefer integration test)
When I debug this test, the classloader tries to use a JarLoader and searches inside the spring-boot-application-default.jar. The jar structure is BOOT-INF / META-INF / org... The class not found is inside the BOOT-INF/classes/org/xxxx. The jar loader failed :/
My question is : why searching inside the jar and not the build/classes/org/xxx ? and why is the JarLoader not finding the class ?
Update 1
I think I have a lead. I created a gradle precompiles quality plugins which uses java-text-fixtures. When enable the java-text-fixtures produces two jars and the problem comes from here.
I don't really understand why for the moment (why 2 jars and not only the text-fixtures one).
Update 2
Ok seems I ran across https://github.com/gradle/gradle/issues/11696

Why is `${maven.projectBasedir}/.mvn/jvm.config` taken into account only when the fork count is equal to zero during the tests?

I use Maven 3.8.1 and Maven surefire plugin 3.0.0-M5 with OpenJDK 16. .mvn/jvm.config contains --add-opens=java.base/java.lang=ALL-UNNAMED in order to fix the following error:
java.lang.reflect.InaccessibleObjectException: Unable to make
protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does
not "opens java.lang" to unnamed module #319aa9ee
Why do I need to pass -DforkCount=0 to Maven to make it work? .mvn/jvm.config seems to be ignored when I run mvn install alone without forcing the unforked VM. Is there a cleaner solution?
You can reproduce my problem by using the following project:
https://jogamp.org/cgit/ardor3d.git/
P.S: The problem is caused by EasyMock 4.3. It uses Objenesis under the hood which claims to support Java 16, it's supported with some tweaks, it's a known concern. sun.misc.Unsafe is mentioned but not the method above.
P.S 2: A stack trace mentions cglib which doesn't support Java 17 yet:
Caused by: org.easymock.cglib.core.CodeGenerationException:
java.lang.reflect.InaccessibleObjectException-->Unable to make
protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does
not "opens java.lang" to unnamed module #2064d52f
Reference:
https://maven.apache.org/docs/3.8.1/release-notes.html#JVM_and_Command_Line_Options

Could not find or load main class io.cucumber.core.cli.Main in spring boot Integration test

I am fairly new to gradle and Cucumber.
I am getting an error while running my project don't tried almost every combination of dependency but still no luck.
although it builds successfully as shown below but still getting Exception as Error: Could not find or load main class io.cucumber.core.cli.Main .
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
I believe by default Intellij creates a separate module per gradle sourceset, hence by default you will have a main module and a test module per project. Each module has its own classpath. It looks like you are trying to run test but with main module classpath, hence the class not found error.

Resources