Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
Failed to connect to weblogic topic using java

Hi,
I am trying to connect to weblgic topic using java code. Here is my code
package com.oracle.xml.notification;
import com.oracle.schemas.soa.fault.Commonfault;
import javax.faces.bean.ManagedBean;
import java.io.StringWriter;
import java.math.BigInteger;
import java.util.Hashtable;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.naming.InitialContext;
import javax.naming.*;
import javax.jms.*;
import javax.jms.Topic;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicPublisher;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.TopicSession;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.naming.NamingException;
@ManagedBean(name = "SendNotificationToQueue")
public class SendNotificationToQueue {
// 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 = "jms/Notification";
// Defines the topic.
public final static String MyTOPIC = "jms/Notification_Topic";
// 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 = "t3s://fmwsoaupgnrldev.adr.alcoa.com:7211";
public static void main(String args[]) throws JAXBException {
SendNotificationToQueue sendNotificationToQueue = new SendNotificationToQueue();
Commonfault inputXML = new Commonfault();
inputXML.setInterfaceDetail("ID");
inputXML.setComponentName("ComponentName");
inputXML.setCompositeDN("CompisiteName");
inputXML.setEngineType("EngineType");
inputXML.setFaultName("FaultName");
inputXML.setFaultType("FaultType");
inputXML.setFlowID(new BigInteger("1234"));
inputXML.setMessage("Message");
JAXBContext jaxbContext = JAXBContext.newInstance(Commonfault.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(inputXML, sw);
String xmlContent = sw.toString();
System.out.println(xmlContent);
try {
sendNotificationToQueue.publishToTopic(xmlContent);
} catch (Exception e) {
System.out.println("Exception occured ##############################" + e.getMessage());
}
}
public void publishToTopic(String message) throws NamingException, JMSException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, WebLogicURL);
System.out.println("111111111111111111111111111111111111");
InitialContext ic = new InitialContext(env);
System.out.println("222222222222222222222222222222");
TopicConnectionFactory f = (TopicConnectionFactory) ic.lookup(JMS_FACTORY);
System.out.println("333333333333333333333333333333333");
TopicConnection con = f.createTopicConnection();
System.out.println("4444444444444444444444444444444");
con.start();
//2) create topic session
TopicSession ses = con.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
//3) get the Topic object
Topic topic = (Topic) ic.lookup(MyTOPIC);
//4)create topic publisher
TopicPublisher topicPublisher = ses.createPublisher(topic);
topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
//5) create TextMessage object
TextMessage msg = ses.createTextMessage();
msg.setText(message);
//7) send message
topicPublisher.publish(msg);
System.out.println("Message successfully published: " + msg);
//8) connection close
con.close();
}
}
I am getting following error.
Exception occured ##############################Unable to resolve 'jms.Notification_Topic'. Resolved 'jms'
Can anyone help?
Answers
-
I fixed this. The issue was a result of a few undesirable containers that I had added to the Project. Fundamentally I had added all the Weblogic containers to my venture. Later I eliminated every one of the Java and just left wlclient.jar, wljmsclient.jar. I thought Jar struggle while perusing the article on
-
Hi,
I am also having the same java issue and found the best answer here.