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

Issue when generating transportReceiver from custom_transport_listeners #3864

Open
sarindaSenevirathne opened this issue Jan 9, 2025 · 0 comments
Labels

Comments

@sarindaSenevirathne
Copy link

Description

We are defining the custom_transport_listeners as follows in deployment.toml file

[[custom_transport.listener]]
name = "QueueConnectionFactory"
protocol = "oracleaq"
class = "org.apache.axis2.transport.jms.JMSListener"
parameter.'java.naming.factory.initial' = "oracle.jms.AQjmsInitialContextFactory"
parameter.db_url = "url"
parameter.'java.naming.security.principal' = "principle"
parameter.'java.naming.security.credentials' = "credential"
parameter.'transport.jms.ConnectionFactoryJNDIName' = "jndiname"
parameter.'transport.jms.ConnectionFactoryType' = "queue"
parameter.'transport.jms.MaxConcurrentConsumers' = 2
parameter.'transport.jms.ConcurrentConsumers' = 2
parameter.'transport.jms.ReconnectProgressFactor' = 1
parameter.'transport.jms.InitialReconnectDuration' = "30000"
parameter.'transport.jms.CacheLevel' = "consumer"
parameter.'transport.jms.ReceiveTimeout' = "5000"

After starting the pack, the generated transportReceiver in axis2.xml is as follows

 <transportReceiver name="oracleaq" class="org.apache.axis2.transport.jms.JMSListener">
        <parameter name="transport.jms.ReconnectProgressFactor" locked="false">1</parameter>
        <parameter name="java.naming.security.credentials" locked="false">credential</parameter>
        <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        <parameter name="java.naming.factory.initial" locked="false">oracle.jms.AQjmsInitialContextFactory</parameter>
        <parameter name="db_url" locked="false">url</parameter>
        <parameter name="transport.jms.CacheLevel" locked="false">consumer</parameter>
        <parameter name="transport.jms.InitialReconnectDuration" locked="false">30000</parameter>
        <parameter name="transport.jms.ReceiveTimeout" locked="false">5000</parameter>
        <parameter name="transport.jms.MaxConcurrentConsumers" locked="false">2</parameter>
        <parameter name="transport.jms.ConcurrentConsumers" locked="false">2</parameter>
        <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
        <parameter name="java.naming.security.principal" locked="false">principle</parameter>
    </transportReceiver>

Since the generated transportReceiver is incorrect, they are facing the following issue

[2025-01-08 14:36:33,973] ERROR {ListenerManager} - Couldn't initialize the oracleaqADTtransport listener java.lang.ClassCastException: class java.lang.String cannot be cast to class org.apache.axiom.om.OMElement (java.lang.String is in module java.base of loader 'bootstrap'; org.apache.axiom.om.OMElement is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @57729490)
        at org.apache.axis2.transport.oracleaq.OracleAQConnectionFactory.<init>(OracleAQConnectionFactory.java:87)
        at org.apache.axis2.transport.oracleaq.OracleAQConnectionFactoryManager.loadConnectionFactoryDefinitions(OracleAQConnectionFactoryManager.java:59)
        at org.apache.axis2.transport.oracleaq.OracleAQConnectionFactoryManager.<init>(OracleAQConnectionFactoryManager.java:46)
        at org.apache.axis2.transport.oracleaq.OracleAQListener.doInit(OracleAQListener.java:66)
        at org.apache.axis2.transport.base.AbstractTransportListenerEx.init(AbstractTransportListenerEx.java:62)
        at org.apache.axis2.engine.ListenerManager.init(ListenerManager.java:84)
        at org.wso2.micro.integrator.core.internal.CoreServerInitializer.initializeCarbon(CoreServerInitializer.java:220)
        at org.wso2.micro.integrator.core.internal.CoreServerInitializer.initMIServer(CoreServerInitializer.java:125)
        at org.wso2.micro.integrator.core.internal.Activator.start(Activator.java:103)
        at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:842)
        at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:834)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:791)
        at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1013)
        at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365)
        at org.eclipse.osgi.container.Module.doStart(Module.java:598)
        at org.eclipse.osgi.container.Module.start(Module.java:462)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$1.run(ModuleContainer.java:1820)
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$2$1.execute(EquinoxContainerAdaptor.java:150)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1813)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1770)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1735)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1661)
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
 


After checking on this, we identified that the issue is caused due to the way we generated the axis2 configs through the j2 template file.

We have edited the j2 file as follows and it generated the transportReceiver correctly and the issue was resolved

 {% for transport_item in custom_transport.listener %}
    <transportReceiver name="{{transport_item.protocol}}" class="{{transport_item.class}}">
        <parameter name="{{transport_item.name}}" locked="false">
        {% for parameter_key,parameter_value in transport_item.parameter.items() %}
        <parameter name="{{parameter_key}}" locked="false">{{parameter_value}}</parameter>
        {% endfor %}
        {% if transport_item.keystore is defined %}
        <parameter name="keystore" locked="false">
            <KeyStore>
                <Location>{{transport_item.keystore.location}}</Location>
                <Type>{{transport_item.keystore.type}}</Type>
                <Password>{{transport_item.keystore.password}}</Password>
                <KeyPassword>{{transport_item.keystore.key_password}}</KeyPassword>
            </KeyStore>
        </parameter>
        {% endif %}
        {% if transport_item.truststore is defined %}
        <parameter name="truststore" locked="false">
            <TrustStore>
                <Location>{{transport_item.truststore.location}}</Location>
                <Type>{{transport_item.truststore.type}}</Type>
                <Password>{{transport_item.truststore.password}}</Password>
            </TrustStore>
        </parameter>
        {% endif %}
        {% if transport_item.ssl_profile.file_path is defined %}
        <parameter name="dynamicSSLProfilesConfig">
            <filePath>{{transport_item.ssl_profile.file_path}}</filePath>
            <fileReadInterval>{{transport_item.ssl_profile.read_interval}}</fileReadInterval>
        </parameter>
        {% endif %}
        </parameter>
    </transportReceiver>
    {% endfor %}

With the change on J2 file, now the transportReceiver is generated as follows in axis2 file

 <transportReceiver name="oracleaq" class="org.apache.axis2.transport.jms.JMSListener">
        <parameter name="QueueConnectionFactory" locked="false">
                  <parameter name="transport.jms.ReconnectProgressFactor" locked="false">1</parameter>
                  <parameter name="java.naming.security.credentials" locked="false">credentials</parameter>
                  <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
                  <parameter name="java.naming.factory.initial" locked="false">oracle.jms.AQjmsInitialContextFactory</parameter>
                  <parameter name="db_url" locked="false">url</parameter>
                  <parameter name="transport.jms.CacheLevel" locked="false">consumer</parameter>
                  <parameter name="transport.jms.InitialReconnectDuration" locked="false">30000</parameter>
                  <parameter name="transport.jms.ReceiveTimeout" locked="false">5000</parameter>
                  <parameter name="transport.jms.MaxConcurrentConsumers" locked="false">2</parameter>
                  <parameter name="transport.jms.ConcurrentConsumers" locked="false">2</parameter>
                  <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">jndiname</parameter>
                  <parameter name="java.naming.security.principal" locked="false">principle</parameter>
        </parameter>
    </transportReceiver>

Please provide a patch version so the customer can use it in their deployment

Steps to Reproduce

Get a MI pack, define the custom_transport.listener as above in deployent toml and start the pack

Now examine the axis2.xml file

Version

MI 4.1.0 latest version

Environment Details (with versions)

non-prod

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

No branches or pull requests

1 participant