Error on task packageDistributionForCurrentOS compose desktop

已回答

Hello, I have 2 PCs one at work and the other at home. I am using Github to sync my project between 2 PCs, when I click on task run or debug, everything works as it should on both PCs.

But the moment I click on task packageDistributionForCurrentOS at home I will get an error in seconds and it will not build:

Execution failed for task ':checkRuntime'.
> java.util.InvalidPropertiesFormatException: jdk.internal.org.xml.sax.SAXParseException;

and if I run it on a PC at work, it will create *.exe file, and install it but the database sqldelight not working, app crashes the moment I try to access database on cannot initialize class repository. (not my problem for now)

My problem is, why it will not create a distro on my PC and stop the task when I didn't use SAX Parser in my project. I dont even parse xml.

It looks like it's not in my project, but somewhere else.

I disabled all non-bundled plugins.

 

And also, today I found  out, I cannot update gradle to higher version than 7.5.1 when I try, everything breaks, cant even sync. Sync task ends in 1 second with only sync error.

 

IntelliJ IDEA 2023.3.2 (Community Edition)

Build #IC-233.13135.103, built on December 20, 2023

Runtime version: 17.0.9+7-b1087.9 amd64

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Windows 10.0

GC: G1 Young Generation, G1 Old Generation

Memory: 2048M

Cores: 12

Registry:

 ide.experimental.ui=true

Kotlin: 233.13135.103-IJ

 

Upload id: 2024_01_14_FKqL11TEFgjTmFaEE4X6iR (file: idea-logs-20240114-2210139685415891236896076.zip)


kotlin.version=1.9.21
compose.version=1.5.11
sqlDelight.version=2.0.1

build.gradle.kts:

plugins {
    kotlin("jvm")
    id("org.jetbrains.compose")
    id("app.cash.sqldelight")
}
repositories {
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    google()
}
dependencies {
    implementation(compose.desktop.currentOs)
    api(compose.material3)
    implementation("org.jetbrains.compose.material","material-icons-extended","1.5.11")
    implementation("app.cash.sqldelight","sqlite-driver","2.0.1")
    implementation("app.cash.sqldelight","app.cash.sqldelight.gradle.plugin","2.0.1")
    implementation("org.slf4j","slf4j-api","2.0.9")
    implementation("org.slf4j","slf4j-simple","2.0.9")
    implementation("org.jetbrains.kotlinx","kotlinx-coroutines-core","1.4.2")
    implementation("org.jetbrains.kotlinx","kotlinx-coroutines-android","1.4.2")
}
sqldelight.databases {
    create("Database") {
        packageName.set("data")
    }
}
compose.desktop {
    application {
        mainClass = “MainKt”
        nativeDistributions {
            targetFormats(TargetFormat.Exe)
            packageName = "RucniNaradiCompose"
            packageVersion = "1.0.0"
        }
    }
}	

 

error:

Caused by: jdk.internal.org.xml.sax.SAXParseException; 
    at java.base/jdk.internal.util.xml.impl.ParserSAX.panic(ParserSAX.java:652)
    at java.base/jdk.internal.util.xml.impl.Parser.step(Parser.java:499)
    at java.base/jdk.internal.util.xml.impl.ParserSAX.parse(ParserSAX.java:436)
    at java.base/jdk.internal.util.xml.impl.ParserSAX.parse(ParserSAX.java:411)
    at java.base/jdk.internal.util.xml.impl.ParserSAX.parse(ParserSAX.java:374)
    at java.base/jdk.internal.util.xml.impl.SAXParserImpl.parse(SAXParserImpl.java:97)
    at java.base/jdk.internal.util.xml.PropertiesDefaultHandler.load(PropertiesDefaultHandler.java:83)
    at org.jetbrains.compose.desktop.application.tasks.AbstractCheckNativeDistributionRuntime$getJDKRuntimeProperties$1.invoke(AbstractCheckNativeDistributionRuntime.kt:138)
    at org.jetbrains.compose.desktop.application.tasks.AbstractCheckNativeDistributionRuntime$getJDKRuntimeProperties$1.invoke(AbstractCheckNativeDistributionRuntime.kt:133)
    at org.jetbrains.compose.desktop.application.internal.ExternalToolRunner.invoke(ExternalToolRunner.kt:93)
    at org.jetbrains.compose.desktop.application.internal.ExternalToolRunner.invoke$default(ExternalToolRunner.kt:30)
    at org.jetbrains.compose.desktop.application.tasks.AbstractCheckNativeDistributionRuntime.getJDKRuntimeProperties(AbstractCheckNativeDistributionRuntime.kt:133)
    at org.jetbrains.compose.desktop.application.tasks.AbstractCheckNativeDistributionRuntime.run(AbstractCheckNativeDistributionRuntime.kt:81)

