Question

4
Replies
165
Views
AndreAugustoC Member since 2014 15 posts
A Dutch Bank
Posted: January 13, 2019
Last activity: January 17, 2019
Closed
Solved

Does anybody have examples of a Pega JMS Connector for Weblogic? Mine doesn't work. I wrote Java JMS clients and they work.

Hi All,

I wonder if some kind soul how has JMS connection to weblogic working could help me here. I work alone and have no expert colleagues to rely on.

Goal: to write a JMS client that posts a message.

Achieved so far: I wrote such a client (producer and consumer) in Java within 1 hour.

Problem: 4 hours down the road, and I still did not manage to create a Pega JMS Connector using the same configurations from my Java one pagers of code that worked. So the problem is in Pega, and potentially on a silly mistake by the user.

Request: It would be nice if somebody could share examples/printscreens of:

1. Printscreen of Pega JMS Connector setup for weblogic using "Direct JNDI Lookup", and less prioritary: using "Resource reference" which I tried after the JNDI Lookup method did not work. Please include the authentication rule instance for the JNDI lookup method Pega form (is it basic authentication?)

2. Printscreen of Pega JMS JNDI Server Data Object creation screen/form for weblogic.

This is all documented at: https://community.pega.com/knowledgebase/articles/how-create-jms-connector.

In the mean time we can try to solve my bug (without example printscreens to sanity check my config):

The bug I was getting while trying to create the JMS "Server Data Object" mentioned above was: "java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory" as per error_screen_for_server.png attached. This message showed when hitting "test connection" button. It surprises me, as it is all running within PRPC that runs inside weblogic itself and the JMS topic is in the same weblogic. So the jar libraries should be visible.

To solve the class not found problem, I had the logical idea to add the wlthint3.jar file name to the path in the dynamic system settings called compiler/default paths. This file contains the WLInitialContextFactory. This proved to be a nightmare, as it caused my weblogic server to not boot again! as no MDB from Pega would ever work (startup log messages). Luckily it was my laptop install, and not the customers.

The solution to the "no Pega reboot" problem - in the absence of a point rollback or safe mode restart - was: update pr_data_admin set pysetting = '' where pysetting like '%wlthint3.jar%';

When creating the "JMS connector" the error is different. It says this when I click test connection: Caught exception opening Data-Admin-Connect-JNDIServer instance:'t3://localhost:7001'

I did check the server logs (pega logs) and nothing else was output other than what I got on the screen and that there was an exception connecting (but no stack trace of it). My log is in development mode.

I am providing right below my Java code that works to publish and at the bottom attached I am providing a word document with the configuration screens I used (I tried to make them correspond to the Java client that worked).

The question of how to make Pega find the missing class without crashing due to a new jar file is also a quite relevant one.

Happy Sunday, Andre' Cesta

'Java works':

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Hashtable;
import java.util.Locale;
import javax.naming.*;
import javax.jms.*;
public class PublishJMS {
// Defines the JNDI context factory.
public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
// Defines the JMS context factory.
//public final static String JMS_FACTORY="ConnectionFactory2";
public final static String JMS_FACTORY="comp.env.jms.tcf.Async";
// Defines the topic.
//public final static String MyTOPIC="jndi/Topic1";
public final static String MyTOPIC="comp.env.jms.topic.AsyncTrigger";
// Defines the WebLogic URL. The port is for the Managed Server or
// the Admin Server where the JMS Server is running.
public final static String WebLogicURL="t3://localhost:7001";
public static void main(String[] args) {
try {
sendMessage();
} catch(Throwable t) {
System.out.println("Exception:");
System.out.println(t);
System.out.println("Complete stack trace:");
t.printStackTrace();
}
}
public static InitialContext getInitialContextMethod1(int iStep) throws NamingException {
int j = 1;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, WebLogicURL);
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "@Install33");
System.out.println(iStep + "." + j++ + " Initial context.");
InitialContext toReturn = new InitialContext(env);
try {
toReturn = new InitialContext(env);
} catch (Throwable t) {
System.out.println(t.getMessage());
t.printStackTrace();
}
return toReturn;
}
public static InitialContext getInitialContextMethod2(int iStep) throws NamingException {
int j = 1;
weblogic.jndi.Environment environment = new weblogic.jndi.Environment();
System.out.println(iStep + "." + j++ + " Initial context.");
environment.setInitialContextFactory(
weblogic.jndi.Environment.DEFAULT_INITIAL_CONTEXT_FACTORY);
environment.setProviderURL(WebLogicURL);
System.out.println(iStep + "." + j++ + " Initial context.");
environment.setSecurityPrincipal("weblogic");
System.out.println(iStep + "." + j++ + " Initial context.");
//environment.setSecurityCrendentials("@Install33");
System.out.println(iStep + "." + j++ + " Initial context.");
//return environment.getInitialContext();
return null;
}
public static void sendMessage() throws Exception {
int i = 1;
System.out.println(i++);
Locale bLocale = new Locale.Builder().setLanguage("en").setRegion("US").build();
System.out.println(i++);
//Create and start connection
InitialContext ic = getInitialContextMethod1(i);
System.out.println(i++);
TopicConnectionFactory f=(TopicConnectionFactory)ic.lookup(JMS_FACTORY) ;
System.out.println(i++);
TopicConnection con=f.createTopicConnection();
System.out.println(i++);
con.start();
System.out.println(i++);
//2) create topic session
TopicSession ses = con.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println(i++);
//3) get the Topic object
Topic topic = (Topic)ic.lookup(MyTOPIC);
System.out.println(i++);
//4)create topic publisher
TopicPublisher topicPublisher = ses.createPublisher(topic);
topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
System.out.println(i++);
//5) create TextMessage object
TextMessage msg=ses.createTextMessage();
msg.setText("This is my message: " + getCurrentDateTime());
System.out.println(i++ + " Now publish:");
//7) send message
topicPublisher.publish(msg);
System.out.println(i++ + " Now close connection.");
//8) connection close
con.close();
System.out.println(i++);
}
/** For generating unique messages. */
public static String getCurrentDateTime() {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
return dtf.format(now);
}
}
Low-Code App Development Data Integration
Moderation Team has archived post
Share this page LinkedIn