1 2 Previous Next 15 Replies Latest reply on Feb 14, 2018 9:43 PM by Ziho Siu

    Sending Messages to a Weblogic Queue

    Charles Walker Newbie

      I'm trying to put a message on a queue hosted on a weblogic 10.3.5 server.  I've followed the bea instructions and created a "wlfullclient.jar".  Following the answer from "https://community.jboss.org/thread/203758", I created the module and jboss seems happy with it.  the module looks like:

       

       

      {code:xml}

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.0" name="wlfullclient">

              <resources>

                      <resource-root path="wlfullclient.jar" />

              </resources>

              <dependencies>

                      <module name="org.omg.api" />

                      <module name="javax.api" />

                      <module name="sun.jdk" />

              </dependencies>

      </module>

      {code}

      I am able to lookup the initialcontext as such:

      {code}

          Properties props = new Properties();

          props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

          props.put(Context.PROVIDER_URL, "t3://10.72.72.147:7010");

          Context ctx = new InitialContext(props);

      {code}

      but when I lookup the connection factory

         

      {code}QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup("/ecologic/jms/ConnectionFactory"); {code}

      I get a {code}weblogic.jms.client.JMSConnectionFactory{code} that can't be cast to a {code}QueueConnectionFactory{code}

       

      Even if I change the Object type to the weblogic specific type, creating a connection fails with a classloader exception

      {code}QueueConnection qc = qcf.createQueueConnection();{code}

       

      I've been wrestling with this for a few days now so I'm hoping someone can provide some guidance.

       

      Thanks,

      Charlie

       



        • 1. Re: Sending Messages to a Weblogic Queue
          Stephen Coy Master

          I expect that you need to get rid of all of the javax.* classes from your wlfullclient.jar.

          • 2. Re: Sending Messages to a Weblogic Queue
            Nicklas Karlsson Master

            Are there any lighter jars (e.g. weblogic.jar) that could be used?

            • 3. Re: Sending Messages to a Weblogic Queue
              Stephen Coy Master

              The weblogic.jar from around 9g onward contains manifest classpath entries that are a minefield of backwardly relative paths (../../../modules/...).

              • 4. Re: Sending Messages to a Weblogic Queue
                Charles Walker Newbie

                I had also thought that might work but when I removed the javax.* classes from the wlfullclient.jar file, I started getting "ClassNotFound" exceptions.

                • 5. Re: Sending Messages to a Weblogic Queue
                  Stephen Coy Master

                  Can you share the details? You may need more module dependencies.

                  • 6. Re: Sending Messages to a Weblogic Queue
                    Charles Walker Newbie

                    Using the wlfullclient.jar file, when executing this line

                     

                    {code} QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup("/ecologic/jms/ConnectionFactory"); {code}

                     

                    I get the exception:

                     

                    {code}java.lang.ClassCastException: weblogic.jms.client.JMSConnectionFactory cannot be cast to javax.jms.QueueConnectionFactory{code}

                     

                    So I modified the code to use the weblogic specific class as such:

                     

                    {code}

                    weblogic.jms.client.JMSConnectionFactory qcf = (weblogic.jms.client.JMSConnectionFactory)ctx.lookup("/ecologic/jms/ConnectionFactory");

                    QueueConnection qc = qcf.createQueueConnection();

                    {code}

                     

                    and got the following exception on the "createQueueConnection()" call:

                     

                    {code}

                    java.lang.LinkageError: loader constraint violation: when resolving method "weblogic.jms.client.JMSConnectionFactory.createQueueConnection()Ljavax/jms/QueueConnection;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, com/ge/dm/services/ea/cim/CimRequestTrigger, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, weblogic/jms/client/JMSConnectionFactory, have different Class objects for the type javax/jms/QueueConnection used in the signature

                    {code}

                     

                    Removing the "javax.*" code from the wlfullclient.jar file got me a:

                     

                    {code}java.lang.NoClassDefFoundError: javax/transaction/SystemException{code}

                     

                    when just trying to get the initialContext.

                    • 8. Re: Sending Messages to a Weblogic Queue
                      Charles Walker Newbie

                      using "wlthinclient.jar" results in the same exceptions.

                      • 9. Re: Sending Messages to a Weblogic Queue
                        rodakr Novice

                        you have to exclude in modul.xml all javax.xxxx from wlthin client

                        and define the modul global in standalone.xml. With only weblogic packages it should be fine.

                        • 10. Re: Sending Messages to a Weblogic Queue
                          Charles Walker Newbie

                          First- Thanks for your help!

                           

                          I've modified the module.xml to look like this:

                           

                          {code:xml}<module xmlns="urn:jboss:module:1.0" name="wlthinclient">

                           

                              <exports>

                                  <exclude path="javax/*"/>

                              </exports>

                           

                              <resources>

                                  <resource-root path="wlthint3client.jar" />

                              </resources>

                           

                              <dependencies>

                                  <module name="org.omg.api" />

                                  <module name="javax.api" />

                                  <module name="sun.jdk" />

                              </dependencies>

                          </module>{code}

                           

                          That gets me further along but i still get an exception unless I use the weblogic specific classes.

                           

                          I still can't cast a "weblogic.jms.client.JMSConnectionFactory" to a "javax.jms.ConnectionFactory".  I also get an exception when looking up the queue:

                           

                          {code}Queue queue = (Queue)ctx.lookup("/ecologic/jms/OnDemandRequest");{code}

                           

                          returns the exception

                           

                          {code}weblogic.jms.common.DestinationImpl cannot be cast to javax.jms.Queue{code}

                           

                          Adding the exclude to the module.xml did help.  the following now works:

                           

                          {code}weblogic.jms.client.JMSConnectionFactory qcf = (weblogic.jms.client.JMSConnectionFactory)ctx.lookup("/ecologic/jms/ConnectionFactory");

                          Connection qc = qcf.createConnection();{code}

                           

                          where it didn't before.  It still appears I'm missing something having to use the weblogic specific classes.

                          • 11. Re: Sending Messages to a Weblogic Queue
                            rodakr Novice

                            In your source code you should just use standad JMS API, you don't need to use  internal weblogic packages.  Only weblogic connection factory is needed if you want  to use t3.

                            With this modu definition it woks for me:

                             

                            <module xmlns="urn:jboss:module:1.1" name="com.weblogic.wlthint3client">

                              <resources>

                             

                               <resource-root path="wlthint3client.jar">

                                      <filter>

                                          <exclude-set>

                                              <path name="javax.ejb"/>

                                              <path name="javax.ejb.spi"/>

                                            <path name="javax.transaction"/>

                                            <path name="javax.jms"/>

                                            <path name="javax.xml"/>

                                            <path name="javax.xml.stream"/>

                                         </exclude-set> 

                                     </filter>

                               </resource-root>

                              </resources>

                             

                              <dependencies>

                                    <module name="javax.api"/>

                                    <module name="sun.jdk" export="false" services="import">

                                        <exports>

                                            <include-set>

                                                <path name="sun/security/acl"/>

                                                <path name="META-INF/services"/>

                                            </include-set>

                                        </exports>

                                    </module>

                                    <module name="com.sun.xml.bind" />

                                    <module name="org.omg.api"/>

                                    <module name="javax.ejb.api" export="false"   />

                                    <module name="javax.transaction.api"  export="false" />

                                    <module name="javax.jms.api"  export="false" />

                                    <module name="javax.xml.stream.api" export="false"  />

                                    <module name="org.picketbox" optional="true"/>

                                    <module name="javax.servlet.api" optional="true"/>

                                    <module name="org.jboss.logging" optional="true"/>

                                    <module name="org.jboss.as.web" optional="true"/>

                                    <module name="org.jboss.as.ejb3" optional="true"/>

                              </dependencies>

                            </module>

                             

                            Just make shure , yours ear wars doesn't contains any weblogic libraries like weblogic.jar or wlthint3client.jar, when you define wls client as modul.

                            • 12. Re: Sending Messages to a Weblogic Queue
                              Charles Walker Newbie

                              That did the trick.  I had to use the "wlfullclient.jar" though.  Without it, on errors, I got marshalling exceptions for a couple of the weblogic exception classes.

                               

                              Thanks for all your help!!

                              • 13. Re: Sending Messages to a Weblogic Queue
                                rodakr Novice

                                I started with wlfullclient.jar  from WLS 10.3.5 and later by more testing I run in troubles with packages collisions... so depends what your application is doing, it might work or not with wlfullcient.jar.

                                wlthint3client.jar was designed by bea weblogic to work also in foreign Application Servers. This is even oficially supported.

                                 

                                And wltint3client is also official Weblogic Client for JMS! You shouldn't have Problems with any internal Weblogic Classes, if you Code According to JMS Standard API.

                                • 14. Re: Sending Messages to a Weblogic Queue
                                  Aniruth Parthasarathy Newbie

                                  Hello Radek,

                                   

                                  You just resolved my issue with Wildfly to Weblogic12c (on jdk1.8). I was trying to resolve this for the past 2 days and finally was able to do it. My sincere thanks to you.

                                   

                                  Ani

                                  1 2 Previous Next