Skip to content

1.5.0.CR1 ClassCastException in multi-module maven project #9515

@sean-scott-lr

Description

@sean-scott-lr

Describe the bug
1.5.0.CR1 introduces a new regression that was not present in 1.4.2.Final.

An invalid ClassCastException occurs within code that was generated by the quarkus-infinispan client during the execution of unit tests.

Expected behavior
The Generated code functions without error.

Actual behavior
This exception is raised during unit testing:


[ERROR] persist_GivenIdentifierWithId_UsesExistingId  Time elapsed: 0.019 s  <<< ERROR!
java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
                [error]: Build step io.quarkus.infinispan.client.deployment.InfinispanClientProcessor#setup threw an exception: java.lang.ClassCastException: class com.lr.core.caching.initializers.IdentifierContextInitializerImpl cannot be cast to class org.infinispan.protostream.SerializationContextInitializer (com.lr.core.caching.initializers.IdentifierContextInitializerImpl is in unnamed module of loader 'app'; org.infinispan.protostream.SerializationContextInitializer is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @58cda03f)
                at io.quarkus.infinispan.client.deployment.InfinispanClientProcessor.setup(InfinispanClientProcessor.java:158)
                at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.base/java.lang.reflect.Method.invoke(Method.java:566)
                at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
                at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
                at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
                at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
                at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
                at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
                at java.base/java.lang.Thread.run(Thread.java:834)
                at org.jboss.threads.JBossThread.run(JBossThread.java:479)

To Reproduce
Steps to reproduce the behavior:

  1. Create a multi-module maven project
  2. In module A
  • Define a class you wish to use with an infinispan cache. Annotate the class with the appropriate @ProtoField annotations. In our case the class is called Identifier
  • Define the interface required to generate the proto. for example:
@AutoProtoSchemaBuilder(
    includeClasses = {Identifier.class},
    schemaPackageName = "com.lr.core.v1.initializer")
public interface IdentifierContextInitializer extends SerializationContextInitializer {}
  1. in module B ( which depends on module A )
  • Define a class which utilizes the classes defined in module A and define the interface required to generate its proto. for example:
@AutoProtoSchemaBuilder(
    dependsOn = IdentifierContextInitializer.class,
    includeClasses = DependentClass.class)
public interface DependentClassContextInitializer extends SerializationContextInitializer {}
  1. Run a test in module B and you will see this exception:
[ERROR] persist_GivenIdentifierWithId_UsesExistingId  Time elapsed: 0.019 s  <<< ERROR!
java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.infinispan.client.deployment.InfinispanClientProcessor#setup threw an exception: java.lang.ClassCastException: class com.logrhythm.core.caching.initializers.IdentifierContextInitializerImpl cannot be cast to class org.infinispan.protostream.SerializationContextInitializer (com.lr.core.caching.initializers.IdentifierContextInitializerImpl is in unnamed module of loader 'app'; org.infinispan.protostream.SerializationContextInitializer is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @58cda03f)
	at io.quarkus.infinispan.client.deployment.InfinispanClientProcessor.setup(InfinispanClientProcessor.java:158)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)

Configuration

# Add your application.properties here, if applicable.

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
    Darwin USMACEA090SSCOT 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

  • Output of java -version:
    openjdk version "11.0.6" 2020-01-14
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

  • GraalVM version (if different from Java):

  • Quarkus version or git rev:
    1.5.0.CR1

  • Build tool (ie. output of mvnw --version or gradlew --version):
    Apache Maven 3.6.3

Additional context
(Add any other context about the problem here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions