From owner-freebsd-java@FreeBSD.ORG Fri Jun 24 12:04:46 2005 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F61416A41C for ; Fri, 24 Jun 2005 12:04:46 +0000 (GMT) (envelope-from achill@matrix.gatewaynet.com) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id C5C8643D1D for ; Fri, 24 Jun 2005 12:04:44 +0000 (GMT) (envelope-from achill@matrix.gatewaynet.com) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id j5OBpUBS012649 for ; Fri, 24 Jun 2005 14:51:30 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id j5OBpTXw012645 for ; Fri, 24 Jun 2005 14:51:30 +0300 Date: Fri, 24 Jun 2005 14:51:29 +0300 (EEST) From: Achilleus Mantzios To: freebsd-java@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT Subject: Wierd problem in linux 2.4.18-bf2.4, Java Blackdown-1.4.2-rc1 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2005 12:04:46 -0000 Ok its linux a problem, but i think it would be interesting to you. 1st off, this problem does not occur in FreeBSD 5.4-STABLE, with java 1.4.2p7. (Kudos to FreeBSD java team!!!) The situation is as follows: >From a jsp i call java.lang.Process proc = Runtime.getRuntime().exec("/usr/local/sbin/uucico_command"); proc.waitFor(); /usr/local/sbin/uucico_command has as follows: ------------------------------------------------------------ #!/bin/sh /bin/rm -f /var/lock/LCK..ttyS* /usr/local/var/lib/pgsql/dbmirror/AsyncMirrorWithSpecialTables.pl /usr/local/var/lib/pgsql/dbmirror/OFFICE.conf /usr/local/sbin/gpsavg epochsecs=`date +'%s'` pushd /usr/local/var/XML_TO_OFFICE/ tar cfj As_AND_Ds_$epochsecs.tar.bz2 A*.xml D*.xml \rm -f A*.xml D*.xml popd /usr/bin/bzip2 /usr/local/var/XML_TO_OFFICE/* export PGUSER=postgres export PGPASSWORD="" vessel_name=`/usr/local/pgsql/bin/psql -A -q -t -h localhost dynacom -c "select replace(lower(name),' ','_') from vessels limit 1"` VESSEL_NAME=`/usr/local/pgsql/bin/psql -A -q -t -h localhost dynacom -c "select replace(name,' ','_') from vessels limit 1"` uucp -r /usr/local/var/XML_TO_OFFICE/*.bz2 uucphub\!/usr/local/var/XML_FROM_VESSELS/$VESSEL_NAME/. /bin/rm -fr /usr/local/var/XML_TO_OFFICE/* /bin/rm -fr /var/spool/uucppublic/outbound > /dev/null 2>&1 /bin/rm -fr /var/spool/uucppublic/inbound > /dev/null 2>&1 outbound=`/usr/bin/wc -c /var/spool/uucp/uucphub/D./* 2>/dev/null | tail -1 | awk '{print $1}'` outbound=${outbound:=0} echo $outbound > /var/spool/uucppublic/outbound 2>/dev/null uucp -r -g 0 /var/spool/uucppublic/outbound uucphub\!/var/spool/uucppublic/$vessel_name.inbound \rm -fr /var/spool/uucp/.Status/uucphub uucp_acct_id=`/usr/local/sbin/dyna_psql $outbound 2>/dev/null` /usr/local/sbin/dyna_log_uucp_acct_update $uucp_acct_id uucico -x 4 -f -s uucphub uucpsc=`/bin/cat /var/spool/uucp/.Status/uucphub | /usr/bin/awk '{print $1}'` uucpsc=${uucpsc:=99} #logger -p uucp.info "NOTICE!!! acctid="$uucp_acct_id "uucpsc="$uucpsc /usr/local/j2sdk1.4.2/bin/java -cp "/usr/local/jboss-3.0.3/server/default/SMA_UUCP.jar:/usr/local/pgsql/share/java/postgresql.jar:/usr/local/jboss-3.0.3/client/log4j.jar" com.gatewaynet.uucp.LogUUCPAcct $uucp_acct_id $uucpsc /usr/local/j2sdk1.4.2/bin/java -cp "/usr/local/jboss-3.0.3/server/default/SMA_UUCP.jar:/usr/local/pgsql/share/java/postgresql.jar:/usr/local/jboss-3.0.3/client/log4j.jar:/usr/local/jboss-3.0.3/server/default/lib/activation.jar:/usr/local/jboss-3.0.3/server/default/lib/mail.jar" com.gatewaynet.uucp.SendCollected pushd /usr/local/var/XML_FROM_OFFICE/ for ASDS in As_AND_Ds*.tar.bz2; do tar xfj $ASDS; rm -f $ASDS; done popd /usr/bin/bunzip2 /usr/local/var/XML_FROM_OFFICE/*.bz2 ############################################ ### The command below is the problematic one ############################################ /usr/local/jboss-3.0.3/server/default/readoff /etc/cron.daily/compstatus & ------------------------------------------------------------ now the problematic /usr/local/jboss-3.0.3/server/default/readoff has as follows ------------------------------------------------------------ #!/bin/sh export CLASSPATH="/usr/local/jboss-3.0.3/server/default/SMA_PER.jar:/usr/local/jboss-3.0.3/server/default/xerces.jar:/usr/local/jboss-3.0.3/client/jbossall-client.jar:/usr/local/jboss-3.0.3/client/log4j.jar:/usr/local/pgsql/share/java/postgresql.jar" /usr/local/j2sdk1.4.2/bin/java -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl com.gatewaynet.periodic.ReadXmlFromOffice ------------------------------------------------------------ whereas ReadXmlFromOffice.java has as follows: ------------------------------------------------------------ /* * Created on 19 Ìáñ 2004, 11:55:47 ðì * */ package com.gatewaynet.periodic; import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; import java.sql.PreparedStatement; import java.util.Arrays; import java.util.Comparator; import org.w3c.dom.Node; /** * @author achill4 * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class ReadXmlFromOffice { private static String XMLFROMDIR = "/usr/local/var/XML_FROM_OFFICE"; private static String XMLTODIR = "/usr/local/var/XML_TO_OFFICE"; private static String FILEDIR = "/usr/local/var/FILES_FROM_OFFICE"; static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("dynacom.RXML"); /** * */ public ReadXmlFromOffice() { super(); // TODO Auto-generated constructor stub } public static void main(String[] args) { java.sql.Connection con=null; try { javax.naming.InitialContext ic = new javax.naming.InitialContext(); Class.forName("org.postgresql.Driver"); con = java.sql.DriverManager.getConnection("jdbc:postgresql://localhost/dynacom","postgres",""); con.setAutoCommit(false); PreparedStatement vslidst = con.prepareStatement("select id from vessels limit 1"); java.sql.ResultSet vslidrs = vslidst.executeQuery(); if (!vslidrs.next()) throw new Exception("No vessel in database. Contact IT DEPT."); int thisvesselvslid = vslidrs.getInt(1); vslidrs.close(); vslidst.close(); con.commit(); javax.xml.parsers.DocumentBuilderFactory builderFactory =javax.xml.parsers.DocumentBuilderFactory.newInstance(); builderFactory.setValidating(false); javax.xml.parsers.DocumentBuilder builder =builderFactory.newDocumentBuilder(); builder.setErrorHandler(new com.gatewaynet.web.util.xml.MyErrorHandler()); File xmldir = new File(XMLFROMDIR); File[] xmlfiles = xmldir.listFiles(); Arrays.sort(xmlfiles,new DirComparator()); String[] xerrors = new String[xmlfiles.length]; String lastdone=null; int numxerrors=0; int xmli; for (xmli = 0; xmli < xmlfiles.length; xmli++) { File xmlfile = xmlfiles[xmli]; try { String xmlfilename =xmlfile.getName(); if (!xmlfilename.endsWith(".xml") && !xmlfilename.endsWith(".XML")) continue; org.w3c.dom.Document document = builder.parse(xmlfile); org.w3c.dom.Element rootel = document.getDocumentElement(); org.w3c.dom.NamedNodeMap attrs = rootel.getAttributes(); String xidstr=null; String vslidstr=null; org.w3c.dom.Attr attr; attr = (org.w3c.dom.Attr) attrs.getNamedItem("xid"); xidstr = attr.getValue(); attr = (org.w3c.dom.Attr) attrs.getNamedItem("vslid"); vslidstr = attr.getValue(); org.w3c.dom.Node curnd; org.w3c.dom.NodeList nodes = rootel.getChildNodes(); String appname=null; String apptbl_tmp=null; String gao=null; String idstr=null; String SQL=null; String comment=null; String filename=null; String file_base64=null; String unixcommand=null; for (int i = 0; i < nodes.getLength(); i++) { curnd = nodes.item(i); if (curnd.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) { if (((org.w3c.dom.Element) curnd).getTagName().equals("appname")) appname = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); if (((org.w3c.dom.Element) curnd).getTagName().equals("apptbl_tmp")) apptbl_tmp = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); if (((org.w3c.dom.Element) curnd).getTagName().equals("id")) idstr = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); if (((org.w3c.dom.Element) curnd).getTagName().equals("gao")) gao = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); if (((org.w3c.dom.Element) curnd).getTagName().equals("sql")) { Node sqlnode = curnd.getFirstChild(); if (sqlnode != null) SQL = ((org.w3c.dom.CDATASection) curnd.getFirstChild()).getData(); } if (((org.w3c.dom.Element) curnd).getTagName().equals("comment")) { Node commentnode = curnd.getFirstChild(); if (commentnode != null) comment = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); } /** * file transfer kai unix commands */ if (((org.w3c.dom.Element) curnd).getTagName().equals("filename")) { Node filenamenode = curnd.getFirstChild(); if (filenamenode != null) filename = ((org.w3c.dom.Text) curnd.getFirstChild()).getData(); } if (((org.w3c.dom.Element) curnd).getTagName().equals("filecontent")) { Node filecontentnode = curnd.getFirstChild(); if (filecontentnode != null) file_base64 = ((org.w3c.dom.CDATASection) curnd.getFirstChild()).getData(); } if (((org.w3c.dom.Element) curnd).getTagName().equals("unixcommand")) { Node unixcommandnode = curnd.getFirstChild(); if (unixcommandnode != null) unixcommand = ((org.w3c.dom.CDATASection) curnd.getFirstChild()).getData(); } } } if (xidstr == null) throw new Exception("xid is null"); int xid = Integer.parseInt(xidstr); if (vslidstr == null) throw new Exception("vslid is null"); int vslid = Integer.parseInt(vslidstr); if (gao == null) throw new Exception("gao is null"); if (vslid != thisvesselvslid && !gao.equals("FLTRAN") && !gao.equals("UNXCOM")) throw new Exception("This Transaction is for Another Vessel. Contact IT DEPT."); logger.info("Processing file "+xmlfilename); if (gao.equals("ACKNOW")) { PreparedStatement st = con.prepareStatement("update xadmin set state='ARC' where xid=?"); st.setInt(1,xid); int rc = st.executeUpdate(); if (rc != 1) throw new Exception("Error updating xadmin to ARC."); st.close(); } else if (gao.equals("CANCEL")) { PreparedStatement st = con.prepareStatement("update xadmin set state='CAN',comment=? where xid=?"); st.setString(1,comment); st.setInt(2,xid); int rc = st.executeUpdate(); if (rc != 1) throw new Exception("Error updating xadmin to ARC."); st.close(); } else if (gao.equals("REPLIC")) { logger.info("IN REPLIC for file "+xmlfilename); // EDW MAS ENDIAFEREI MONO TO SQL. java.sql.Statement st2 = con.createStatement(); logger.info("IN REPLIC after createStatement for file "+xmlfilename); if (SQL != null) st2.execute(SQL); logger.info("IN REPLIC after execute for file "+xmlfilename); st2.close(); } else if (gao.equals("FLTRAN")) { if (filename == null) throw new Exception("File name in file transfer cannot be null. Contact IT DEPT."); if (file_base64 == null) throw new Exception("File content in file transfer cannot be null. Contact IT DEPT."); byte[] filecontent = Base64.decode(file_base64.toCharArray()); File outfile = new File(FILEDIR+"/"+filename); FileOutputStream fout = new FileOutputStream(outfile); fout.write(filecontent); fout.close(); } else if (gao.equals("UNXCOM")) { if (unixcommand == null) throw new Exception("Command in unix command cannot be null. Contact IT DEPT."); // PROSOXH SE size(unixcommands)/1024 > (getconf ARG_MAX) Process proc = Runtime.getRuntime().exec(new String[] {"sh","-c",unixcommand}); FileOutputStream fout = new FileOutputStream(new File(XMLTODIR+"/"+xmlfile.getName().replaceAll(".xml","")+".out")); PrintStream out = new PrintStream(fout); java.io.InputStream procout = proc.getInputStream(); out.println("=============="); out.println("Output (if any)"); out.println("=============="); int c; while ((c=procout.read()) >=0) { out.write(c); //System.out.write(c); //System.out.flush(); } java.io.InputStream procerr = proc.getErrorStream(); out.println("=============="); out.println("Error (if any)"); out.println("==============="); while ((c=procerr.read()) >=0) { out.write(c); //System.out.write(c); //System.out.flush(); } } else throw new Exception("GAO "+gao+" not supported. CONTACT IT DEPT."); con.commit(); boolean isdeled = xmlfile.delete(); if (!isdeled) throw new Exception("Error deleting file. Xaction Aborted."); System.out.println("OK with file "+xmlfile.getName()); lastdone=xmlfile.getName(); } catch (Exception xmle) { System.out.println("Error : "+xmle.getMessage()+": with file "+xmlfile.getName()); logger.error("Error : "+xmle.getMessage()+": with file "+xmlfile.getName()); //xmle.printStackTrace(); con.rollback(); xerrors[numxerrors++]="--------------------------"+"Error with "+xmlfile.getName()+"--------------------------\n"+ xmle.getMessage()+"\n"+"---------------------------------------------------------------------"; xmlfile.delete(); } } // end for if (lastdone != null) { FileOutputStream fout = new FileOutputStream(new File(XMLTODIR+"/lastdone.mon")); PrintStream out = new PrintStream(fout); out.println("Last XML was "+lastdone); } if (numxerrors!=0) { FileOutputStream fout = new FileOutputStream(new File(XMLTODIR+"/xerror.mon")); PrintStream out = new PrintStream(fout); int run; for (run=0;run