Why I can't build hibernate-orm from source code? - java

Following the Quickstart of the ReadMe file of Hibernate library,
I came across the following problem when trying to run this piece of code:
./gradlew clean build
org.hibernate.test.type.TimeAndTimestampTest > test FAILED
java.lang.AssertionError at TimeAndTimestampTest.java:47
org.hibernate.test.timestamp.JdbcTimeDefaultTimeZoneTest > testTimeZone FAILED
java.lang.AssertionError at JdbcTimeDefaultTimeZoneTest.java:83
5335 tests completed, 2 failed, 209 skipped
:hibernate-core:test FAILED
:hibernate-core:buildDashboard
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':hibernate-core:test'.
A build operation failed.
Could not write XML test results for org.hibernate.test.annotations.derivedidentities.e3.b3.DerivedIdentityEmbeddedIdParentEmbeddedIdGrandparentEmbeddedIdColumnOverridesDepTest to file /home/liver/Documents/repos/hibernate-orm/hibernate-core/target/test-results/TEST-org.hibernate.test.annotations.derivedidentities.e3.b3.DerivedIdentityEmbeddedIdParentEmbeddedIdGrandparentEmbeddedIdColumnOverridesDepTest.xml.
To build the project I used this workaround:
./gradlew build -x test
However, this isn't appropiate since it skips all the tests while building.
When I try to run that specific test TimeAndTimestampTest.java on IntelliJ I get the following:
Screenshot of the failed test
Apparently,the source code doesn't recognize the following route to import the missing libraries:
org.hibernate.jpamodelgen.xml.jaxb.*
How can I solve this problem?

Related

Integration with JIB Gradle cause compilation error

Tring to integrate with JIB (Containerize your Gradle Java project) with my Java project.
Following this documentation: https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin
Added the following to my project:
dependencies {
classpath("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.1.4")
}
apply plugin: 'com.google.cloud.tools.jib'
jib.to.image = 'my-docker-local/my-app'
Gradle version is: 5.6.4
The compilation with "./gradlew" build is working fine. but, when
excecuting "gradle jib" getting the following error:
gradle jib To honour the JVM settings for this build a single-use
Daemon process will be forked. See
https://docs.gradle.org/7.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
FAILURE: Build failed with an exception.
Where: Build file '/Users/igorgumush/dev/java11/my-service/build.gradle' line: 139
What went wrong: A problem occurred evaluating root project 'my-service'.
Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web,
build_9nl2gys0kuhc8m4mdlq51u41r$_run_closure4$_closure24#6ea6088b] on
object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 8.0.
Well the solution was very simple.
I used:
./gradlew jib
instead of
grade jib

java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor when manually building the plugin

I am trying to use JaCoCo code coverage plugin (3.0.4) in Jenkins (2.138.2). It works as expected, but what I don't like about it is that it does not generate the report when the build is either failed or aborted. This code is here: https://github.com/jenkinsci/jacoco-plugin/blob/master/src/main/java/hudson/plugins/jacoco/JacocoPublisher.java#L585-L587
There is a pull request for this, but looks like it didn't get worked on after its original creation.
So I tried to rebuild the plugin myself with next steps:
Clone https://github.com/jenkinsci/jacoco-plugin
Checkout the latest version 3.0.4
Remove the if statement from above in JacocoPublisher class
Build the plugin (mvn package as they say)
I am able to build it with no problems. The next steps are:
Navigate to Jenkins -> Manage Jenkins -> Manage Plugins -> Advanced
Upload the generated jacoco.hpi file and restart Jenkins
After this is done, the Post Build step to run JaCoCo reports disappears, and I see this in jenkins logs:
06-Nov-2018 17:19:24.353 WARNING [Handling GET /jenkins/job/testing-jacoco-code-coverage-reports/configure from 0:0:0:0:0:0:0:1 : http-nio-8080-exec-3 Job/configure.jelly Project/configure-entries.jelly] hudson.ExpressionFactory2$JexlExpression.evaluate Caught exception evaluating: i.descriptor in /jenkins/job/testing-jacoco-code-coverage-reports/configure. Reason: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor
at jenkins.model.Jenkins.getDescriptorOrDie(Jenkins.java:1517)
at hudson.tasks.Publisher.getDescriptor(Publisher.java:122)
at hudson.tasks.Recorder.getDescriptor(Recorder.java:51)
at hudson.plugins.jacoco.JacocoPublisher.getDescriptor(JacocoPublisher.java:775)
... 168 more
The solution for this issue proposed by Jenkins is not applicable here since the plugin already extends the required classes.
Reverting to previous version (3.0.4 but not of my custom build) makes the build step appear again, but again, is lacking the behavior I need.
Am I missing anything?
Thank you!
After removing the original version, I had to also delete the remaining jacoco plugin files from the /plugins folder. After that, installation went fine.

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default)

