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

Getting class cast eecption while using Micronaut aq-jsm library #575

Open
ashokkkannan opened this issue Aug 24, 2024 · 0 comments
Open

Comments

@ashokkkannan
Copy link

ashokkkannan commented Aug 24, 2024

Expected Behavior

We should be able to intialize javax.jms.ConnectionFactory for Oracle AQ - JMS feature with Datasource injected by Micronaut

Actual Behaviour

We are getting class cast exception as the aqjms library expects the Database connection to be of type oracle.jdbc.internal.OracleConnection but the datasource initialized by Micronaut is of type

io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted`_

`21:08:44.737 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [io.micronaut.jms.configuration.JMSConnectionFactoryBeanProcessor] could not be loaded: Error processing bean definition [Definition: com.oracle.ide.rpas.jms.AqJmsConfig]: Error instantiating bean of type  [javax.jms.ConnectionFactory]

Message: class io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted cannot be cast to class oracle.jdbc.internal.OracleConnection (io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted and oracle.jdbc.internal.OracleConnection are in unnamed module of loader 'app')
Path Taken: AqJmsConfig.connectionFactory()
io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [io.micronaut.jms.configuration.JMSConnectionFactoryBeanProcessor] could not be loaded: Error processing bean definition [Definition: com.oracle.ide.rpas.jms.AqJmsConfig]: Error instantiating bean of type  [javax.jms.ConnectionFactory]

Message: class io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted cannot be cast to class oracle.jdbc.internal.OracleConnection (io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted and oracle.jdbc.internal.OracleConnection are in unnamed module of loader 'app')
Path Taken: AqJmsConfig.connectionFactory()
	at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1998)
	at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:303)
	at io.micronaut.context.DefaultBeanContext.configureAndStartContext(DefaultBeanContext.java:3310)
	at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:345)
	at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:211)
	at io.micronaut.runtime.Micronaut.start(Micronaut.java:75)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:334)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:320)
	at com.oracle.ide.rpas.Application.main(Application.java:27)
Caused by: io.micronaut.context.exceptions.BeanContextException: Error processing bean definition [Definition: com.oracle.ide.rpas.jms.AqJmsConfig]: Error instantiating bean of type  [javax.jms.ConnectionFactory]

Message: class io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted cannot be cast to class oracle.jdbc.internal.OracleConnection (io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted and oracle.jdbc.internal.OracleConnection are in unnamed module of loader 'app')
Path Taken: AqJmsConfig.connectionFactory()
	at io.micronaut.context.AnnotationProcessorListener.onCreated(AnnotationProcessorListener.java:117)
	at io.micronaut.context.AnnotationProcessorListener.onCreated(AnnotationProcessorListener.java:44)
	at io.micronaut.context.DefaultBeanContext.triggerBeanCreatedEventListener(DefaultBeanContext.java:2380)
	at io.micronaut.context.DefaultBeanContext.postBeanCreated(DefaultBeanContext.java:2357)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2301)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2309)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3119)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3021)
	at io.micronaut.context.DefaultBeanContext.initializeEagerBean(DefaultBeanContext.java:2694)
	at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1992)
	... 8 common frames omitted
Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [javax.jms.ConnectionFactory]

Message: class io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted cannot be cast to class oracle.jdbc.internal.OracleConnection (io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted and oracle.jdbc.internal.OracleConnection are in unnamed module of loader 'app')
Path Taken: AqJmsConfig.connectionFactory()
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2342)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2297)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2309)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3119)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3021)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2982)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2955)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1713)
	at io.micronaut.jms.configuration.JMSConnectionFactoryBeanProcessor.process(JMSConnectionFactoryBeanProcessor.java:55)
	at io.micronaut.jms.configuration.JMSConnectionFactoryBeanProcessor.process(JMSConnectionFactoryBeanProcessor.java:41)
	at io.micronaut.context.AnnotationProcessorListener.onCreated(AnnotationProcessorListener.java:114)
	... 18 common frames omitted
Caused by: java.lang.ClassCastException: class io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted cannot be cast to class oracle.jdbc.internal.OracleConnection (io.micronaut.data.connection.jdbc.advice.ContextualConnection$Intercepted and oracle.jdbc.internal.OracleConnection are in unnamed module of loader 'app')
	at com.oracle.ide.rpas.jms.AqJmsConfig.connectionFactory(AqJmsConfig.java:32)
	at com.oracle.ide.rpas.jms.$AqJmsConfig$ConnectionFactory0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2327)
	... 29 common frames omitted
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:355)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:253)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:884)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:844)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:450)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:299)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:963)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:296)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:199)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Steps To Reproduce

  1. Include Oracle db config and jms config
  2. Inject Datasource object.
  3. Add code to create javax.jms.ConnectionFactory using AQjmsFactory .getConnectionFactory(dataSource)

Environment Information

MAC - JDK 17
micronaut-jms-core: 3.4.0
com.oracle.database.messaging:aqapi: 19.3.0.0

DB details:
Type: Oracle Autonomous Database
Version: 19c
Uses Oracle AQ

Connection pool type: Tried with both Hikari and UCP, same issue.

Example Application

No response

Version

4.5.0

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

1 participant