TM1 Java API - open connection error

Post Reply
krishnadixit
Posts: 31
Joined: Fri Oct 14, 2011 6:44 am
OLAP Product: TM1, COGNOS
Version: TM1 9_5 Cognos Planning 8_4
Excel Version: 2007
Location: Mumbai, India

TM1 Java API - open connection error

Post by krishnadixit »

Hi All,
I've TM1 10.2.2 FP5 and java 1.8.0_92 environment.

I installed FP5 last week and all of sudden my java code stopped working. Even the simplest code gives me error. Has IBM changed anything in background.

Here is my simple code:

Code: Select all

import com.applix.tm1.*;

public class TM1_Connect {	
	TM1Server ts=null;
	TM1Bean tb=null;	
	
	TM1_Connect(){
		try{			
			ts = new TM1Server();
			tb = new TM1Bean();
			tb.setDebugMode(true);
            		tb.setAdminHost("localhost");			
			ts = tb.openConnection("SData", "admin", "apple");
		}catch (Exception ex){
			System.out.println("tm1 err # "+ex);
		}
	}
	public static void main(String[] args) {	
		System.out.println("Hello world");
		TM1_Connect tc = new TM1_Connect();
	}
}

And I get this error:

Code: Select all

TM1 Error-> Error creating socket - java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.<init>(Unknown Source)
	at sun.security.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
	at com.applix.tm1.TM1NetClass.ConnectToHost(TM1NetClass.java:254)
	at com.applix.tm1.TM1NetClass.ConnectUsingIPv6(TM1NetClass.java:203)
	at com.applix.tm1.TM1NetClass.Connect(TM1NetClass.java:169)
	at com.applix.tm1.TM1Bean.getAdmEntryList(TM1Bean.java:539)
	at com.applix.tm1.TM1Bean.getNumberOfServers(TM1Bean.java:369)
	at com.applix.tm1.TM1Bean.findEntryByServerName(TM1Bean.java:629)
	at com.applix.tm1.TM1Bean.openConnection(TM1Bean.java:188)
	at TM1_Connect.<init>(TM1_Connect.java:13)
	at TM1_Connect.main(TM1_Connect.java:20)
tm1 err # java.lang.IllegalArgumentException: SSL_TLSv2
What is this? java.lang.IllegalArgumentException: SSL_TLSv2

My big java program stopped working after FP5. I then installed FP6 and tested but no success, then I uninstalled the TM1 and reinstalled with FP5. No success.

I've checked all my settings and configurations. It was running smoothly till last week.

Have anybody faced this issue lately? Can anybody suggest the probable solution.

P.S. I am facing same problem in my REST API java code too
BrianL
MVP
Posts: 264
Joined: Mon Nov 03, 2014 8:23 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2 PA2
Excel Version: 2016

Re: TM1 Java API - open connection error

Post by BrianL »

Did you also grab an IF for FP5?

This looks like an issue I've seen where some IBM updates to enforce TLS 1.2 security only work with the IBM JRE and not with the Oracle JRE.

The IBM jre is provided as part of the install kit in the <path_to_install_location>/bin(64)/jre/ folder.
krishnadixit
Posts: 31
Joined: Fri Oct 14, 2011 6:44 am
OLAP Product: TM1, COGNOS
Version: TM1 9_5 Cognos Planning 8_4
Excel Version: 2007
Location: Mumbai, India

Re: TM1 Java API - open connection error

Post by krishnadixit »

Yes,
This weekend I uninstalled and re-installed TM1 with FP5 - No success
then with FP4 - No success
then with only base TM1 - No success.

This problem started only after I installed FP5 & FP6. It was working fine with FP4 and Oracle JRE.

Further the question is if it only works with IBM JRE then how can we make it work with Oracle JRE as well?
BrianL
MVP
Posts: 264
Joined: Mon Nov 03, 2014 8:23 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2 PA2
Excel Version: 2016

Re: TM1 Java API - open connection error

Post by BrianL »

