I am developing a web application, using Eclipse + Web Tools Platform + Kotlin plugin.
In the “Web Deployment Assembly” setting, I added the source folder of the Kotlin source files, but when I publish this web app to the Tomcat server, only the *.kt source files are deployed, but the *.class files are not.
Then I added the whole [Kotlin Runtime Libary] to the “Web Deployment Assembly” setting, and try to publish this project, this time I got a “java.io.FileNotFoundException: C:\MyWebApp\kotlin_bin” error.
Now I can not run my web app in Eclipse, because not class files are deployed.
In the last post, I said that if I added the [/kotlin_bin] folder into the setting file [.settings/org.eclipse.wst.common.component], the Kotlin class files in the [/kotlin_bin] folder will be deployed into the Tomcat Server
But new problem happened.
The class files in the [/kotlin_bin] folder contain only the class and method declaration information, but the implementation code are not generated in these class files.
So, even these class files are deployed into the Tomcat Server, When I try to start the Tomcat Server, these incomplete class files will cause a java.lang.ClassFormatError with the following error message:
Absent Code attribute in method that is not native or abstract in class file xxxx/xxxx/xxxx
If I run a console app from my project, the kotlin plugin will compile source files and generate class files, then I can copy these class files to the Tomcat Server manually.
But this is very inconvenience because I have to do it over and over again in my development process.
How can I deploy the Kotlin class files of my Web application to the web app server automatically?
This issue actually effects WebSphere Liberty publishing as well. The other problem I have is that configuration file in .settings is going to get overwritten by M2E-WTP integration.
In the end I just reverted all the Koltinization to use Java except for the JUnit tests which still work in WebSphere Liberty within Eclipse.
This is major issue while using Kotlin in Eclipse, Most of my team members use Eclipse for their development,
Because of these build related issues we have to move back to Java
I think Kotlin itself is a very great language, much more better than Java.
Since this issue is a problem about the development tools, but not the language it self,
so I think it may be better if you change the tools, for example, using IntelliJ IDEA, which is made by JetBrains, the same company who made Kotlin language.
IntelliJ IDEA has 2 edition:
the Community edition is free, the Ultimate edition cost money, but you can use it for like 1 month as Free trial.
Hey,
I agree Kotlin is better language compare to Java, but dev tools are also very important. Eclipse provides much more functionality compare to community addition of Kotlin,
Also we have a team of around 10 people I don’t think it will be feasible for us to buy IDEA Ultimate edition.
IDEA EAP edition is a good choice and we will try to evaluate this.
By the way, I suggest you to use JetBrains Toolbox.
It can help you to download and update to the latest version of InteliJ IDEA (and many other IDEs)
Also, you can select using EAP edition in the setting dialog.
(1)Create a Kotlin main class, for example:
fun main(args: Array) {
println(“Hello, world!”)
}
(2)Right click this main class, and select “Run”=>“Kotlin Application”
This will make the Kotlin plugin compile all the Kotlin source files, and generate class files.
(3)Deploy your web app to the App server, but use the outputed class folder instead of the source folders.
for example, if the “output folder” of your app is “var/classes”, you can deploy it to the App Server,
like this, in the WTP setting file [.settings/org.eclipse.wst.common.component] :