Author |
Message
|
smdavies99 |
Posted: Thu Nov 07, 2013 1:21 am Post subject: When 'ClassNotFoundException' does not mean what it says? |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Broker 9.0.0.0, windows Server 2008 R2
Code: |
2013-11-07 11:58:23.170686 2228 UserTrace BIP7170I: Operation ''get'' on map ''S_SUPPLIER_ID'' has been completed successfully.
A client successfully completed operation ''get'' on map ''S_SUPPLIER_ID' in grid ''WMB''. The data processed by this action was ''Key = AMI''.
None
2013-11-07 11:58:23.170754 2228 UserTrace BIP11103I: Got data from map ''S_SUPPLIER_ID''
The message flow has successfully got data from map ''S_SUPPLIER_ID'', in cache ''WMB'', using key ''AMI''.
2013-11-07 11:58:23.179866 2228 UserTrace BIP3484E: ''CWOBJ1130W: Communication with the partition with the domain:grid:mapSet:partitionId WMB_DEVBRKR_localhost_12809_DEVBRKR_localhost_12813:WMB:mapSet:7 failed with an Object Request Broker (ORB) exception communicating with <null> at 192.168.98.252. org.omg.CORBA.INTERNAL: An internal error happened processing the request''
An embedded component has written the diagnostic message included here.
Refer to the appropriate message in the embedded component's documentation.
2013-11-07 11:58:23.180052 2228 UserTrace BIP11108E: Failed to complete action on map ''S_SUPPLIER_ID''
The message flow has failed to complete an action on map ''S_SUPPLIER_ID'' in cache ''WMB''. Details of the exception are: ''ClassNotFoundException: com.mycorp.broker.globalcache.supplier$SSupplier''.
|
The Map has been created and the Java code does a 'map.get' to check if the key/value pair is there. If it isn't it add the value if it is, it updates it.
The output from
mqsicacheadmin DEVBRKR -c showMapSizes
shows the map in existence. so that part of the code is working fine.
So how can this code return the class not found error?
Code: |
SSupplier[] sup1 = (SSupplier[])map.get(id);
if (sup1 == null) {
map.put(id, sup);
result[0] = "Ok[I]: key=("+ id + ") Value=" + myStr;
} else {
map.update(id, sup);
result[0] = "Ok[U]: key=("+ id + ") Value=" + myStr;
}
return true;
} catch (MbException e) {
// TODO Auto-generated catch block
System.err.println("error writing into cache");
result[0] = e.toString() + serials[0];
}
|
'sup' is created
sup = new SSupplier();
and populated with setter functions.
I understood that IIB 9 allowed Objects to be used in maps rather then string values. Is this correct?
The code that works in 8.0.0.3 runs fine as that uses a string object. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Esa |
Posted: Thu Nov 07, 2013 1:35 am Post subject: Re: When 'ClassNotFoundException' does not mean what it says |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
smdavies99 wrote: |
''ClassNotFoundException: com.mycorp.broker.globalcache.supplier$SSupplier''.
|
SSuplier is an inner class? Have you declared it public?
smdavies99 wrote: |
I understood that IIB 9 allowed Objects to be used in maps rather then string values. Is this correct? |
Yes, but the classes must support serialization by implementing Serializable or Externalizable interface.
Last edited by Esa on Thu Nov 07, 2013 1:38 am; edited 1 time in total |
|
Back to top |
|
 |