its continuing with lines of error code
    

0

Hello!

Thank you for reporting this!

Does the issue persists if you run the Task from OS' Command Prompt?

Would you be able to share the affected Project?

If the Project cannot be shared, please share the full build output (it looks like you are using Gradle, please specify --info for more detailed logging), including the full exception's stack trace.

0

Hello, it looks like, it was a Windows 10 → Intellij Idea problem that even a reinstall (multiple times) didn't solve. So today I reinstalled the whole Windows 10 (because of the inability to update gradle above 7.5.1 - the moment I tried, everything broke, even stooped syncing) and the problem is no more. Everything works, not everything, but it looks like a problem in my programming Compose Desktop.

When I run my project from task compose-run or debug, my app works fine. After packageDistributionForCurrentOS and install, the moment my view accesses database, the app crashes initialize class repository

in that class (part of it) it's SqLite

object Repository {
    private val database = MySqlController()

    fun getToolsPopis(): List<String> {
        val result = mutableListOf<String>()
        database.executeMySQLQuery( “SELECT popis FROM RucniNaradi;”) {
            while (it.next()) { result.add(it.getString(1))  }
        }
        return result
    }

}

and class MySqlController:

class MySqlController {
    private val runDir = System.getProperty("user.dir")
    private val dataDirectory = File("$runDir/data/")
    private val database = File("$runDir/data/sqDelight.db")
    private var conn: Connection? = null
    init {
        if (!dataDirectory.isDirectory) {  dataDirectory.mkdir()  }
        if (!database.isFile) {  database.createNewFile() }
    }
    private fun getConnection() {
        try { conn = DriverManager.getConnection("jdbc:sqlite:${database.path}") }
        catch (ex: SQLException) { ex.printStackTrace() }
        catch (ex: Exception) { ex.printStackTrace() }
    }
    fun executeMySQLQuery(sqlQuery: String, naradie: (t: ResultSet) -> Unit) {
        var stmt: Statement? = null
        var resultSet: ResultSet? = null
        getConnection()
        try {
            stmt = conn!!.createStatement()
            resultSet = stmt!!.executeQuery(sqlQuery)
            if (stmt.execute(sqlQuery)) {
                resultSet = stmt.resultSet
                naradie(resultSet)
            }
        }
        catch (ex: SQLException) { LOG.info("Chyba dotazu databáze: \n ${ex.message}") }
        finally { closeAll(stmt, resultSet) }
    }

I have tested with SqlDelight same problem and now Xerial SqLite same problem.

The moment function fun getToolsPopis() from object Repository is called app crashes.

How can I access log or something when it's running from *.exe on windows.

 

0

It's hard to determine the root cause without knowing your app closely, but it might be a good idea to try and add some extra try catch blocks and logging to Repository and MySqlController, so when the app crashes it would give you more information on what exactly has caused the crash.

0

Hello, and thanks.

I am starting to believe I am a total noob at programming, but after a long google session I found my solution to my second problem, after running task suggestRuntimeModules it is:

compose.desktop {
    application {
        nativeDistributions {
            modules("java.instrument", "java.sql", "jdk.unsupported")
        }
    }
}

And thanks for the logging advice.

 

And now I have one other question, is it possible to create *.exe but that requires no admin right to install?

0

请先登录再写评论。