我正在AS400服务器上运行的Java应用程序上工作。

    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);

    }


还有这个

    try {

        if ("true".equals(local)) {
            user = "*CURRENT";
            password = "*CURRENT";
        }
        connection = DriverManager.getConnection(url, user, password);

    } finally{
        //do something here...
    }


使用url beeing jdbc:as400://10.65.1.31/QSYS.LIB

在连接到AS400的Windows服务器上运行时,我工作正常,但是在AS400上本地运行时,出现异常:

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


从跟踪日志中,我现在发现了这一点:

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


您知道可能是什么问题吗?

我们在AS400版本R610上运行

由于某种原因,程序试图使用Kerberos验证用户-即使我提供了参数AuthenticationMethod = client

现在,我试图启动和运行一些远程调试,因此我们将CL命令修改为:

 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)


但这以以下消息结尾:
信息 。 。 。 。 :* SRVPGM的JVM_OnLoad处理期间发生错误
  JDWP15。错误代码是3。
Årsag。 。 。 。 。 :* SRVPGM的JVM_OnLoad函数未完成
  JDWP15由于出现错误代码3。错误代码定义如下:1-
  JVM无法找到服务程序。 2-JVM无法执行
  激活服务程序。 3-JVM无法找到
  JVM_OnLoad函数。 4-从JVM_OnLoad返回错误代码0

我的AS400员工说它不了解os400.xrun.option-有人能看到我们在做什么吗?

好吧-现在我们将程序移至产品环境中,看看它是否可以在此处运行-神奇地它将在那里运行,因此我们的测试AS400出了点问题。所以现在它可以在产品中使用,并且我们可以在测试服务器上解决这个问题。

最佳答案

其实我不知道您到目前为止已经尝试了什么,但是只需遵循以下代码并验证自己即可解决... !!!

 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) {

              .....

          }


我希望这能帮到您

09-27 12:17