Unable to compile/run when mix a jmix Java application with kotlin classes

Hello all,
I started generating a fullstack Java application, and when I first used a kotlin class, the project stops compiling with following error:

Caused by: java.nio.file.NoSuchFileException: /daten/workspaces/jmix/demo/build/tmp/entitiesEnhancing/main/persistence

My platform is:
The jmix-version is 1.4.2 with Amazon coretto java 11.
The database I am using is a mysql.
I am using latest the intellij 2022.3.1 Ultimate Edition

I tracked down the problem to the point when I first used kotlin. After that, the compile failed.
I also observed that the entities are not listed during compile-Time, as if there were none.

You can easily reproduce it with

  1. create new jmix project, full stack Java
  2. configure database and generate model from database, import an entity
    . compile and run-> OK

Here is the build.gradle from 1st, running version:


plugins {
    id 'io.jmix' version '1.4.2'
    id 'java'
}

apply plugin: 'org.springframework.boot'

jmix {
    bomVersion = '1.4.2'
}

group = 'com.company'
version = '0.0.1-SNAPSHOT'

repositories {
    mavenCentral()
    maven {
        url 'https://nexus.jmix.io/repository/public'
    }
}

dependencies {
    implementation 'io.jmix.core:jmix-core-starter'
    implementation 'io.jmix.data:jmix-eclipselink-starter'
    implementation 'io.jmix.ui:jmix-ui-starter'
    implementation 'io.jmix.ui:jmix-ui-data-starter'
    implementation 'io.jmix.ui:jmix-ui-themes-compiled'
    implementation 'io.jmix.ui:jmix-ui-widgets-compiled'
    implementation 'io.jmix.security:jmix-security-starter'
    implementation 'io.jmix.security:jmix-security-ui-starter'
    implementation 'io.jmix.security:jmix-security-data-starter'
    implementation 'io.jmix.localfs:jmix-localfs-starter'
    implementation 'io.jmix.datatools:jmix-datatools-starter'
    implementation 'io.jmix.datatools:jmix-datatools-ui-starter'

    implementation 'org.springframework.boot:spring-boot-starter-web'


    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'mysql:mysql-connector-java'
}

test {
    useJUnitPlatform()
}
  1. create a new kotlin class and configure kotlin for the project “as Kotlin Java with Gradle) module” run all imports for kotlin support
  2. after that, compile will fail with the error above (I added the complete console output at the end)

Here is the build.gradle after configuring kotlin

buildscript {
    ext.kotlin_version = '1.8.0'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
plugins {
    id 'io.jmix' version '1.4.2'
    id 'java'
}

apply plugin: 'org.springframework.boot'
apply plugin: 'kotlin'

jmix {
    bomVersion = '1.4.2'
}

group = 'com.company'
version = '0.0.1-SNAPSHOT'

repositories {
    mavenCentral()
    maven {
        url 'https://nexus.jmix.io/repository/public'
    }
}

dependencies {
    implementation 'io.jmix.core:jmix-core-starter'
    implementation 'io.jmix.data:jmix-eclipselink-starter'
    implementation 'io.jmix.ui:jmix-ui-starter'
    implementation 'io.jmix.ui:jmix-ui-data-starter'
    implementation 'io.jmix.ui:jmix-ui-themes-compiled'
    implementation 'io.jmix.ui:jmix-ui-widgets-compiled'
    implementation 'io.jmix.security:jmix-security-starter'
    implementation 'io.jmix.security:jmix-security-ui-starter'
    implementation 'io.jmix.security:jmix-security-data-starter'
    implementation 'io.jmix.localfs:jmix-localfs-starter'
    implementation 'io.jmix.datatools:jmix-datatools-starter'
    implementation 'io.jmix.datatools:jmix-datatools-ui-starter'

    implementation 'org.springframework.boot:spring-boot-starter-web'


    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'mysql:mysql-connector-java'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

test {
    useJUnitPlatform()
}
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

The console output is

10:57:22: Executing 'bootRun'

Starting Gradle Daemon
Connected to the target VM, address: '127.0.0.1:44849', transport: 'socket'
Gradle Daemon started in 1 s 228 ms
> Task :bootBuildInfo
> Task :processResources

> Task :compileKotlin
'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

Enhancing entities in root project 'demo' for source set 'main'
Project entities:
    JPA: [];
    DTO: [];
Project converters: [].
Running EclipseLink enhancer in root project 'demo' for source set 'main'
Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-40007] (Eclipse Persistence Services - 2.7.9.6-jmix): org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: An exception was thrown while weaving: [Ljava.lang.String;@4973813a
Internal Exception: java.nio.file.NoSuchFileException: /daten/workspaces/jmix/demo/build/tmp/entitiesEnhancing/main/persistence
	at org.eclipse.persistence.exceptions.StaticWeaveException.exceptionPerformWeaving(StaticWeaveException.java:140)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.main(StaticWeave.java:88)
Caused by: java.nio.file.NoSuchFileException: /daten/workspaces/jmix/demo/build/tmp/entitiesEnhancing/main/persistence
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
	at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
	at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
	at java.base/java.nio.file.Files.readAttributes(Files.java:1764)
	at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1259)
	at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:733)
	at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:850)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:248)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:177)
	at java.base/java.util.jar.JarFile.<init>(JarFile.java:350)
	at java.base/java.util.jar.JarFile.<init>(JarFile.java:321)
	at java.base/java.util.jar.JarFile.<init>(JarFile.java:287)
	at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:95)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveClassTransformer.buildClassTransformers(StaticWeaveClassTransformer.java:108)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveClassTransformer.<init>(StaticWeaveClassTransformer.java:78)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.process(StaticWeaveProcessor.java:252)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.performWeaving(StaticWeaveProcessor.java:174)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.start(StaticWeave.java:117)
	at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.main(StaticWeave.java:86)

> Task :compileKotlin FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':compileKotlin'.
> Process 'command '/usr/lib/jvm/java-11-amazon-corretto/bin/java'' finished with non-zero exit value 1

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 11s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
3 actionable tasks: 3 executed
Disconnected from the target VM, address: '127.0.0.1:44849', transport: 'socket'
10:57:34: Execution finished 'bootRun'.

Any idea?

Regards
Manfred

Hi,

There is an issue for the same problem. We’ll try to do something with it in the upcoming 1.5 release.

Hi,
thanks for the reply.
Then we have to wait until it’s fixed, if there is no workaround…

I looked at the problem again and it seems that it is not the issue I thought initially.

Try doing the following:

  1. Create a separate kotlin directory where all your kotlin sources will be
  2. Convert main spring boot application class (the one with the @SpringBootApplication annotation) from java to kotlin (that seems to be the reason of the error). Make sure that the class ant its members have the open keyword.
  3. If while running you have problems like spring cannot find the main class or similar, try renaming the main application class

image

Hi,
thanks for investigating.
I will check the workaround.

Hopefully you are still looking into fixing the main problem, since we are mainly implementing in java.
Regards
Manfred