Getting exception while creating and reading file

Hello MicroEJ team,

I’m trying to store a file in the simulator, I am using the MicroEJ version.

… |BOARD_NAME| replace:: STM32U5G9J-DK2
… |BOARD_REVISION| replace:: MB1918-U5G9ZJQ-A02
… |RCP| replace:: MICROEJ SDK
… |VEEPORT| replace:: VEE Port
… |SIM| replace:: MICROEJ Simulator
… |CIDE| replace:: MICROEJ SDK
… |RTOS| replace:: ThreadX
… |MANUFACTURER| replace:: STMicroelectronics
… |MICROEJ_ARCHITECTURE_VERSION| replace:: 8.1.0
… |MICROEJ_SDK_VERSION| replace:: 23.07
… |TOOLCHAIN| replace:: IAR Embedded Workbench for Arm
… |TOOLCHAIN_VER| replace:: 9.50.1

and below is a code from the foundation library that I am using and using the same configuration defined in the example below.

From this, I am getting the below exception:

Uncaught exception thrown in Feature demoapp (CN=com.is2t.feature.demoapp, OU=IS2T, O=IS2T, L=NANTES, ST=FRANCE, C=FR):
Exception in thread “com.is2t.feature.demoapp” java.lang.RuntimeException
at java.lang.Throwable.fillInStackTrace(Throwable.java:82)
at java.lang.Throwable.(Throwable.java:32)
at java.lang.Exception.(Exception.java:14)
at java.lang.RuntimeException.(RuntimeException.java:14)
at java.io.File.(File.java:154)
at com.medtronic.neuro.LandingPage.main(LandingPage.java:36)
at com.medtronic.neuro.LandingPage.start(LandingPage.java:260)
at ej.kf.Kernel$2.run(Kernel.java:237)
at java.lang.Thread.run(Thread.java:325)
at java.lang.Thread.runWrapper(Thread.java:387)

Could you please help me with this issue?

Hi Shuhabazhar,

Sorry for the delay…

It seems that the issue is that you are running against the FS API.
This “FS API” module is only meant for compilation and this dependency is normally replaced at build time by the implementation provided by the VEE Port / Kernel.

Let’s understand why it is not replaced.
It seems you are running a Sandboxed Application (a “feature”).
What Kernel are you using ? For your Application to access the File System Foundation Library API, the Kernel must have it in its Runtime API.
https://docs.microej.com/en/latest/KernelDeveloperGuide/kernelAPI.html

Also, can you clarify which MICROEJ SDK version you are using ? SDK 5 (MMM / Eclipse) ? SDK 6 (Gradle) ?

Best regards,
Rémy

Hi @rlouedec,
I am using ej.api:fs:2.1.1 in build.gradle file and manually added the fs-2.1.1 jar file in the following locations.

  1. …\demoapp\app\build\vee\javaLibs
  2. …\demoapp\app\build\vee\MICROJVM\javaLibs
    and I am using MICROEJ SDK 6.

Thanks

Hi @shuhabazhar,

Ok, I understand now why you have the issue at runtime instead of an error at buildtime.
The javaLibs folder is for libraries implementations packaged with VEE Ports.
In your case, you added the API jar of the File System foundation library. This jar does not contain any implementation and should be used for compilation only.

Different VEE Ports may provide different implementations (versions) of the same Foundation Library API.
So applications can depend on the same API Jar, but build against different VEE Ports for different targets using different implementations/versions of the same FS API Jar.
See Libraries — MicroEJ Documentation

What you need to do in your case is to add the FS Pack to your VEE Port.
For that, you can add our FS Pack available publicly on the MicroEJ Central Repository.

In yyy-configuration/module.ivy, add:

	<dependencies>
		<!-- ... -->
		<dependency org="com.microej.pack" name="fs" rev="6.0.4"/>
		<!-- ... -->
	</dependencies>

and in yyy-configuration/yyy.platform, add:

    <group name="fs"/>

See also: File System — MicroEJ Documentation

Best regards,
Rémy