Author |
Message
|
Harsha_AS |
Posted: Thu Jun 22, 2017 8:31 am Post subject: Converting mbelement to dataObject JCN node |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
Hello,
I am facing an issue to convert mbelement to DataObject. Could you someone please help me on this. I am trying to cast here and at the run time i get it cannot cast mbelement to dataobject. Please let me know if there is any better way of doing it.
Below is the error i get at runtime.
Code: |
"java.lang.ClassCastException: com.ibm.broker.plugin.MbElement incompatible with commonj.sdo.DataObject"
MbElement inpayload=i n A s s e m b l y.getMessage().getRootElement().getLastChild();
DataObject order = (DataObject) msgAsBytes;
BOXMLSerializer serializer = (BOXMLSerializer) new ServiceManager()
.locateService("com/ibm/websphere/bo/BOXMLSerializer");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
String xMLString = "";
String returnStr = "";
String solrURL = "https://dev2-solr.ussco.com/solr-4.4.0/slicej";
try {
serializer.writeDataObject(order, order.getType().getURI(),
"order", outputStream);
xMLString = outputStream.toString("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
//options.put("convertdatetimefieldstoutc", true);
SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
.processRequest(xMLString, options, solrURL); |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jun 22, 2017 8:38 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You are not dealing with a J2EE java server.
Look into what type of node will serialize automatically for you the message tree.
Use the facilities that come with the broker!.
Learn to use the broker Java API (see MbElement) class  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Harsha_AS |
Posted: Thu Jul 06, 2017 10:07 am Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
Actually the issue is when we run the below code as a JAVA application we are able to send the data to URL - https://dev2-solr.ussco.com/solr-4.4.0/slicej.
But when I use the same code in IIB there is no data sent to the URL and it is not even throwing any error. Could some one please help me on this.
The above URL is not an webservice.
try {
xMLString = inputpayload;
Map<String, Object> options = new HashMap<String, Object>();
//options.put("convertdatetimefieldstoutc", true);
options.put("convertdatetimefieldstoutc", true);
SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
.processRequest(xMLString, options, solrURL);
//returnStr = "Order XML sent to SOLR:"+solrURL+"\n"+xMLString;
//System.out.println(returnStr);
} catch (Exception e) {
e.printStackTrace();
returnStr = "Error while sending message to SOLR ("+solrURL+") : \n"+e.getMessage()+"\nFor following Order XML\n "
+ xMLString;
//System.out.println(returnStr);
throw new MbUserException(this, "evaluate()", "", "", returnStr,
null);
//throw new MediationBusinessException(returnStr,e);
} finally{
System.out.println("Testing");
} |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 06, 2017 10:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
First let's try and explain what you're attempting to do.
Second if you are calling a web service, you should probably use a SOAP/REST Request Node and not do what you've shown us...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Harsha_AS |
Posted: Thu Jul 06, 2017 10:24 am Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
No I am not calling the webservice. It is the SOLR service.
Do you think raising an PMR with IBM will help by any chance. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 06, 2017 10:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Harsha_AS wrote: |
No I am not calling the webservice. It is the SOLR service.
Do you think raising an PMR with IBM will help by any chance. |
And in which way is SOLR not a service? You access it through a URL and you pass it an XML? payload!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Harsha_AS |
Posted: Thu Jul 06, 2017 10:43 am Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
Actually we are migrating from WESB to IIB. We have just take the code from WESB and using it in JCN node. It works perfectly in WESB and also as a JAVA application but not in JCN node.
Yes er are accessing it through URL and pass it an XML.
SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
.processRequest(xMLString, options, solrURL); |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jul 06, 2017 11:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
There is a migration tool for moving from WESB to IIB.
You can't just slap a WESB application into an IIB JCN. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Harsha_AS |
Posted: Fri Jul 07, 2017 6:29 am Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself.
Any help will be great. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 07, 2017 6:34 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Harsha_AS wrote: |
We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself.
Any help will be great. |
Okay.
What is the full error message you get in IIB? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Harsha_AS |
Posted: Fri Jul 07, 2017 7:30 am Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
Actually that is the issue I am facing. I am not seeing any error in IIB. It just terminates without any error but SOLR is not receiving any orders.  |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 07, 2017 8:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Harsha_AS wrote: |
We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself. |
So what this is telling you is that you need to make the call to the SOLR service yourself.
Now as you should probably guess there is a reason why the Java code has been commented out...
Instead of the commented code, try introducing either an HTTP Request node, or a SOAP Request node, or a REST Request ...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Harsha_AS |
Posted: Fri Jul 07, 2017 12:07 pm Post subject: |
|
|
Apprentice
Joined: 04 Dec 2011 Posts: 26
|
Thanks for the time and response.
Actually it worked the same Java code.
One thing I did is, I added all the required certificates to keystore file since we are making an https call. And also worked with WESB team to use the correct jar files. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 07, 2017 12:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Harsha_AS wrote: |
Thanks for the time and response.
Actually it worked the same Java code.
One thing I did is, I added all the required certificates to keystore file since we are making an https call. And also worked with WESB team to use the correct jar files. |
Good for you. However you have now circumvented the "official" way to do things. It is the most efficient way to do them as well. May be not the easiest as far as migration goes... but in 2 years who is going to maintain that??  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|