"Generate Native Access" does not work (NoClassDefFoundError:)

70 views
Skip to first unread message

P5music

unread,
Aug 23, 2020, 6:18:24 AM8/23/20
to CodenameOne Discussions
I am adding some native iOS functionality to my CodenameOne app.
I am just at the beginning.
I created this Interface

import com.codename1.system.NativeInterface;

public interface VoiceInput extends NativeInterface {

    public boolean isSupported();

}

This is the bare minimum.
When I try to run "Generate Native Access" from the menu I get this, what's wrong? Thanks in advance.

-pre-init
Generating GUI sources
...
Processing GUI builder file: /home/pc/IdeaProjects/myappcp/src/com/myappcp/app/OneContainer.java
Attempting to generate GUI sources for /home/pc/IdeaProjects/myappcp/res/guibuilder/com/myappcp/app/OneContainer.gui with System JAXB
...
Processing GUI builder file: /home/pc/IdeaProjects/myappcp/src/com/myappcp/app/OneContainer.java
Attempting to generate GUI sources for /home/pc/IdeaProjects/myappcp/res/guibuilder/com/myappcp/app/OneContainer.gui with System JAXB
Failed to generate Gui Source with System JAXB.  Will attempt using bundled JAXB.
ago 23, 2020 10:02:55 AM com.codename1.build.client.GenerateGuiSources generateGuiSource
INFORMAZIONI: null
/home/pc/IdeaProjects/myappcp/build.xml:529: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
/home/pc/IdeaProjects/myappcp/build.xml:529: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
/home/pc/IdeaProjects/myappcp/build.xml:529: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
Ant build completed with 3 errors and 2 warnings in 1s at 23/08/20, 10:02

Shai Almog

unread,
Aug 23, 2020, 9:50:17 PM8/23/20
to CodenameOne Discussions
Which JDK/IDE combination are you using?

P5music

unread,
Aug 24, 2020, 4:45:36 AM8/24/20
to CodenameOne Discussions
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
IntelliJ IDEA 2020.2 (Community Edition)
Build #IC-202.6397.94, built on July 27, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-42-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 949M
Cores: 4
Non-Bundled Plugins: com.codename1.plugin.intellij
Current Desktop: ubuntu:GNOME

Shai Almog

unread,
Aug 24, 2020, 11:45:06 PM8/24/20
to CodenameOne Discussions
Thanks. Please file an issue on that. This is due to JDK 9's disastrous breaking down of the JVM. We still have a few dependencies left such as JAXB and JavaFX. Hopefully we'll be able to completely remove both. In the interim it seems that our workaround for the former failed on your setup.

Dave Dyer

unread,
Aug 25, 2020, 12:28:25 PM8/25/20
to CodenameOne Discussions
I think there's a problem if you have manually relocated some components - the "generate" code
uses some canned/expected paths instead of the actual classpath.   It will work if you stick
your native interface definitions into a virgin project.

P5music

unread,
Aug 26, 2020, 5:13:08 AM8/26/20
to CodenameOne Discussions
You seem to be right but I do not know what has been relocated. I do not think I relocated something, maybe I added some classpaths?
What could I have done?

Shai Almog

unread,
Aug 26, 2020, 10:28:34 PM8/26/20
to CodenameOne Discussions
Try creating a clean project and create a GUI builder form in that project. Then try to open it in the GUI builder and build it. This might trigger the jaxb download for that project and might let you generate a native interface there. I'm not sure if it will solve the other project but you might be able to use this as a workaround by copying the native code from there.

P5music

unread,
Aug 27, 2020, 4:32:07 AM8/27/20
to CodenameOne Discussions
What you both say works for a clean project but not for my app project. Those errors are issued and a pink message says "project needs to be compiled first"
Thanks

Dave Dyer

unread,
Aug 27, 2020, 11:53:53 AM8/27/20
to CodenameOne Discussions
Generate the template code in your clean project, copy to your actual project.  Problem solved until next time.

Shai Almog

unread,
Aug 28, 2020, 12:59:43 AM8/28/20
to CodenameOne Discussions
Do you use the GUI builder in the project?
Did you try it in the past?
That's probably the main difference as this bug relates to the GUI builder which is the only part that uses JAXB.

P5music

unread,
Aug 28, 2020, 4:18:50 AM8/28/20
to CodenameOne Discussions
No, I did not use that function at all in my project.

Shai Almog

unread,
Aug 29, 2020, 1:43:55 AM8/29/20
to CodenameOne Discussions
That is odd. Can you think of a reason why your project is different from the test project?

P5music

unread,
Aug 30, 2020, 11:23:58 AM8/30/20
to CodenameOne Discussions
The project was created before CEF update or other ones.
Do you think I have to create it again? What if I have to recreate it multiple times for every problem shows up?
Is it possible to "clean" the project somehow?

Shai Almog

unread,
Aug 31, 2020, 12:28:21 AM8/31/20
to CodenameOne Discussions
Did you send a build with the existing project?
If so it might be a new regression in behavior related to CEF. It's possible that the FX update system also solves the JAXB stuff so now that we don't have them we're failing on the jaxb side. This should be fixable although unfortunately not trivial.

P5music

unread,
Aug 31, 2020, 1:48:15 PM8/31/20
to CodenameOne Discussions
So do I have to do something or I have to wait, I did not understand.

Shai Almog

unread,
Aug 31, 2020, 9:34:30 PM8/31/20
to CodenameOne Discussions
Since this is a one time thing you have two potential workarounds:

- Use JDK 8 with Java FX (e.g. ZuluFX)
- Use the other project to generate the native code and copy the resulting files into the current project

Since generating native interfaces is a one time process you don't really need to do it often.
Reply all
Reply to author
Forward
0 new messages