stoney |
Posted: Thu Nov 07, 2013 1:36 am Post subject: |
|
|
Centurion
Joined: 03 Apr 2013 Posts: 140
|
IIB v9 does allow you to use user defined Java objects with the Global Cache. However, you must place the classes for those Java objects in a JAR file in the shared-classes directory. They cannot be deployed to the runtime along with your message flows and Java compute node classes.
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fbc23770_.htm
The ClassNotFoundException occurs because the internal WebSphere eXtreme Scale component that backs the Global Cache does not have access to your deployed SSupplier class - only those in the shared-classes directories.
The other exception you might see is a ClassCastException, where it claims that SSupplier is incompatible with SSupplier. This would happen if you have the SSupplier class in the shared-classes directory and also deployed to the integration server. |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Nov 07, 2013 2:40 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
I suppose some progress has been made.
Code: |
2784 UserTrace BIP11103I: Got data from map ''S_SUPPLIER_ID''
The message flow has successfully got data from map ''S_SUPPLIER_ID'', in cache ''WMB'', using key ''AMI''.
2013-11-07 13:38:20.274448 2784 UserTrace BIP3484E: ''CWOBJ1130W: Communication with the partition with the domain:grid:mapSet:partitionId WMB_DEVBRKR_localhost_12809_DEVBRKR_localhost_12813:WMB:mapSet:7 failed with an Object Request Broker (ORB) exception communicating with <null> at 192.168.98.252. org.omg.CORBA.INTERNAL: An internal error happened processing the request''
An embedded component has written the diagnostic message included here.
Refer to the appropriate message in the embedded component's documentation.
2013-11-07 13:38:20.274662 2784 UserTrace BIP11110E: Failed to connect to cache ''WMB''
The execution group has failed to connect to cache ''WMB''. Details of the exception are: ''com.ibm.websphere.objectgrid.ObjectGridRuntimeException: org.omg.CORBA.INTERNAL: An internal error happened processing the request vmcid: 0x0 minor code: 0 completed: No''.
2013-11-07 13:38:20.275342
|
This might all be more trouble than it is worth. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 07, 2013 7:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
smdavies99 wrote: |
an Object Request Broker (ORB) exception communicating with<null> at 192.168.98.252 |
this is unclear to me whether the ORB broker @192.168.98.252 was not instantiated => null object, or whether the request object to retrieve the value from the map, passed to the ORB broker @192.168.98.252 was null...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Nov 07, 2013 7:53 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Yes that's what I thought.
If I create a simple string object (ie that works on V it wotks on V9 as well. Trying to use an object with a mix of data types fails.
I'm with Vitor here. Using Java involves just far too much faffing around. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 07, 2013 7:55 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
smdavies99 wrote: |
Yes that's what I thought.
If I create a simple string object (ie that works on V it wotks on V9 as well. Trying to use an object with a mix of data types fails.
I'm with Vitor here. Using Java involves just far too much faffing around. |
Like Jeff said, using your object with multiple primitives (i.e. data types) did you make sure this object was either serializable or externalizable?
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Nov 07, 2013 8:08 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
fjb_saper wrote: |
Like Jeff said, using your object with multiple primitives (i.e. data types) did you make sure this object was either serializable or externalizable?
 |
Yep. Even our resident Java expert is baffled. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
stoney |
Posted: Thu Nov 07, 2013 11:44 am Post subject: |
|
|
Centurion
Joined: 03 Apr 2013 Posts: 140
|
It is worth raising a PMR for this issue, if you haven't already - please send in service trace that covers the error as well. |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Nov 07, 2013 1:06 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
stoney wrote: |
It is worth raising a PMR for this issue, if you haven't already - please send in service trace that covers the error as well. |
Before I do that are there any examples of doing this sort of thing in the eXtreme cache product? I've tried to find some help there but so far to no avail.
A bit of java that shows how to do the externalizable bits would help as well. We are pretty short on Jave skills and our 'expert' has done anything like this before (his expertise is U/I stuff). _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Tibor |
Posted: Fri Nov 08, 2013 6:58 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
|
Back to top |
|
 |
stoney |
Posted: Wed Nov 13, 2013 2:57 am Post subject: |
|
|
Centurion
Joined: 03 Apr 2013 Posts: 140
|
Serializable is much easier to implement than Externalizable. To implement Serializable, you simply need to mark it as being implemented:
Code: |
import java.io.Serializable;
public class Pojo implements Serializable {
} |
If you're using the toolkit, you'll get a warning about it not having a serialVersionUID - you can ask the toolkit to generate you one. You'd end up with something like this:
Code: |
import java.io.Serializable;
public class Pojo implements Serializable {
private static final long serialVersionUID = 1692393888158914817L;
} |
That is all you need on the Java class to store it in the Global Cache.
I suspect (but can't confirm without seeing your projects or service trace) that your Java class is being pulled into your BAR file and deployed to the runtime, causing the exceptions you're seeing.
Your Java class must live in a separate Java project to any Java compute node classes. You then need to export that Java project into a JAR file and copy that into the shared-classes directory of the runtime in order to make the classes available.
In order to use those Java classes from a Java compute node project, you cannot add a reference to the Java project in the toolkit. This causes both Java projects to be included in the BAR file, which you don't want. Instead, the Java compute node project must reference the exported JAR file instead.
There's a few tips on removing the project references hidden away in this blog entry: https://www.ibm.com/developerworks/community/blogs/c7e1448b-9651-456c-9924-f78bec90d2c2/entry/how_to_store_logical_message_tree_data_in_the_global_cache_using_jaxb?lang=en
Skip over the bits about JAXB and look for the bits under "Creating a new Java Compute Node" where the POJOs project references get removed from the GCPOJOsJava project and replaced with the path to the JAR file. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Nov 13, 2013 4:45 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Thanks for the post. You have hit the nail right on the head.
I'll look at it when I get back from my next trip to foreign parts (Broker 7 site)
My real gripe is that you have to employ two different deployment methods. One for the bar file and one for the jar file.
I am firmly in the camp that says 'Java seems to out of its way to make things as hard as possible'.
I know that this is a generalization but there are days when I wish I was back writing VMS device drivers, coding applications in Bliss and not having to worry about classes, classpath precidence and all that stuff. (yeah, I know the world has moved on...) _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
|