grails2.5.0 Unable to download plugin dependencies - java

There are some problems when containerizing a Grails project. I have never contacted Grails before. This problem has troubled me for a long time. I hope you can help me solve it
grails-app/conf/BuildConfig.groovy:
grails.servlet.version = "2.5"
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.7
grails.project.source.level = 1.7
grails.server.port.http = 8080
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
inherits("global") {}
log "warn"
checksums true
legacyResolve false
repositories {
inherits true
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenRepo "our maven Repo"
mavenCentral()
}
dependencies {
compile group: 'com.ctrip.framework.apollo', name: 'apollo-client', version: '0.11.0-SNAPSHOT'
compile group: 'com.alibaba', name: 'dubbo', version: '2.6.0'
compile('org.apache.zookeeper:zookeeper:3.4.9') {
excludes 'slf4j-log4j12'
}
compile group: 'com.101tec', name: 'zkclient', version: '0.2'
compile group: 'com.google.guava', name: 'guava', version: '18.0'
}
plugins {
build ":tomcat:7.0.55.3"
runtime ":hibernate4:4.3.10"
runtime ":shiro:1.2.1"
}
}
When using the docker image proactivehk/grails:2.5.0 (image link) to package the project, the following error occurred
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.grails.plugins:hibernate4:zip:4.3.10, org.grails.plugins:shiro:zip:1.2.1: Could not transfer artifact org.grails.plugins:hibernate4:zip:4.3.10 from/to grailsCentral (https://repo.grails.org/grails/plugins): Received fatal alert: handshake_failure (Use --stacktrace to see the full trace)
DockerFile:
FROM proactivehk/grails:2.5.0
WORKDIR /app
COPY . .
CMD grails prod war
I also tried using the command grails -Dhttps.protocols=TLSv1.1,TLSv1.2 prod war
I can run or package this project normally in the local IDE (windows / IntelliJ IDEA), but I don't know why it can't work normally in the container.

Well I would say it's because Grails has removed all community plugins for 2.0 AND bintray is now offline as well... but if I say something like that they will delete this comment. ;)

Related

Gradle build fails java.security.NoSuchAlgorithmException: Error constructing implementation on raspberry running Ubuntu 20.04

I am trying to build an empty gradle application with the following build.gradle file.
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.json', name: 'json', version: '20220924'
implementation group: 'uk.co.caprica', name: 'vlcj', version: '4.8.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
test {
useJUnitPlatform()
}
When I try to build I get the following error:
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.json:json:20220924.
Required by:
project :
> Could not resolve org.json:json:20220924.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/json/json/20220924/json-20220924.pom'.
> java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
> Could not resolve uk.co.caprica:vlcj:4.8.1.
Required by:
project :
> Could not resolve uk.co.caprica:vlcj:4.8.1.
> Could not get resource 'https://repo.maven.apache.org/maven2/uk/co/caprica/vlcj/4.8.1/vlcj-4.8.1.pom'.
> java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 22s
1 actionable task: 1 executed
What I tried so far with no success:
add maven certificate to jvm cacerts
What I am using
gradle 7.4
jdk and jre 11
ubuntu 20.04 (raspberry aarch64)
The maven repo exists and I am a bit hopeless what should I do. Any suggestions?
Thanks in advance if you can help!
UPDATE:
As #dave_thompson_085 recommended, I ran the build with stacktrace and got the following error:
java.security.KeyManagementException: problem accessing trust store
Tried to reinstall java but the same problem exist.
If anyone runs into the same problem as me just set the variable for
javax.net.ssl.trustStore
to where your cacerts are located.
For me it was: /usr/lib/jvm/java-11-openjdk-arm64/lib/security/cacerts
If you don't want to add this parameter every time when you are trying to build here is a solid solution for that.

Heroku java app won't stay online for more than 90 seconds

I have been trying to get my discord bot (jda/gradle) online on heroku for quite some time now, the only thing that works for me is using a .jar file to get my bot online, but unfortunately it goes offline after 90 seconds, and the heroku logs give this:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
here is my build.gradle:
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
mainClassName = 'com.xlol.testbot.TestBot'
group 'com.xlol'
version '1.0'
sourceCompatibility = 16
repositories {
mavenCentral()
jcenter()
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
}
task stage(dependsOn: ['build', 'clean'])
build.mustRunAfter clean
dependencies {
implementation group: 'me.duncte123', name: 'botCommons', version: '1.0.45'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
implementation 'net.dv8tion:JDA:4.3.0_324'
implementation 'io.github.cdimascio:java-dotenv:5.1.1'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
}
compileJava.options.encoding = 'UTF-8'
my Procfile:
web: java $JAVA_OPTS -jar build/libs/HerokuTestBot-1.0-all.jar -Dserver.port=$PORT $JAR_OPTS
my system.properties:
java.runtime.version=16
server.port=${PORT:8080}
if you need anything else just ask for it, I have been trying to fix this issue for about 3 days now, any help would be appreciated, thanks in advance!
For people who want the answer (Credits to #Chris), this happened due to Heroku not being able to find a web application on the port "$PORT" (Variable by Heroku). This hosting requires a web port or application to access it through the website link.
However, in all cases. People will recommend you to use a VPS, or a hosting that supports Java hosting. (Example being: A host that hosts minecraft servers, because Minecraft runs on Java. || A host that supports Discord Bot Hosting in multiple languages, from NodeJS to Java)

How to fix jvm options exports javafx 11 to com.jfoenix on gradle idea?

It's been 3 days that I look on the internet how to fix this on gradle
Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix
On simple idea projects I was adding
--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix --add-exports javafx.controls/com.sun.javafx.scene.control=com.jfoenix --add-exports javafx.base/com.sun.javafx.binding=com.jfoenix --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix --add-exports javafx.base/com.sun.javafx.event=com.jfoenix
I know, I have to add jvm options but how do I ?
I'm using gradle javafx 11.0.2, java 11, on intellij idea,
this is the build.gradle
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
compileJava.options.encoding = 'UTF-8'
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/com.jfoenix/jfoenix
compile group: 'com.jfoenix', name: 'jfoenix', version: '9.0.9'
compile group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-9.1.2'
// https://mvnrepository.com/artifact/de.jensd/fontawesomefx-commons
runtime group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
// https://mvnrepository.com/artifact/com.h2database/h2
compile group: 'com.h2database', name: 'h2', version: '1.4.199'
}
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml','javafx.graphics','javafx.base' ]
}
mainClassName = 'org.yanisboukir.agence.Main'
Thanks
If you are running a non modular project (you don't have module-info.java), to include the VM arguments in your run task, all you need to add to your build.gradle file is:
run {
jvmArgs = [
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
"--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"
]
}
Note that in this case, you can't use --add-exports=...=com.jfoenix.
If you run a modular project, with a module descriptor like:
module hellofx {
requires javafx.controls;
requires javafx.fxml;
requires com.jfoenix;

opens org.openjfx to javafx.fxml;
exports org.openjfx;
}
now these are the VM arguments that you will have to include in your build file:
run {

 jvmArgs = [
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix"
]

}
For newer versions of Gradle (6.x) the following worked for me:
compileJava {
options.compilerArgs.add('--add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED')
}
For Java test code:
compileTestJava {
options.compilerArgs.add('--add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED')
}
Compile-time following:
compileJava {
options.compilerArgs.add('--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix')
options.compilerArgs.add('--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix')
options.compilerArgs.add('--add-exports=--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix')
options.compilerArgs.add('--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix')
}
Run-time following
run {

 jvmArgs = [
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix"
]

}
We must set both of them. If we only set the first one idea can compile, however at the run time throw exception. Thanks #sakra #José Pereda
this didn't work for me in JDK 16:
run {
jvmArgs = [
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
]
}
what worked instead is
run {
jvmArgs = [
"--add-opens=java.base/java.lang.reflect=com.jfoenix",
"--add-opens=java.base/java.lang.reflect=com.jfoenix",
"--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-opens=javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-opens=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
"--add-opens=javafx.base/com.sun.javafx.event=com.jfoenix",
]
}

Azure Pipeline Gradle build fails for Spring

Im trying to build and deploy a Spring API on Azure via a Yaml pipeline. But i get an error during the spring application gradle build saying.
Error: /home/vsts/work/1/s/gradlew failed with return code: 1
Could not find org.springframework.boot:spring-data-rest-hal-browser:
Expanding the Error,
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-data-rest-hal-browser:.
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 39s
1 actionable task: 1 executed
Error: /home/vsts/work/1/s/gradlew failed with return code: 1
at ChildProcess.<anonymous> (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.151.0/node_modules/vsts-task-lib/toolrunner.js:639:25)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:886:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
##[error]Error: /home/vsts/work/1/s/gradlew failed with return code: 1
##[section]Finishing: Gradle
Things i have tried.
I have tried changing specifying the versions of spring-data-rest-hal-browser in my project from.
compile("org.springframework.boot:spring-data-rest-hal-browser")
to
compile("org.springframework.boot:spring-data-rest-hal-browser:2.4.0.RELEASE")
and finally
compile("org.springframework.boot:spring-data-rest-hal-browser:3.0.8.RELEASE")
But still the same Error results
This is my current build.gradle file in my repo
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.test.spring.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.11'
repositories {
mavenCentral()
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-data-rest-hal-browser")
compile("org.springframework.data:spring-data-rest-webmvc:3.1.5.RELEASE")
}
And this is my current azure-pipelines.yml file
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: Gradle#2
inputs:
workingDirectory: '$(system.defaultWorkingDirectory)'
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'build'
- task: CopyFiles#2
displayName: 'Copy Files to: Wireframe Directory on development server'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- script:
cd '$(Build.ArtifactStagingDirectory)';
ls
- task: FtpUpload#1
displayName: 'FTP Upload: $(Build.ArtifactStagingDirectory)'
inputs:
credentialsOption: inputs
serverUrl: '[test server url]'
username: '[test username] '
password: '[test password] '
rootDirectory: '$(Build.ArtifactStagingDirectory)'
remoteDirectory: D:\home\site\wwwroot\webapps\ROOT\
preservePaths: true
I want to be able to automatically deploy my spring application to the server URL by pushing my code to it via the Azure devops pipeline which would build and deploy the spring application.
Thanks
So i resolved the issue by making some changes to the build.gradle file and build pipeline using help from the Microsoft Azure Repository for Intellij on Github: see here
My new build.gradle file looks like this:
plugins {
id 'org.jetbrains.intellij' version '0.4.1' apply false
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
}
/**
*This is task for update Gradle wrapper version.
*/
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}
apply plugin: 'io.spring.dependency-management'
group = 'com.test.spring.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
allprojects {
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
}
task unitTest(type: Test) {
exclude '**/ApplicationTests/**'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'org.springframework.data', name: 'spring-data-rest-hal-browser', version: '3.0.8.RELEASE'
compile("org.springframework.data:spring-data-rest-webmvc:3.1.5.RELEASE")
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
tasks.withType(FindBugs) {
ignoreFailures = true
reports {
html { enabled = true }
xml.enabled = !html.enabled
}
}
/**
* Preparing for release build
*/
task prepRelease() {
}
Also modified the azure-pipelines.yml file to include stacktrace and info to assist in debugging other gradle and build errors.
tasks: 'build --stacktrace --info'

RuntimeException: Sikulix fatal error: loadlib: opencv_java342.dll not in any libs folder

Project structure (full project can be downloaded here):
Launcher.java class:
import org.sikuli.script.Pattern;
public class Launcher {
public static void main(String[] args)
{
Pattern p1 = new Pattern(Launcher.class.getResource("sample.png"));
}
}
build.gradle file:
plugins {
id 'java'
}
group 'com.myproj'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "http://oss.sonatype.org/content/groups/public"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'com.sikulix', name: 'sikulixapi', version: '1.1.4-SNAPSHOT'
}
Program throws following runtime error:
loadlib: opencv_java342.dll not in any libs folder
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.sikuli.script.Pattern.<init>(Pattern.java:125)
at Launcher.main(Launcher.java:7)
Caused by: java.lang.RuntimeException: Sikulix fatal error: loadlib: opencv_java342.dll not in any libs folder
at org.sikuli.script.Sikulix.terminate(Sikulix.java:58)
at org.sikuli.script.RunTime.terminate(RunTime.java:60)
at org.sikuli.script.RunTime.libsLoad(RunTime.java:915)
at org.sikuli.script.RunTime.loadLibrary(RunTime.java:1105)
at org.sikuli.script.Finder2.<clinit>(Finder2.java:33)
... 2 more
Disconnected from the target VM, address: '127.0.0.1:9172', transport: 'socket'
Process finished with exit code 1
Interesting thing is that my code worked in the morning smoothly. And when I got back home in the evening something went wrong. Can't run it anymore.. Thank you for any help!
What I've tried:
reload sikulixapi package using Gradle from scratch
download 3.4.2 opencv and load it in runtime like suggested here
add opencv_java342.dll directly to the project as described here
even tried to launch the project on different Windows machine to exclude environment issues - still fails
It happened, that there was a bug in the latest snapshot. Full conversation with developers can be found here.
So, in this situation you have at least two options:
Wait until developers fix the issue and introduce new snapshot. Bugs/questions can be reported here.
Tell gradle/maven to use previous stable version of sikulixapi
library. Full list of currently available snapshots can be found here. Gradle example:
dependencies {
compile group: 'com.sikulix', name: 'sikulixapi', version: '1.1.4-20181214.081346-62'
}

Categories