You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jlidholm <jo...@gmail.com> on 2016/07/11 14:36:14 UTC

Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Hi,

I'm trying to use a custom POJO configured as a bean in a Camel XML DSL
route.
This POJO in its constructor tries to call two static methods in the Oracle
Weblogic Availability Helper class. But this call never returns, whether I'm
stepping in debug or just running it.

The calls to the helper class run fine when running locally from a plain
Main method in a local class in Eclipse (not as a part of a Camel route).

The code is the sample code from the Oracle documentation
(https://docs.oracle.com/cd/E17904_01/web.1111/e13727/dahelper.htm#JMSPG935):
And it hangs on the call "JMSDestinationAvailabilityHelper.getInstance()".
When I instead sent the JMSDestinationAvailabilityHelper in as a bean-ref to
the POJO bean, I got passed that call but got stuck on the second
"dah.register(...)" never returning.

--- === Oracle Sample code BEGIN === ---
/import java.util.Hashtable;
import javax.naming.Context;
import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;

Hashtable contextProps = new Hashtable();
contextProps.put(javax.naming.Context.PROVIDER_URL, myURL);
contextProps.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
JMSDestinationAvailabilityHelper dah =
JMSDestinationAvailabilityHelper.getInstance();

RegistrationHandler rh = dah.register(
   contextProperties,
   destinationJNDIName,
   myDestinationAvailableListener
)/
--- === Oracle Sample code END === ---

Not sure I'm making my problem clear, but would appreciate any hints if
anyone gets what might be going on.
Is there some other way I need to wire my bean? Or define the POJO?

Parts of my camel-context.xml:
    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
      <property name="environment">
         <props>
           <prop
key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
           <prop key="java.naming.provider.url">${weblogicJMS.url}</prop>
           <prop
key="java.naming.security.principal">${weblogicJMS.username}</prop>
           <prop
key="java.naming.security.credentials">${weblogicJMS.password}</prop>
         </props>
       </property>
    </bean>

    <bean id="testClassResolve"
class="weblogic.jms.extensions.JMSDestinationAvailabilityHelper"/>

    <bean id="topicPollH08"
class="camel.engine.jms.JMSTopicPollingProcessor" scope="singleton">
      <constructor-arg index="0" ref="jndiTemplate"/>
      <constructor-arg index="1" value="${weblogicJMS.topic.name}"/>
      <constructor-arg index="2" ref="testClassResolve"/>
    </bean>

The code of the POJO:
package camel.engine.jms;


import java.util.Hashtable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jndi.JndiTemplate;

import weblogic.jms.extensions.DestinationAvailabilityListener;
import weblogic.jms.extensions.DestinationDetail;
import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;
import weblogic.jms.extensions.RegistrationHandle;



//
// The JMSTopicPollingProcessor polls a given JMS Topic and returns the
first message to the camel Exchange.

public class JMSTopicPoller implements DestinationAvailabilityListener {

  private static final Logger log =
LoggerFactory.getLogger(JMSTopicPoller.class);
  private JndiTemplate jndiTemplate;
  private JMSDestinationAvailabilityHelper dah;
  private RegistrationHandle rh;
  
  private String topicName;

  public JMSTopicPoller(JndiTemplate jndiTemplate, String topicName,
JMSDestinationAvailabilityHelper dah) throws Exception {
    this.jndiTemplate = jndiTemplate;
    this.topicName = topicName;
    this.dah = dah;
    initConnection();
  }
  
  private void initConnection() throws Exception {
    
    Hashtable<String, String> contextProps = new Hashtable<String,
String>();
    for(final String name:
jndiTemplate.getEnvironment().stringPropertyNames()) {
      contextProps.put(name,
jndiTemplate.getEnvironment().getProperty(name));
    }
    
    log.debug("JMSTopicPollingProcessor - trying to register Weblogic
Destination Availability listener");

    rh = dah.register(
       contextProps,
       topicName,
       this
    );
    
    log.debug("JMSTopicPollingProcessor - Registered Weblogic Destination
Avalability listener");
}

  @Override
  public void onDestinationsAvailable(String arg0, List<DestinationDetail>
arg1) {
    log.debug("Destinations available");
  }

  @Override
  public void onDestinationsUnavailable(String arg0, List<DestinationDetail>
arg1) {
    log.debug("Destinations unavailable");
    
  }

  @Override
  public void onFailure(String arg0, Exception arg1) {
    log.debug("Failure!");
  }
}




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by jlidholm <jo...@gmail.com>.
Ok, more actual progress on this one...

The issue running locally wasnt' the java version after all. It was due to
us running Camel via maven (mvn camel:run).
When running Camel as a standalone java process, the initiation of the
Weblogic Helper class works fine!

Finally!



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785107.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by jlidholm <jo...@gmail.com>.
No, I guess it is not a proper solution after all, just a hint on going
forward.

@Claus: I'm not sure what you mean by "try to create the POJO up front".
Outside the Camel route somehow?

Thankful for hints on moving this forward after all.
Cannot get it working using open jdk 8 either.





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785065.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by souciance <so...@gmail.com>.
Not sure if it is a good thing that it runs only with jdk 1.6. Isn't that
out of support?

On Tue, Jul 12, 2016 at 10:04 PM, jlidholm [via Camel] <
ml-node+s465427n5785056h99@n5.nabble.com> wrote:

> Success!
>
> For any future readers stumbling upon this.
> Tried other JDK and it works as a charm.
>
> Didn't get it working using
>
>
>
> *java version "1.7.0_101" OpenJDK Runtime Environment (IcedTea 2.6.6)
> (7u101-2.6.6-2~deb8u1) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed
> mode) *
>
> But it works when running under
>
>
>
> *java version "1.6.0" Java(TM) SE Runtime Environment (build
> pap3260sr11-20120806_01(SR11)) IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4
> AIX ppc-32 jvmap3260sr11-20120801_118201 (JIT enabled, AOT enabled) *
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785056.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785057.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by jlidholm <jo...@gmail.com>.
Success!

For any future readers stumbling upon this.
Tried other JDK and it works as a charm.

Didn't get it working using
*java version "1.7.0_101"
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-2~deb8u1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
*

But it works when running under
*java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr11-20120806_01(SR11))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32
jvmap3260sr11-20120801_118201 (JIT enabled, AOT enabled)
*



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785056.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by jlidholm <jo...@gmail.com>.
Ok, no luck separating the logic and using init-method.

However - this is the same stack trace I get, and this also relates to my
suspicion that it is somehow thread/concurrency related (as I am not sure
how Camel/Spring handles these static bean references).

The last part of the first answer in this question seems relevant in my
case, but I cannot translate it to "Camel-lingo"...
The relevant part of the response being 

"Perhaps check your web-apps to see if any have static final references to
WL classes (to TransactionManager?), and, if so, change how they're
initialized so they're not part of the "clearReferencesStaticFinal" part of
the clean-up life-cycle."

https://community.oracle.com/thread/2562823?start=0&tstart=0

Any thoughts?
And yes, I'm trying to use a static factory-method to get an instance of the
helper class I need to be using





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785051.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by Claus Ibsen <cl...@gmail.com>.
You can also try to create the POJO up front if you say you can get
that working.
Then from Camel you can call this instance.

Also if its in the ctr there is an issue, you can try move that logic
to an init method, and have that called. If you use spring xml, you
can do that init-method thingy.



On Tue, Jul 12, 2016 at 12:03 PM, jlidholm <jo...@gmail.com> wrote:
> Ok, I'll try that.
> Just thought since the POJO instantiates fine when not defined as a bean in
> a camel route that there was a generic pitfall involved that someone might
> recognize.
>
> Thanks for the swift response!
>
> /Johnny
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785044.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by jlidholm <jo...@gmail.com>.
Ok, I'll try that.
Just thought since the POJO instantiates fine when not defined as a bean in
a camel route that there was a generic pitfall involved that someone might
recognize.

Thanks for the swift response!

/Johnny



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015p5785044.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Its usually harder for us to help when using commercial products like
WebLogic as its not something we can get hands on to reproduce the
issue.

And your problem seems more related to using WebLogic and not as much
about Apache Camel.
Maybe you need to ask on at Oracle WL user forum / report ticket for
commerical support from them or something.

You can also try to do a thread dump when it "hangs" to see if you can
spot the hanging thread and see what class/method its "hanging" at
that can help you track down the issue, or useful information for
Oracle support team to help you.

On Mon, Jul 11, 2016 at 3:36 PM, jlidholm <jo...@gmail.com> wrote:
> Hi,
>
> I'm trying to use a custom POJO configured as a bean in a Camel XML DSL
> route.
> This POJO in its constructor tries to call two static methods in the Oracle
> Weblogic Availability Helper class. But this call never returns, whether I'm
> stepping in debug or just running it.
>
> The calls to the helper class run fine when running locally from a plain
> Main method in a local class in Eclipse (not as a part of a Camel route).
>
> The code is the sample code from the Oracle documentation
> (https://docs.oracle.com/cd/E17904_01/web.1111/e13727/dahelper.htm#JMSPG935):
> And it hangs on the call "JMSDestinationAvailabilityHelper.getInstance()".
> When I instead sent the JMSDestinationAvailabilityHelper in as a bean-ref to
> the POJO bean, I got passed that call but got stuck on the second
> "dah.register(...)" never returning.
>
> --- === Oracle Sample code BEGIN === ---
> /import java.util.Hashtable;
> import javax.naming.Context;
> import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;
>
> Hashtable contextProps = new Hashtable();
> contextProps.put(javax.naming.Context.PROVIDER_URL, myURL);
> contextProps.put(Context.INITIAL_CONTEXT_FACTORY,
> "weblogic.jndi.WLInitialContextFactory");
> JMSDestinationAvailabilityHelper dah =
> JMSDestinationAvailabilityHelper.getInstance();
>
> RegistrationHandler rh = dah.register(
>    contextProperties,
>    destinationJNDIName,
>    myDestinationAvailableListener
> )/
> --- === Oracle Sample code END === ---
>
> Not sure I'm making my problem clear, but would appreciate any hints if
> anyone gets what might be going on.
> Is there some other way I need to wire my bean? Or define the POJO?
>
> Parts of my camel-context.xml:
>     <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
>       <property name="environment">
>          <props>
>            <prop
> key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
>            <prop key="java.naming.provider.url">${weblogicJMS.url}</prop>
>            <prop
> key="java.naming.security.principal">${weblogicJMS.username}</prop>
>            <prop
> key="java.naming.security.credentials">${weblogicJMS.password}</prop>
>          </props>
>        </property>
>     </bean>
>
>     <bean id="testClassResolve"
> class="weblogic.jms.extensions.JMSDestinationAvailabilityHelper"/>
>
>     <bean id="topicPollH08"
> class="camel.engine.jms.JMSTopicPollingProcessor" scope="singleton">
>       <constructor-arg index="0" ref="jndiTemplate"/>
>       <constructor-arg index="1" value="${weblogicJMS.topic.name}"/>
>       <constructor-arg index="2" ref="testClassResolve"/>
>     </bean>
>
> The code of the POJO:
> package camel.engine.jms;
>
>
> import java.util.Hashtable;
> import java.util.List;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> import org.springframework.jndi.JndiTemplate;
>
> import weblogic.jms.extensions.DestinationAvailabilityListener;
> import weblogic.jms.extensions.DestinationDetail;
> import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;
> import weblogic.jms.extensions.RegistrationHandle;
>
>
>
> //
> // The JMSTopicPollingProcessor polls a given JMS Topic and returns the
> first message to the camel Exchange.
>
> public class JMSTopicPoller implements DestinationAvailabilityListener {
>
>   private static final Logger log =
> LoggerFactory.getLogger(JMSTopicPoller.class);
>   private JndiTemplate jndiTemplate;
>   private JMSDestinationAvailabilityHelper dah;
>   private RegistrationHandle rh;
>
>   private String topicName;
>
>   public JMSTopicPoller(JndiTemplate jndiTemplate, String topicName,
> JMSDestinationAvailabilityHelper dah) throws Exception {
>     this.jndiTemplate = jndiTemplate;
>     this.topicName = topicName;
>     this.dah = dah;
>     initConnection();
>   }
>
>   private void initConnection() throws Exception {
>
>     Hashtable<String, String> contextProps = new Hashtable<String,
> String>();
>     for(final String name:
> jndiTemplate.getEnvironment().stringPropertyNames()) {
>       contextProps.put(name,
> jndiTemplate.getEnvironment().getProperty(name));
>     }
>
>     log.debug("JMSTopicPollingProcessor - trying to register Weblogic
> Destination Availability listener");
>
>     rh = dah.register(
>        contextProps,
>        topicName,
>        this
>     );
>
>     log.debug("JMSTopicPollingProcessor - Registered Weblogic Destination
> Avalability listener");
> }
>
>   @Override
>   public void onDestinationsAvailable(String arg0, List<DestinationDetail>
> arg1) {
>     log.debug("Destinations available");
>   }
>
>   @Override
>   public void onDestinationsUnavailable(String arg0, List<DestinationDetail>
> arg1) {
>     log.debug("Destinations unavailable");
>
>   }
>
>   @Override
>   public void onFailure(String arg0, Exception arg1) {
>     log.debug("Failure!");
>   }
> }
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2