Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage-restservice-sparkjava does not work in Quarkus #157

Open
nimo23 opened this issue Mar 1, 2024 · 2 comments
Open

storage-restservice-sparkjava does not work in Quarkus #157

nimo23 opened this issue Mar 1, 2024 · 2 comments

Comments

@nimo23
Copy link

nimo23 commented Mar 1, 2024

Environment Details

  • EclipseStore Version: 1.2.0
  • JDK version: openjdk version "21.0.2" 2024-01-16
  • OS: Mac OS
  • Used frameworks: Quarkus 3.8.1

Describe the bug

I use EclipseStore in Quarkus (in JVM-Mode) sucessfully after changing the ClassLoaderProvider according to https://stackoverflow.com/questions/65898882/quarkus-with-microstream-classloader-problems:

return EmbeddedStorageConfigurationBuilder.New()
	..
	.createEmbeddedStorageFoundation()
	// TODO workaround see https://stackoverflow.com/questions/65898882/quarkus-with-microstream-classloader-problems
	// default is "ClassLoader.getSystemClassLoader()"
	.onConnectionFoundation(cf -> cf.setClassLoaderProvider(ClassLoaderProvider.New(Thread.currentThread().getContextClassLoader())))
	..
	.start();

However, when using the eclipse-store "rest-interface":

<dependency>
	<groupId>org.eclipse.store</groupId>
	<artifactId>storage-restservice-sparkjava</artifactId>
	<version>1.2.0</version>
</dependency>

then quarkus does not start the application successfully and the following stacktrace is shown:

2024-03-01 10:38:59,512 INFO [org.ecl.ser.per.typ.PersistenceTypeHandlerManager] (Quarkus Main Thread) Initializing type handler manager
Exception in thread "Thread-38" java.lang.NoClassDefFoundError: javax/servlet/Filter
at spark.embeddedserver.EmbeddedServers.initialize(EmbeddedServers.java:41)
at spark.Service.lambda$init$2(Service.java:618)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:518)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
... 3 more

I also tried to use another spark-version as suggested in microstream-one/microstream#238:

<dependency>
	<groupId>org.eclipse.store</groupId>
	<artifactId>storage-restservice-sparkjava</artifactId>
	<version>1.2.0</version>
</dependency>
<!-- workaround because of: https://github.com/microstream-one/microstream/issues/238  -->
<dependency>
	<groupId>com.sparkjava</groupId>
	<artifactId>spark-core</artifactId>
	<version>2.8.0</version>
</dependency> 

I also tried to solve this issue by making the javax.servlet-api-dependency explicit:

<dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>javax.servlet-api</artifactId>
	<version>3.1.0</version>
	<scope>provided</scope>
</dependency>

But that doesn't help. Looking at the classpath I can see that javax.servlet.api exists:

Screenshot at Mar 01 10-50-40

To Reproduce

Use EclipseStore in Quarkus and initialize a StorageRestService by storage-restservice.

Expected behavior

Using a StorageRestService should work.

@hg-ms
Copy link
Contributor

hg-ms commented Mar 1, 2024

Hello,

The spark-java REST service was intended to provide the Api to standalone java apps too, that’s why it has jetty and other stuff included. There is currently no other implementation.
As Quarkus provides a great REST support you may implement the four required routes directly in your app to get rid of the sparkjava implementation.
Please see the Microstream issues #549 and #695 for additional information.

@nimo23
Copy link
Author

nimo23 commented Mar 1, 2024

Ok, thanks for the information. I will try to create a RestClient in Quarkus consuming the endpoints like in microstream-one/microstream#695 (comment).

By the way, a possible Quarkus extension in the future could potentially provide these REST endpoints by default for the Quarkus DevConsole and the application itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants