4

I am aware that a (very) similar question has been asked elsewhere but there are no answers so am posting here in the hope the new post will trigger some valuable responses.

I am trying to create a standalone app that will interrogate a JMS queue that is running on websphere. The queues are running as local apps are able to communicate with it and there are messages sitting there waiting for me.

I am using Netbeans and am using JDK1.8. In addition I have added the following jar files to the library:

javax.jms-1.1.jar
com.ibm.ws.orb_8.5.0.jar
com.ibm.ws.ejb.thinclient_8.5.0.jar  

The latter two were copied from the websphere installation.

Here is a summary of the initial code (it is actually built in a class with methods for the context and factory bits so have modified it to show here):

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, corbaloc:iiop:192.168.254.202:2809);
try{
InitialContext jndiContext = new InitialContext(env);
}catch(NamingException e){
System.out.println("ERROR: Could not create JNDI context: " + System.lineSeparator() + e.toString());
System.exit(1);
}
ConnectionFactory connectionFactory= (ConnectionFactory) this.jndiContext.lookup(factory);
String outFactory       = "jndi/OUTConnectionFactory";
try{    
connectionFactory = (ConnectionFactory) jndiContext.lookup(outFactory);
}catch(Exception e){
System.out.println("ERROR: Could not create factory connection:");
System.out.println(e.toString());
System.exit(2); 
}

At this point (connectionFactory = ...) it fails without triggering the catch

Exception in thread "P=598328:O=0:CT" java.lang.NoClassDefFoundError: sun/io/MalformedInputException
    at com.ibm.rmi.iiop.CDRReader.getTcsCConverter(CDRReader.java:398)
    at com.ibm.rmi.iiop.CDRReader.readStringOrIndirection(CDRReader.java:479)
    at com.ibm.rmi.iiop.CDRReader.read_string(CDRReader.java:465)
    at com.ibm.rmi.IOR.read(IOR.java:335)
    at com.ibm.rmi.iiop.Connection._locate(Connection.java:480)
    at com.ibm.rmi.iiop.Connection.locate(Connection.java:439)
    at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:219)
    at com.ibm.rmi.corba.Corbaloc.locateUsingINS(Corbaloc.java:307)
    at com.ibm.rmi.corba.Corbaloc.resolve(Corbaloc.java:378)
    at com.ibm.rmi.corba.ORB.objectURLToObject(ORB.java:3721)
    at com.ibm.CORBA.iiop.ORB.objectURLToObject(ORB.java:3256)
    at com.ibm.rmi.corba.ORB.string_to_object(ORB.java:3619)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.stringToObject(WsnInitCtxFactory.java:1645)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getWsnNameService(WsnInitCtxFactory.java:1502)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:1040)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:962)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:614)
    at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128)
    at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at jmstool2.JmsConn.CreateFactCon(JmsConn.java:103)
    at jmstool2.JmsConn.connect(JmsConn.java:59)
    at jmstool2.Jmstool2.main(Jmstool2.java:21)
Caused by: java.lang.ClassNotFoundException: sun.io.MalformedInputException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 25 more
Java Result: 1

I am really not sure where to look to resolve this error. Is it a case of finding the right .jar file or library or are there bigger issues at play here? I am a LAMP developer really and this dive into the world of Java and JMS queues is proving rather frustrating.

Many thanks

Community
  • 1
  • 1
Jon Holland
  • 391
  • 7
  • 19
  • Additional related question is the problem that: sun/io/MalformedInputException is missing or is that just the class that is reporting the error? – Jon Holland Jan 12 '15 at 13:35
  • `I am using Netbeans and am using JDK1.8`. As was pointed in that other thread - Java 1.8 is not supported as client to WebSphere 8.5. Please use Java 1.6 or 1.7. – Gas Jan 12 '15 at 14:12
  • Will try that then Gas...sorry you had not posted there when I first looked. – Jon Holland Jan 12 '15 at 14:21
  • I have moved to JDK 1.7 and that error has gone. OK, I have another error (javax.naming.NamingException: Error getting WsnNameService properties [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible ) but at least I feel I can move foreward with this. – Jon Holland Jan 12 '15 at 14:27
  • Ok, good that it helped a bit. Sorry I didn't notice your post was earlier :). I'll add it as an answer. Your other problem might be the SSL. Check this [post](http://www-01.ibm.com/support/docview.wss?uid=swg21614221). You can create new question, if you will still have issues. – Gas Jan 12 '15 at 15:14
  • Hi again Gas. I have recreated my little application on the server itself and indeed it is connecting there so looks like some security or permissions issue. Websphere already had the iiop security settings set to SSL supported. I just want to get on and programme...get deflated with these sorts of things as I just don't have experience with this side. Thanks for you input. – Jon Holland Jan 12 '15 at 17:14
  • 1
    Please find one more possible solution on [this topic](http://stackoverflow.com/a/36798643/3749321) – ParanoidUser Apr 22 '16 at 16:15
  • Thanks for keeping this post updated @ParanoidUser - 15 months after the original – Jon Holland Apr 25 '16 at 09:11

1 Answers1

8

The class sun.io.MalformedInputException doesn't exist in Java 8, and also Java 8 is not supported as client to WebSphere Application Server v 8.5. Please use Java 6 or 7.

Gas
  • 17,601
  • 4
  • 46
  • 93
  • I am in a similar situation - but I really want to use Java 8. its been just over an year since the last comment from @Gas. I am wondering if things have changed and if I can now use Java 8. if it benefits, I am using IBM JDK 8 inside WebSphere Liberty Profile – vamsi-vegi Mar 17 '16 at 19:04
  • looks like there is a patch APAR from IBM: http://www-01.ibm.com/support/docview.wss?uid=swg1IX90160 – vamsi-vegi Mar 17 '16 at 19:15