The problem is that the TM1JavaApi jar file uses some IBM JRE specific code. I'm not aware of any workaround that would allow you to use the Oracle JRE instead. I don't know off the top of my head if IBM even supports the use of the TM1JavaApi with the Oracle JRE. If they do you could file a bug.

In my experience I've only seen this with the FP6 jar or one of the recent FP5 IF releases. You should be able to continue using the FP4 TM1JavaApi.jar with a FP5/FP6 server with no problems at all.
kjanssen
Posts: 17
Joined: Mon Jan 19, 2015 12:43 pm
OLAP Product: Cognos Express
Version: 10.2.2
Excel Version: 2010

Re: TM1 Java API - open connection error

Post by kjanssen »

I was able to workaround this issue by calling the following code before connecting.

Code: Select all

System.setProperty("com.ibm.jsse2.overrideDefaultProtocol", "TLSv1.2");
I found the "TLSv1.2" name here: http://grepcode.com/file/repository.gre ... rsion.java
kjanssen
Posts: 17
Joined: Mon Jan 19, 2015 12:43 pm
OLAP Product: Cognos Express
Version: 10.2.2
Excel Version: 2010

Re: TM1 Java API - open connection error

Post by kjanssen »

As I had a follow up issue with the SSL certificate where I found no solution for other than "add the certificates to your JVM keystore" - what i have done - i decided to disable certificate check for this. (also the communication is localhost only so there is near to zero chance for man-in-the-middle)

Code: Select all

	private static class SslCertFix {

		private static void disableCertCheck() {

			// Tell the TM1 Api to use TLSv1.2 to run on Oracle JVM
			System.setProperty("com.ibm.jsse2.overrideDefaultProtocol",
			    "TLSv1.2");

			try {
				TrustManager[] trustAllCerts =
				        new TrustManager[] {new X509TrustManager() {

					        @Override
					        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
						        return null;
					        }

					        @Override
					        public void checkClientTrusted(
					                X509Certificate[] certs, String authType) {
					        }

					        @Override
					        public void checkServerTrusted(
					                X509Certificate[] certs, String authType) {
					        }

				        }};

				SSLContext sc = SSLContext.getInstance("SSL");
				sc.init(null, trustAllCerts, new java.security.SecureRandom());
				SSLContext.setDefault(sc);
			} catch (Throwable e) {
				throw new IllegalStateException("unable to bypass ssl check",
				    e);
			}
		}
	}
Drg
Regular Participant
Posts: 159
Joined: Fri Aug 12, 2016 10:02 am
OLAP Product: tm1
Version: 10.2.0 - 10.3.0
Excel Version: 2010

Re: TM1 Java API - open connection error

Post by Drg »

HEY MAN use tm1 JRE in your eclips project
C:\Program Files\ibm\cognos\tm1_64\bin\jre\7.0
C:\Program Files\ibm\cognos\tm1_64\bin64\jre\7.0
JUST copy this folder on your comp append new envierment varible(path) on your computer
or
in your eclips project > property > java build path > java system library
kjanssen
Posts: 17
Joined: Mon Jan 19, 2015 12:43 pm
OLAP Product: Cognos Express
Version: 10.2.2
Excel Version: 2010

Re: TM1 Java API - open connection error

Post by kjanssen »

Hey Drg,

unfortunately this is not possible. As the project using the TM1 API requires Java8 and the JRE provided by TM1 is only Java7.
Drg
Regular Participant
Posts: 159
Joined: Fri Aug 12, 2016 10:02 am
OLAP Product: tm1
Version: 10.2.0 - 10.3.0
Excel Version: 2010

Re: TM1 Java API - open connection error

Post by Drg »

kjanssen wrote:Hey Drg,

unfortunately this is not possible. As the project using the TM1 API requires Java8 and the JRE provided by TM1 is only Java7.
After FIXPACK 4 ibm change core JRE.
Maybe you help downgrade tm1 to 10.2.2 fp4 :o
Post Reply