Reputation: 17
I am working on an java application running on an AS400 server.
try {
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
String doTrace = AppProp.getInstance().getProperty("trace.enabled");
if("true".equals(doTrace)){
Trace.setTraceAllOn(true);
String tracefile = AppProp.getInstance().getProperty("trace.file");
new File(tracefile).createNewFile();
Trace.setFileName(tracefile);
Trace.setTraceOn(true);
log.warn("Trace Enabled");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ExceptionInInitializerError(e);
}
and this
try {
if ("true".equals(local)) {
user = "*CURRENT";
password = "*CURRENT";
}
connection = DriverManager.getConnection(url, user, password);
} finally{
//do something here...
}
With the url beeing jdbc:as400://10.65.1.31/QSYS.LIB
When running on a windows server connecting to the AS400 i works fine, but when running locally on the AS400 i get the exception:
at com.df.info2000.as400Worker.AS400SQLConnection.getConnection(AS400SQLConnection.java:66)
at com.df.info2000.as400Worker.AS400FileAccess.initConnection(AS400FileAccess.java:62)
at com.df.info2000.as400Worker.AS400FileAccess.<init>(AS400FileAccess.java:50)
at com.df.info2000.as400Worker.AS400FileIterator.<init>(AS400FileIterator.java:23)
at com.df.info2000.wscom.WSCOMTransferFileThradsafe.connectAS400Iterator(WSCOMTransferFileThradsafe.java:674)
at com.df.info2000.wscom.WSCOMTransferFileThradsafe.initialize(WSCOMTransferFileThradsafe.java:132)
... 1 more
Caused by: java.lang.NullPointerException
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Exception.java:29)
at java.lang.RuntimeException.<init>(RuntimeException.java:32)
at java.lang.NullPointerException.<init>(NullPointerException.java:36)
at com.ibm.as400.access.SocketContainerUnix.getInputStream(SocketContainerUnix.java:65)
at com.ibm.as400.access.AS400ImplRemote.signonConnect(AS400ImplRemote.java:1834)
at com.ibm.as400.access.AS400ImplRemote.getConnection(AS400ImplRemote.java:957)
at com.ibm.as400.access.AS400ImplRemote.connect(AS400ImplRemote.java:392)
at com.ibm.as400.access.AS400.connectService(AS400.java:822)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2764)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1040)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:931)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.df.info2000.as400Worker.AS400SQLConnection.getConnection(AS400SQLConnection.java:51)
... 6 more
From the trace log i have now found this:
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Error retrieving GSSToken:
org.ietf.jgss.GSSException, major code: 11, minor code: 0
major string: General failure, unspecified at GSSAPI level
minor string: Error: com.ibm.security.krb5.KrbException, status code: 0
message: java.security.PrivilegedActionException: java.io.FileNotFoundException: No such path or directory. /etc/krb5/krb5.conf
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Exception.java:29)
at org.ietf.jgss.GSSException.<init>(GSSException.java:181)
at com.ibm.security.jgss.i18n.I18NException.throwGSSException(I18NException.java:5)
at com.ibm.security.jgss.mech.krb5.bb.b(bb.java:32)
at com.ibm.security.jgss.mech.krb5.bb.a(bb.java:154)
at com.ibm.security.jgss.mech.krb5.bb.<init>(bb.java:36)
at com.ibm.security.jgss.mech.krb5.Krb5MechFactory.getNameElement(Krb5MechFactory.java:44)
at com.ibm.security.jgss.GSSManagerImpl.a(GSSManagerImpl.java:19)
at com.ibm.security.jgss.GSSNameImpl.a(GSSNameImpl.java:17)
at com.ibm.security.jgss.GSSNameImpl.canonicalize(GSSNameImpl.java:0)
at com.ibm.security.jgss.GSSNameImpl.<init>(GSSNameImpl.java:173)
at com.ibm.security.jgss.GSSManagerImpl.createName(GSSManagerImpl.java:14)
at com.ibm.as400.access.TokenManager.getGSSToken(TokenManager.java:35)
at com.ibm.as400.access.AS400.signon(AS400.java:3359)
at com.ibm.as400.access.AS400.connectService(AS400.java:821)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2764)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1040)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:931)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.df.info2000.as400Worker.AS400SQLConnection.getConnection(AS400SQLConnection.java:67)
at com.df.info2000.as400Worker.AS400FileAccess.initConnection(AS400FileAccess.java:62)
at com.df.info2000.as400Worker.AS400FileAccess.<init>(AS400FileAccess.java:50)
at com.df.info2000.as400Worker.AS400FileIterator.<init>(AS400FileIterator.java:23)
at com.df.info2000.wscom.WSCOMTransferFileThradsafe.connectAS400Iterator(WSCOMTransferFileThradsafe.java:674)
at com.df.info2000.wscom.WSCOMTransferFileThradsafe.initialize(WSCOMTransferFileThradsafe.java:132)
at com.df.info2000.wscom.MainExtract.main(MainExtract.java:62)
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Signing-on without prompting...
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Current userID in EBCDIC:
D3 C5 C3 D4 D6 C8 40 40 40 40
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Current userID: 'LECMOH'
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Current userID in EBCDIC:
D3 C5 C3 D4 D6 C8 40 40 40 40
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Current userID: 'LECMOH'
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Sign-on completed.
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Service disconnected implementation: as-signon
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Establishing connection to server: as-database
Thread[Thread-0,5,main] Wed Oct 01 09:17:51 CEST 2014 Starting a local socket to as-signon
Can you see what may be the problem ?
We are running on an AS400 version R610
For some reason the program is trying to authenticate the user with Kerberos - even if i provide the parameter AuthenticationMethod=client
Now i am trying to get some remote debugging up and running so we are modifying our CL command to this:
RUNJVA CLASS('com.df.info2000.wscom.MainExtract')
CLASSPATH('/DFWSCOM/config/')
OPTIMIZE(*JIT) INTERPRET(*JIT)
PROP(
(os400.xrun.option 'jdwp:transport=dt_socket,address=8000,
server=y,suspend=y')
(java.security.krb5.conf
'/QIBM/ProdData/OS400/NetworkAuthentication/krb5.conf')
(java.ext.dirs
'/DFWSCOM/lib/')) GCHINL(240000000)
GCHMAX(*NOMAX) JOB(WSCOVFC) OUTPUT(*NONE)
But it ends with this message:
Message . . . . : An error occurred during JVM_OnLoad processing of *SRVPGM
JDWP15. The error code is 3.
Årsag . . . . . : The JVM_OnLoad function did not complete for *SRVPGM
JDWP15 because of error code 3. The error codes are defined as follows: 1 -
The JVM was unable to locate the service program. 2 - The JVM was unable to
activate the service program. 3 - The JVM was unable to locate the
JVM_OnLoad function. 4 - Error code 0 was returned from the JVM_OnLoad
My AS400 guy says it doesn't understand the os400.xrun.option - can anyone see what we are doing wrong ?
Well - now we have moved the program to the prod environment to see if it would run there - and magically it would, so there is something wrong with our test AS400. So for now it works in prod, and we live with the problem on the test server...
Upvotes: 1
Views: 1932
Reputation: 586
It looks like you have a couple problems.
You need to upgrade your jt400.jar file, as the tracepoints don't seem to match the latest jt400.jar tracepoints. The latest PTFs for V6R1 are SI53962 and SI53963.
You should be using null pointers instead of *CURRENT. Allowing the use of *CURRENT is a security exposure for older versions of JTOpen and has been disallowed. Consequently, your code should look like the following.
if ("true".equals(local)) {
user = null;
password = null;
}
Upvotes: 0
Reputation: 484
Actually I don't know what have you tried so far but Just Follow this code and verify yourself and get solved...!!!
Connection con = null;
try {
Class.forName("com.ibm.as400.access.AS400JDBCDriver);
} catch(ClassNotFoundException e) {
System.out.println(e);
System.exit(0);
}
try {
con = DriverManager.getConnection("jdbc:as400://yourserver", "yourUserId", "yourPassword");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM YOURLIB.YOUR_PF_FILE");
while (rs.next()) {
String field1 = rs.getString(1);
String field2 = rs.getString("fieldname");
.....
} catch(Exception e) {
.....
}
I Hope this will help you
Upvotes: 0