I am trying to package my mavenized project, but it always bring up an error. I have tried various things to resolve it,still yet, the problem remains the same.
This is the error I usually get when trying to package my project:
ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default) on project mymodule-omod: Command execution failed. Cannot run program "bower" (in directory "C:\Users\osagie\Documents\GitHub\mymodule\omod\src\main\webapp\resources\scripts"): CreateProcess error=267, The directory name is invalid -> [Help 1]
Attached is the project structure:

How to solve Jenkins build error on recording test results?

After all the successful steps of my Jenkins build I get an error:
Recording test results
"ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
hudson.AbortException: No test report files were found. Configuration error?"
I tried to search the answer in Jenkins documentation and on stack-overflow, however I didn't find any answer.
If you use behat3, then make sure that its version has junit formatter support, as it was missed in early versions https://github.com/Behat/Behat/pull/676
Also check that you have configured profile at behat.yml
behat 2
jenkins:
formatter:
name: pretty,junit
parameters:
output_path: ,build/logs/behat
behat 3
jenkins:
formatters:
junit: [build/log/behat]
Also build.xml must call it as "behat --profile jenkins"
I may assume that you have configured your test result path not to be related to Jenkins workspace (usually, this is the directory which you run tests from). JUnit result xml path should be configured in relation with Jenkins workspace directory, which is the root directory for you xml reports.

Building a distribution with dependencies for Spring framework

I learning Spring development and trying to configure the Spring framework step by step following a project on Github (the website is: https://github.com/spring-projects/spring-framework/wiki/Building-a-distribution-with-dependencies). After typing in the command $ ./gradlew depsZip to Run the depsZip gradle task . the following information was shown with a failure:
:spring-aspects:compileJava
Download http://repo.springsource.org/libs-release/org/aspectj/aspectjrt/1.7.1/a
spectjrt-1.7.1.jar
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\beans\factory\aspectj\AbstractBeanConfigurerAspect.
aj:1 [error] The type java.lang.CharSequence cannot be resolved. It is indirectl
y referenced from required .class files
[ant:iajc] (no source information available)
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\mock\staticmock\AbstractMethodMockingControl.aj:19
[error] The import java.util.Arrays cannot be resolved
[ant:iajc] import java.util.Arrays;
[ant:iajc] ^^^^^^^^^^^^^^^
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\mock\staticmock\AbstractMethodMockingControl.aj:87
[error] Arrays cannot be resolved
[ant:iajc] if (!Arrays.equals(this.args, args)) {
[ant:iajc] ^
[ant:iajc]
[ant:iajc] 3 errors
:spring-aspects:compileJava FAILED
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\aspects.
gradle' line: 30
* What went wrong:
Execution failed for task ':spring-aspects:compileJava'.
> compile errors: 3
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 42.798 secs
C:\Users\Zihan\Documents\GitHub\spring-framework [(abdcefb...)]>
could any help me with the configuration problem. really appreciate if giving some guidance.
Thanks in advance!
Firstly, why you can't use a dependency managment tool like maven or gradle? At your link I read
Although it is strongly recommended that Spring Framework users take advantage of the transitive dependency management features of build systems like Gradle, Maven, and Ivy, some teams cannot use these tools. This is usually due to corporate restrictions or working with legacy builds
Using tool defined above simply the build and the mantainence to a spring project. Then to start with a spring project you can following this Building Spring Project

Categories

Resources