Java.util.zip not handling Unicode filenames

I have a zip file that contains files with Asian filenames. java.util.zip.ZipFile opens it, but the filenames are garbled. Is there any way to handle filenames that contain unicode characters?

Of course, compression works on bytes, not some higher level constructs like Strings or files.
You can use the ZipOutputStream or DeflaterOutputStream for compression.
And the javadoc for Deflater even has a code example of compressing a String.
Edited by: Kayaman on May 22, 2011 5:04 PM

Similar Messages

  • How do I compress a string with  java.util.zip - not a file ?

    How do I compress a string with java.util.zip?
    Is possible to compress something else except a file?

    Of course, compression works on bytes, not some higher level constructs like Strings or files.
    You can use the ZipOutputStream or DeflaterOutputStream for compression.
    And the javadoc for Deflater even has a code example of compressing a String.
    Edited by: Kayaman on May 22, 2011 5:04 PM

  • Java.util.zip.ZipException: a device attached to the system is not function

    getting a java.util.zip.zipexception : a device attached to the system is not functioning error - what could cause such an error?
    My program finds all zip files in an archive and then searches through them for xls files, which it extracts and re-locates.
    I havent even a clue where to look for the cause of this exception but Ill attach at the bottom the code in the general vicitiny of the trigger so that you can get kind of an idea what Im trying to do, and if im lucky, even spot my problem. :) Thanks!!
    //zips is an array of zip files
    int found = 0;
    File[] haveXLs = new File[zips.length];
    for (int i = 0; i < zips.length; i++){
    String fileName = new String("L:/Vision/Archive/" + zips.getName());
    ZipFile archive = new ZipFile(fileName);
    String name = zips[i].getName().substring(0,8);
    for(Enumeration e = archive.entries(); e.hasMoreElements();){
    ZipEntry entry = (ZipEntry) e.nextElement();
    if(entry.getName().substring(0,8) == name){
    haveXLs[found] = zips[i];
    found++;

    Hey there a few things.
    Make sure that you dont use fileseparators like you do. ("/")
    Use the separator generated for your system.
    Something like:
    String sep = System.getProperty("file.separator");
    You mentioned it work local, but not network.
    Either you have plenty of harddrives or L: is a mapped drive.
    Is it working at the mapped drive?
    When you say on the network, how are you accessing the files?
    Could it be possible for another user to lock a file, so you wont have access to it over the network?
    BR.
    MagDy

  • Java.util.zip.ZipException: duplicate entry  ??? think not

    Ok I have jar file 3rd party, they have 2 entrys in their jar
    inetsoft/report/images/printer.gif and
    inetsoft/report/images/printer2.gif
    Those files are identical best i can tell, and they cause the error. Is there a way to the JWS in version based mode to look up files on full name alones... and don't warry about diffing files with diffrent names ???
    java.util.zip.ZipException: duplicate entry: inetsoft/report/images/printer2.gif
         at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:165)
         at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:93)
         at com.sun.javaws.jardiff.JarDiffPatcher.writeEntry(Unknown Source)
         at com.sun.javaws.jardiff.JarDiffPatcher.applyPatch(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.applyPatch(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.access$1(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol$RetrieveAction.actionDownload(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.doDownload(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
         at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
         at com.sun.javaws.Launcher.downloadResources(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:484)

    This sounds like an instance of bug: 4474211 (see http://developer.java.sun.com/developer/bugParade/bugs/4474211.html)
    you can try out the fix for this by loading the 1.2 beta from the j2se 1.4.1 beta release, and using the new version of the JNLPDownloadServlet that can be found in the 1.2-beta developers pack at: http://java.sun.com/products/javawebstart/download-jnlp.html

  • CMS not yielding to java.util.zip???

    Hello,
    I have been trying to track down some long pauses in our voldemort BDB JE server. It appears these pauses correspond to CMS concurrent phases. In one example below it is during the concurrent-mark and in the other example it is during concurrent-sweep. From what I have been able to piece together, the GC thread should be yielding to the applications threads soon after they post a yield request. But that doesn't appear to be happening below as far as I can tell. The application seems to hang until the CMS phase ends which can be several seconds with our 6g heap size.
    Am I interpreting things properly? Should the GC thread be yielding to the application yield requests? Threads dumps frequently show a thread as RUNNABLE at java.util.zip.Adler32.updateBytes(Native Method). This happens more frequently than I would expect by chance. Is it possible that the java.util.zip native method is unable to post the yield request??? I am running out of ideas here. Any suggestions would be appreciated.
    thanks,
    -sfp
    A strace shows:
    14914 14:52:08.217539 write(1, "1880.097", 8) = 8 <0.000023>
    14914 14:52:08.217619 write(1, ": ", 2) = 2 <0.000012>
    14914 14:52:08.217673 write(1, "[CMS-concurrent-sweep: 3.206/3.2"..., 40) = 40 <0.000013>
    14914 14:52:08.217724 write(1, " (CMS-concurrent-sweep yielded 0"..., 40) = 40 <0.000013>
    14914 14:52:08.217773 times({tms_utime=106915, tms_stime=19188, tms_cutime=0, tms_cstime=0}) = 558234922 <0.000015>
    14914 14:52:08.217829 write(1, " [Times: user=3.20 sys=0.00, rea"..., 45) = 45 <0.000012>
    14914 14:52:08.217879 write(1, "\n", 1) = 1 <0.000012>
    14914 14:52:08.217929 futex(0x2aac40a8a324, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0x464a9c18, 8) = 1 <0.000014>
    after which thread 14946 starts getting the WAKEs from the thread 14914 GC thread.
    14946 14:52:08.217975 <... futex resumed> ) = 0 <1.891633>
    14946 14:52:08.218028 futex(0x464a9c18, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
    14914 14:52:08.218063 futex(0x464a9c18, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
    14946 14:52:08.218085 <... futex resumed> ) = -1 EAGAIN (Resource temporarily unavailable) <0.000033>
    14946 14:52:08.218121 futex(0x464a9c18, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
    14914 14:52:08.218140 <... futex resumed> ) = 0 <0.000062>
    14946 14:52:08.218161 <... futex resumed> ) = 0 <0.000026>
    14946 14:52:08.218196 futex(0x47275e84, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0x464ab728, 62 <unfinished ...>
    And from a later run (look at the 2 seconds before the thread dump was forced):
    (the timelogger is a trivial webapp to log a timestamp to make sure we aren't in a Stop The World GC)
    -XX:+CMSClassUnloadingEnabled -XX:CMSCoordinatorYieldSleepCount=20 -XX:CMSYieldSleepCount=10 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/tmp -XX:+ManagementServer -XX:MaxHeapSize=6442450944 -XX:NewSize=314572800 -XX:+PrintCMSInitiationStatistics -XX:PrintCMSStatistics=2 -XX:+PrintClassHistogram -XX:+PrintCommandLineFlags -XX:PrintFLSStatistics=1 -XX:+PrintGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+TraceClassUnloading -XX:+UseConcMarkSweepGC
    1122.994: [GC [1 CMS-initial-mark: 4754072K(5324800K)] 4772017K(5601280K), 0.0044590 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
    Total time for which application threads were stopped: 0.0092070 seconds
    1122.999: [CMS-concurrent-mark-start]
    Dec 22, 2009 3:37:11 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2602 logged @ 2009-12-22.15:37:11.647 delta=250
    Dec 22, 2009 3:37:11 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2603 logged @ 2009-12-22.15:37:11.896 delta=249
    Dec 22, 2009 3:37:12 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2604 logged @ 2009-12-22.15:37:12.147 delta=251
    Dec 22, 2009 3:37:12 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2605 logged @ 2009-12-22.15:37:12.397 delta=250
    Dec 22, 2009 3:37:12 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2606 logged @ 2009-12-22.15:37:12.646 delta=249
    Dec 22, 2009 3:37:12 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2607 logged @ 2009-12-22.15:37:12.897 delta=251
    Dec 22, 2009 3:37:13 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2608 logged @ 2009-12-22.15:37:13.146 delta=249
    Dec 22, 2009 3:37:13 PM com.lotame.timelogger.TimeLoggerResource update
    INFO: sequence: 2609 logged @ 2009-12-22.15:37:13.396 delta=250
    Application time: 2.0828760 seconds
    2009-12-22 15:37:13
    Full thread dump Java HotSpot(TM) 64-Bit Server VM (10.0-b23 mixed mode):
    "voldemort-niosocket-server2" daemon prio=10 tid=0x00002aac40114800 nid=0x3d59 waiting on condition [0x00000000428c7000..0x00000000428c7d10]
    java.lang.Thread.State: RUNNABLE
    at java.util.zip.Adler32.updateBytes(Native Method)
    at java.util.zip.Adler32.update(Adler32.java:49)
    at com.sleepycat.je.log.ChecksumValidator.update(ChecksumValidator.java:61)
    at com.sleepycat.je.log.LogManager.getLogEntryFromLogSource(LogManager.java:713)
    at com.sleepycat.je.log.LogManager.getLogEntry(LogManager.java:664)
    at com.sleepycat.je.tree.IN.fetchTarget(IN.java:1215)
    at com.sleepycat.je.dbi.CursorImpl.searchAndPosition(CursorImpl.java:2103)
    at com.sleepycat.je.Cursor.searchInternal(Cursor.java:1778)
    at com.sleepycat.je.Cursor.searchAllowPhantoms(Cursor.java:1748)
    at com.sleepycat.je.Cursor.search(Cursor.java:1615)
    at com.sleepycat.je.Cursor.getSearchKey(Cursor.java:1067)
    at voldemort.store.bdb.BdbStorageEngine.get(BdbStorageEngine.java:169)
    at voldemort.store.bdb.BdbStorageEngine.get(BdbStorageEngine.java:126)
    at voldemort.store.bdb.BdbStorageEngine.getVersions(BdbStorageEngine.java:112)
    at voldemort.store.bdb.BdbStorageEngine.getVersions(BdbStorageEngine.java:67)
    at voldemort.store.DelegatingStore.getVersions(DelegatingStore.java:86)
    at voldemort.store.DelegatingStore.getVersions(DelegatingStore.java:86)
    at voldemort.server.protocol.vold.VoldemortNativeRequestHandler.handleGetVersion(VoldemortNativeRequestHandler.java:89)
    at voldemort.server.protocol.vold.VoldemortNativeRequestHandler.handleRequest(VoldemortNativeRequestHandler.java:74)
    at voldemort.server.niosocket.AsyncRequestHandler.read(AsyncRequestHandler.java:170)
    at voldemort.server.niosocket.AsyncRequestHandler.run(AsyncRequestHandler.java:98)
    at voldemort.server.niosocket.SelectorManager.run(SelectorManager.java:143)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)

    See http://blogs.oracle.com/charlesLamb/2006/09/adler32_vs_the_gc.html for a explanation of the base problem.
    See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6919638 for how the problem was greatly exacerbated by the -XX:+ExplicitGCInvokesConcurrent flag causing CMS to run its (slow) concurrent collection while silently keeping JNI blocked for the duration.

  • Java.util.zip.ZipException: invalid entry size error --  help required

    Hi all
    I am sure this error would have been posted many number of times, but I would really appreciate if someone could help me with my problem. I am working on reading data from a .zip file, which in it has ~5GB data. All I am performing is a read operation through the piece of code specified below. This code worked well for .zip files handling till ~2.5GB
    FileInputStream fis = new FileInputStream(filename);
    BufferedInputStream bis = new BufferedInputStream(fis);
    ZipInputStream zis = new ZipInputStream(bis);
    StreamTokenizer tok = new StreamTokenizer( zis );
    ZipEntry entry;
    while((entry = zis.getNextEntry()) != null)
    \\read from the zip file through the streamTokenizer
    I just print what I read through the program, on the console.
    But the error I get is
    java.util.zip.ZipException: invalid entry size (expected 4294967295 but got 2117536490 bytes)
    at java.util.zip.ZipInputStream.readEnd(Unknown Source)
    at java.util.zip.ZipInputStream.read(Unknown Source)
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at java.io.StreamTokenizer.read(Unknown Source)
    at java.io.StreamTokenizer.nextToken(Unknown Source)
    at ZipFileStreams.getMessages(ZipFileStreams.java:677)
    at ZipFileStreams.main(ZipFileStreams.java:814)
    Could anybody give me hints as to what am I missing and where am i going wrong. Any help would be appreciated.
    Thanks

    Hi,
    I get the same exception while reading a ZIP file. The size if the ZIP file is just 82KB but I am reading it over FTP not sure if it makes any difference. I am using JDK 1.4.2_05. Here is the code I am trying to execute.
    public class TestFTP {
    public static void main( String[] argv ) throws Exception {
    String inboundPath = "/transfer/inbound/";
    FTPClient ftp = new FTPClient();
    ftp.connect("123");
    ftp.login( "123", "123" );
    ftp.changeWorkingDirectory(inboundPath);
    FTPFile[] zipFiles = ftp.listFiles("*.zip");
    TelnetClient telnetClient;
    for(int i=0;i<zipFiles.length;i++){   
    System.out.println(zipFiles.getName());
    ZipInputStream zis = new ZipInputStream(ftp.retrieveFileStream(zipFiles[i].getName()));
    for (ZipEntry entry = zis.getNextEntry(); entry != null; entry = zis.getNextEntry()){           
    System.out.println(entry.getName());
    The error message is
    java.util.zip.ZipException: invalid entry size (expected 10291 but got 10233 bytes)
         at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:367)
         at java.util.zip.ZipInputStream.read(ZipInputStream.java:141)
         at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:91)
         at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:69)
         at test.TestFTP.main(TestFTP.java:41)
    Exception in thread "main"
    Please let me know if you were able to fix the problem.
    Thanks

  • Zip created through java.util.zip but problem in windows XP compress folder

    Hi friends,
    I am a software developer ,working on java/j2ee.currently i am working in a document management software related to logistics.Here i am facing a problem at the time of open the zip file through windows XP's in built software called "Folder compress".It's creared through java.util.zip.zipoutputstream.but at time of open through xp compress folder software ,it's showing error that "you can't open this file , this file are protected for your computer security" , but when i trying to open it through winzip or winrar, it's not giving any problem.My also specefing the code snippet below :-
    ZipOutputStream zip =  null;
         FileOutputStream fileWriter = null;
              try
                   fileWriter = new FileOutputStream(destZipFile);
                   zip = new ZipOutputStream(fileWriter);
                   //required for XP compress
                   zip.setMethod(ZipOutputStream.DEFLATED);
                zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
              }catch (Exception ex){
                   ex.printStackTrace();
                   System.exit(0);
              addFolderToZip("", srcFolder, zip);
              try
                   zip.flush();
                   zip.close();
                   zip=null;
                   fileWriter.close();
                   fileWriter = null;
              }catch (Exception ex)
                   //ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
              }I desperately looking for a help regarding this issue , if any body have any solution the please send at this forum.
    Thanks,
    Chiranjit

    this file working file for winzip or winrar there is no problem.i am also sending the whole code of that java file that can help you better.
    Program Name:     EdocRetrieveServiceSLBean.java
    Description:     EdocRetrieveService CMP Bean Class
    Classes:          EdocRetrieveServiceSLBean
    Package:          net.mlog.edoc.ejb.entity
    Modification History
    <CR No>          <Date>               <Modified By>               <Comments>
    Version 1.0     2005.12.01          Sutapa   Ray               Create
    /** The sequence of methods to be called.
       ===============================================================================================================================
       1. mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId)
       2. mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId)
              a) Start DIR --
              private  String DoFolder(String folderNname)
              b) Create the folder
              private String CreateFolder(String FolderName,String newFolderPath)
              c) Zip the folder
              private void zipFolder(String srcFolder, String destZipFile)
              d) Add folders to zip file
              private void addToZip(String path, String srcFile, ZipOutputStream zip)
              e) Add the srcFolder to the zip stream.
              private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
              f) Delete Directory from server
              public boolean deleteDir(File dir) {
       3. mpsDocumentView(String argUserId,Integer[] argSfxFileId)
       4. mlogOriginDocumentView(int argDocumentId,String argUserId)
       5. findDocTypeForDocId(Integer argDocId) throws RemoteException;
    package net.mlog.edoc.ejb.session;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import javax.ejb.CreateException;
    import javax.ejb.ObjectNotFoundException;
    import javax.ejb.FinderException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.naming.Context;
    import javax.rmi.PortableRemoteObject;
    import java.rmi.RemoteException;
    //import lib for all entity beans
    import net.mlog.edoc.ejb.entity.IDocumentCMP;
    import net.mlog.edoc.ejb.entity.IDocumentCMPHome;
    import net.mlog.edoc.ejb.entity.IDocumentTypeCMP;
    import net.mlog.edoc.ejb.entity.IDocumentTypeCMPHome;
    import net.mlog.edoc.ejb.entity.IDocumentAuditCMP;
    import net.mlog.edoc.ejb.entity.IDocumentAuditCMPHome;
    //import lib for reader class of properties file
    import net.mlog.edoc.ejb.session.PropertiesFileReader;
    //import lib for user Define File class
    import net.mlog.edoc.ejb.Session.EFile;
    //import lib for SFXWebClient
    import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSLHome;
    import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSL;
    import java.sql.Date;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import java.util.zip.Deflater;
    import java.util.Vector;
    import java.util.Iterator;
    import java.util.Collection;
    import java.util.StringTokenizer;
    import java.util.Enumeration;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.File;
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    //import lib for NGP Mail
    import javax.jms.Queue;
    import javax.jms.QueueConnectionFactory;
    import javax.jms.QueueConnection;
    import javax.jms.QueueSender;
    import javax.jms.QueueSession;
    import javax.jms.JMSException;
    import weblogic.jms.extensions.WLQueueSession;
    import weblogic.jms.extensions.XMLMessage;
    //import javax.mail.*;
    //import javax.mail.internet.*;
    //import lib for USI
    import com.msl.security.USIException;
    import com.msl.security.USIServerAPI;
    import com.msl.security.UserPolicyData;
    import net.msl.util.logging.MLogger;
    public class EdocRetrieveServiceSLBean implements SessionBean {
      private static final boolean VERBOSE = true;
      private SessionContext ctx;
      public void ejbActivate() {
      public void ejbRemove() {
      public void ejbPassivate() {
      public void setSessionContext(SessionContext ctx) {
        this.ctx = ctx;
      public void ejbCreate () throws CreateException {
      private static final MLogger logger;
      static
         logger = MLogger.getLogger(net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.class.getName(), "net/mlog/edoc/ejb/session/eDocRetrieveServiceMessagesXML");
    //*********************KEEPING AUDITS OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
    * <b>
    * Used for Auditing the user action.
    * </b>
    * This function is called from various functions of eDocController
    * <p>
    * @param  argActionDetails Gives the details of Action in document audit.
    * @param  argDocumentId gives the Document Id in Document Audit.
    * @param  argActionId Action Id in Document Audit.
    * @param  argActionByUserId User Id of the Docment Audit action.
    * @return Returns a boolean value. 1 for success, 0 for Failure.
    public boolean mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId) throws RemoteException
         //NGP/JDK Logging
         boolean flag=false;
    try{
         //getting context of the server
         InitialContext documentAuditCMPInitialContext=getInitialContext();
         Object objDocumentAuditCMPRef=null;
         try{
              objDocumentAuditCMPRef=documentAuditCMPInitialContext.lookup("DocumentAuditCMPBeanJNDI");
         catch(Exception e)
              //NGP/JDK Logging if JNDI Not found
              //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentAuditCMPBeanJNDI"});
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentAuditCMPBeanJNDI not found");
         //find the maximum audit id in the Document_Audit table
         //Home interface reference of DocumentAuditCMP EJB
         //IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)PortableRemoteObject.narrow(objDocumentAuditCMPRef,IDocumentAuditCMPHome.class);
         IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)objDocumentAuditCMPRef;
         //Remote interface reference of DocumentAuditCMP EJB
         IDocumentAuditCMP iDocumentAuditCMPCreateRef=iDocumentAuditCMPHomeRef.create(new Timestamp(System.currentTimeMillis()),argActionDetails,argActionByUserId,new Integer(argActionId),new Integer(argDocumentId));
         //set flag to true if Document is audited
         flag=true;
    }//end of try
    catch(Exception expt)
         //logger.finer(expt);
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.CreateException","Exception in creating Document Audit record");
      return flag;
    //*********************BATCH DOWNLOAD OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
    * <b>
    * Used for Validating the documents.
    * </b>
    * This function is called from Struts
    * <p>
    * @param  TREEDATA Treeset obtained after search.
    * @param  SessionIDVal gives the Session Value Id.
    * @return Returns a boolean value. 1 for success, 0 for Failure.
    public byte[] mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId) throws RemoteException
         //NGP/JDK Logging
         /*FileHandler handler = null;
        Logger logger=null;
         try
           PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
            String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
           handler = new FileHandler("eDoc.log",0,1, true);
           logger = Logger.getLogger("ErrorMsg");
           logger.addHandler(handler);
           logger.setLevel(Level.ALL);
        }catch(Exception excp)
             NGP/JDK Logging warning
             logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
         //Remote interface reference of SFXWebClientSL
         ISFXWebClientSL iSFXWebClientSLRef=null;
         //Home interface reference of SFXWebClientSL
         ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
         Vector filePath=new Vector();
         byte[] fileContent=null;
         String eDocRoot="";
         String eDocPathMain="";
         String eDocPath="";
         File tempRootFileforDelete = null;
         if (TREEDATA.capacity() != 0 )
              String BLNODirPath="";
              String PONODirPath="";
              String SONODirPath="";
              // added for doc type level--2005.11.27--samar
              String docTypeDirPath="";
              String filepath="";
              try
                 PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
                 filepath=propertiesFileReaderRef.getProperties("/edoc.properties","TEMP_FILE_DIR");
                 logger.finer("File Path:" +filepath);
              }catch(Exception excp)
                   excp.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.IOException","TEMP_FILE_DIR property (edoc.properties) not found");
              eDocRoot=CreateFolder("eDocTemp",filepath+File.separator);
              // added for top level--2005.12.02--samar
              //eDocRoot=CreateFolder("eDocTemp",System.getProperty("user.home")+File.separator);
              //eDocPath=CreateFolder(SessionIDVal,eDocRoot+File.separator);
              Enumeration TREEDATAEn = TREEDATA.elements();               //Setting The Tree Folder
              String   BLNO="";
              String   PONO="";
              String   SONO="";
              String   DNO ="";
              while(TREEDATAEn.hasMoreElements())
                   StringTokenizer st = new StringTokenizer((TREEDATAEn.nextElement()).toString(),"_");
                   while (st.hasMoreTokens()) // Extract All the Fields Of Every Vector Element
                        BLNO = st.nextToken();          // CSBWNO
                        PONO = st.nextToken();         // PONO
                        SONO = st.nextToken();        // SONO
                        DNO = st.nextToken();          // DNO
                        eDocPathMain=CreateFolder(SessionIDVal,eDocRoot+File.separator);
                        eDocPath=CreateFolder("eDoc",eDocPathMain+File.separator);
                        BLNODirPath = CreateFolder(BLNO,eDocPath+File.separator);
                        PONODirPath = CreateFolder(PONO,BLNODirPath+File.separator);
                        SONODirPath = CreateFolder(SONO,PONODirPath+File.separator);
                        // added for doc type level--2005.11.27--samar
                        docTypeDirPath=CreateFolder(findDocTypeForDocId(new Integer(DNO)),SONODirPath+File.separator);
                        File tempRootFile=new File(eDocRoot);
                        tempRootFile.canWrite();
                        filePath.add(tempRootFile.getParent());
                        tempRootFileforDelete = tempRootFile;
                        //File tempeDocPathMainFile=new File(eDocPathMain);
                        //filePath.add(tempeDocPathMainFile.getParent());
                        //2005-12-01::code change for top level directory deletion
                        //File tempFile=new File(eDocPath);//BLNODirPath);
                        //filePath.add(tempFile.getParent());
                        filePath.add(eDocPathMain);
                        filePath.add(eDocPath);
                        filePath.add(BLNODirPath);
                        filePath.add(PONODirPath);
                        filePath.add(SONODirPath);
                        // added for doc type level--2005.11.27--samar
                        filePath.add(docTypeDirPath);
                        /* Access The Data from DataBase Temp Storage with Document Id And Store In This SO Folder */
                        /*Long Raw*/
                        try
                             InitialContext initialContext=new InitialContext();
                             int sfxid=0;
                             /*DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
                             OraclePooledConnection pc = new OraclePooledConnection("jdbc:oracle:thin:hr/hr@essoraclesvr:1521:essorcl","edoc","edoc");
                             Connection con=new DBCon().Connect();//pc.getConnection();
                             PreparedStatement pstm=con.prepareStatement("select SFX_FILE_ID from DOCUMENT where DOCUMENT_ID=?");
                             //getting context of the server
                             InitialContext documentCMPInitialContext=getInitialContext();
                             Object objDocumentCMPRef=null;
                             try{
                                  objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
                             catch(Exception e)
                                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
                                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
                             //Home interface reference of DocumentCMP EJB
                             //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
                             IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
                             IDocumentCMP documentCMPRef=null;
                             //Remote interface reference of DocumentCMP EJB
                             try{
                                  documentCMPRef=iDocumentCMPHomeRef.findByPrimaryKey(new Integer(DNO));
                             catch(Exception e)
                                  logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ObjectNotFound","Document Id not found");
                             /*pstm.setInt(1,Integer.parseInt(DNO));
                             ResultSet rs1=pstm.executeQuery();
                             if(rs1.next()){
                             sfxid=rs1.getInt(1);
                             sfxid=documentCMPRef.getSfxFileId().intValue();
                             logger.finer("sfxid==="+sfxid);
                             String strFile=documentCMPRef.getDocumentName().toString();
                             //SFX lookup
                             //InitialContext initialContext=new InitialContext();
                             Object sfxWebClient=null;
                             try{
                                    sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
                             catch(Exception e)
                                  //NGP/JDK logging if JNDI not found
                                  //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
                                  logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
                             iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
                             iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();//SFXWebClient reference creation
                             if(iSFXWebClientSLRef!=null)
                                  //logger.finer("ffffffff---");
                                  int arrSFXFileId[]=new int[1];
                                  arrSFXFileId[0]=sfxid;
                                  Object objEFile[]=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
                                  if(objEFile.length>0)
                                       byte b[]=(byte[])objEFile[1];
                                       String f=strFile.substring(strFile.lastIndexOf(File.separator)+1,strFile.length());
                                       // changed(instead of SONODirPath now docTypeDirPath) for doc type level--2005.11.27--samar
                                       FileOutputStream fout=new FileOutputStream(docTypeDirPath+File.separator + f);
                                       //logger.finer("SONODirPath+File.separator + f---"+SONODirPath+File.separator + f);
                                       filePath.add(docTypeDirPath+File.separator + f);
                                       int j;
                                       for(j=0;j<b.length;j++)
                                            fout.write(b[j]);
                                       fout.close();
                                       //for auditing the document
                                       //logger.finer("Document download audited");
                                       boolean flagAudit=mlogOriginDocumentAudit("Document has been downloaded",Integer.parseInt(DNO),5,argUserId);
                                       //logger.finer("Audit complete"+flagAudit);
                                       if(logger.isFinerLoggable()) {
                                            logger.finer("Audit complete"+flagAudit);
                             //Delete after finish
                             tempRootFile.delete();
                         }catch(Exception e)
                             //e.printStackTrace();
                             logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Folder creation processing");
                        /* End Long Raw     */
                      }// end of while hasMoreTokens
               }// end of while hasMoreElements
         }else{ }
         /* Zip */
          try
              zipFolder(eDocPath+File.separator,eDocPath+".zip");
          }catch(Exception excp)
              ////logger.finer(excp.toString());
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip processing");
         // send the byte array for the file
         String fileName=eDocPath+".zip";
         try{
                   File file=new File(fileName);
                   InputStream is = new FileInputStream(file);
                   // Get the size of the file
                   long length = file.length();
                   // You cannot create an array using a long type.It needs to be an int type.
                   // Before converting to an int type,check to ensure that file is not larger than Integer.MAX_VALUE.
                   //Kept for future requirement if any
                   if (length > Integer.MAX_VALUE) {
                        // File is too large
                   // Create the byte array to hold the data
                    fileContent = new byte[(int)length];
                   // Read in the bytes
                   int offset = 0;
                   int numRead = 0;
                   while (offset < fileContent.length
                           && (numRead=is.read(fileContent, offset, fileContent.length-offset)) >= 0) {
                        offset += numRead;
                   // Ensure all the bytes have been read in
                   if (offset < fileContent.length) {
                        throw new IOException("Could not completely read file "+file.getName());
                   // Close the input stream and return bytes
                   is.close();
         }catch(Exception e){
          deleteDir(tempRootFileforDelete);
         //trying for deleting folder and zip file
         File file=new File(fileName);
         if(file.exists())
                 file.delete();
                 //logger.finer("File Deleted successfully");
         if(file.exists()){
                 //logger.finer("File Not Deleted ");
         /* File FileToDelete = new File(eDocPath+".zip");
         boolean  DelStatus1 = deleteDir(FileToDelete);
          //logger.finer("Deletion 1:"+DelStatus1 );
          File FolderToDelete = new File(eDocPath);
         boolean  DelStatus2 = deleteDir(FolderToDelete);
          //logger.finer("Deletion 2:"+DelStatus2);
          for(int index=filePath.size()-1;index>=0;index--)
               File delFile=new File(filePath.elementAt(index).toString());
               //logger.finer(delFile.getAbsolutePath());
               if(delFile.exists())
                    //logger.finer("Before delete---123");
                    //logger.finer("File Deleted========>"+delFile.delete());
                    //logger.finer("After delete---123");
                    //logger.finer(delFile.getAbsolutePath()+"-----------"+delFile.exists());
          return fileContent;
    /* ***************************Start DIR *********************/
    private  String DoFolder(String folderNname)
         File f;
         f = new File(folderNname);
         f.mkdir();                                                   // Create The Folder
       //f.deleteOnExit();                                  //R n D to Delete The zip folders only  */
         return(folderNname+File.separator);
    //to create the folder
    private String CreateFolder(String FolderName,String newFolderPath)
              String NewDir ="";
              NewDir=newFolderPath + FolderName;
              newFolderPath=DoFolder(NewDir);
              return(NewDir);
    //To zip the folder
    private void zipFolder(String srcFolder, String destZipFile)
         ZipOutputStream zip =  null;
         FileOutputStream fileWriter = null;
              try
                   fileWriter = new FileOutputStream(destZipFile);
                   zip = new ZipOutputStream(fileWriter);
                   //required for XP compress
                   zip.setMethod(ZipOutputStream.DEFLATED);
                zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
              }catch (Exception ex){
                   ex.printStackTrace();
                   System.exit(0);
              addFolderToZip("", srcFolder, zip);
              try
                   zip.flush();
                   zip.close();
                   zip=null;
                   fileWriter.close();
                   fileWriter = null;
              }catch (Exception ex)
                   //ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
         //     File f2= new File(destZipFile);
    *  Write the content of srcFile in a new ZipEntry, named path+srcFile,of the zip stream
    *  The result is that the srcFile will be in the path folder in the generated archive.
    *  @param path          String, the relative path with the root archive.
    *  @param srcFile     String, the absolute path of the file to add
    *  @param zip          ZipOutputStram, the stream to use to write the given file.
    //the folders are added to zip file
    private void addToZip(String path, String srcFile, ZipOutputStream zip)
         File folder = new File(srcFile);
         //folder.deleteOnExit();
         if (folder.isDirectory()) {
              addFolderToZip(path, srcFile, zip);
         else {
              //Transfer bytes from in to out
              byte[] buf = new byte[1024];
              int len;
              FileInputStream in = null;
              try {
                   in = new FileInputStream(srcFile);
                   // void putNextEntry(ZipEntry e) Begins writing a new ZIP file entry
                   // and positions the stream to the start of the entry data.
                   zip.putNextEntry(new ZipEntry(path +File.separator+ folder.getName()));
                   while ((len = in.read(buf)) > 0)
                        zip.write(buf, 0, len);
              }catch (Exception ex){
                   ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
              }finally{
                   try
                        //2005-12-01::file pointer close
                        in.close();
                   }catch(Exception e){
                        e.printStackTrace();
                        logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
         folder.delete(); //we addedd for DELETE
    * add the srcFolder to the zip stream.
    * @param path          String, the relatif path with the root archive.
    * @param srcFile     String, the absolute path of the file to add
    * @param zip          ZipOutputStram, the stream to use to write the given file.
    private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
         File folder = new File(srcFolder);
         folder.canWrite();
         //folder.deleteOnExit();
         String fileListe[] = folder.list();
         try
              int i = 0;
              while (true)
              addToZip(path+File.separator+ folder.getName(), srcFolder+File.separator+fileListe, zip);
              i++;
         }catch (Exception ex)
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Naming after adding to Zip Folder");
    /* $$$$$$$$$$$$$$$$$           End Zipping               $$$$$$$$$$$$$$$ */
    /****************Start Of Deleting Directory from server***********/
    public boolean deleteDir(File dir) {
         // to see if this directory is actually a symbolic link to a directory,
         // we want to get its canonical path
         //- that is, we follow the link to the file it's actually linked to
         File candir;
         try {
              candir = dir.getCanonicalFile();
         } catch (IOException e) {
              return false;
         // a symbolic link has a different canonical path than its actual path,
         // unless it's a link to itself
         if (!candir.equals(dir.getAbsoluteFile())) {
              //this file is a symbolic link, and there's no reason for us to follow it,
              //because then we might be deleting something outside of the directory we were told to delete
              return false;
         // now we go through all of the files and subdirectories in the directory and delete them one by one
         File[] files = candir.listFiles();
         if (files != null) {
         for (int i = 0; i < files.length; i++) {
              File file = files[i];
              //file read only set false
              //in case this directory is actually a symbolic link, or it's empty,
              //we want to try to delete the link before we try anything
              boolean deleted = file.delete();
              if (!deleted) {
                   // deleting the file failed, so maybe it's a non-empty directory
                   if (file.isDirectory()) deleteDir(file);
                   // otherwise, there's nothing else we can do
         // now that we tried to clear the directory out, we can try to delete it again
         return dir.delete();
    /************End Of Deleting Directory *********************/
    private InitialContext getInitialContext() throws NamingException {
    try {
    return new InitialContext();
    } catch (NamingException ne) {
    //logger.finer("Please make sure that the server is running.");
    throw ne;
    //*****************************WEB SERVICE FILE RETRIEVE IMPLEMENTATION FOR MPS PEOPLE*************************************************
    * <b>
    * Used for Retrieval of a document.
    * </b>
    * This function is called from retrieveDocument function of MPStoEdocWebServiceSLBean.
    * <p>
    * @param argUserId User Id of the user who wants to retrieve the document
    * @param argSfxFileId[] Sfx File Id which gives the reference number of the document(s) in the SFX database.
    * @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
    public Object[] mpsDocumentView(String argUserId,Integer[] argSfxFileId) throws RemoteException
         //NGP/JDK logging
         logger.finer("mpsDocumentView called--");
         try{
              argUserId=argUserId.toUpperCase();
         catch(Exception e)
              e.printStackTrace();
         logger.finer("mpsDocumentView argSfxFileId[0]--"+argSfxFileId[0]);
         Object[] searchResult=null;
         /*FileHandler handler = null;
    Logger logger=null;
         int finalIndex=0;
         try
    //PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
         //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
    //handler = new FileHandler("eDoc.log",0,1, true);
    //logger = Logger.getLogger("ErrorMsg");
    //logger.addHandler(handler);
    //logger.setLevel(Level.ALL);
    }catch(Exception excp)
         //NGP/JDK Logging warning
         //logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","PurchaseOrderCMPBeanJNDI not found");
         Object objDocumentFile[]=null;
         ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
         ISFXWebClientSL iSFXWebClientSLRef=null;
         try{
              //Locating SFX WEB CLIENT SESSION BEAN
              InitialContext initialContext=new InitialContext();
              Object sfxWebClient=null;
              try{
                   sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
              catch(Exception e)
                   //NGP/JDK Logging if JNDI not found
                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
              iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
              //creation of SFX we client
              iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();
              int arrSFXFileId[]=new int[argSfxFileId.length];
              logger.finer("SFXWebClient created----");
              //holds the sequence of SFX file id in the array
              //EFile file=new EFile();
              //getting context of the server
              InitialContext documentCMPInitialContext=getInitialContext();
         Object objDocumentCMPRef=null;
         int docId=0;
         try{
              objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
         catch(Exception e)
                   //NGP/JDK Logging if JNDI not found
                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
         //Home interface reference of DocumentCMP EJB
         //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
              IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
         //find the document id in the Document table from the SFx File Id
              for(int index=0;index<argSfxFileId.length;index++)
                   arrSFXFileId[index]=argSfxFileId[index].intValue();
                   logger.finer("mpsDocumentView arrSFXFileId[index]--"+arrSFXFileId[index]);
         logger.finer("For Document auditing----");
         //Remote interface reference of DocumentCMP EJB
         IDocumentCMP iDocumentCMPRef=iDocumentCMPHomeRef.findDocIdBySfxId(new Integer(arrSFXFileId[index]));
                   docId=iDocumentCMPRef.getDocumentId().intValue();
                   //for document audit
                   try{
                        boolean flagAudit=mlogOriginDocumentAudit("Document is Viewed",docId,5,argUserId);
                   catch(Exception e)
                        //logger.finer("Document cannot be audited----");
                        logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in audit processing");
              //call the retrieveDocument method for the above array of elements
              //Object[] tempObjDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
              //EFile file=new EFile();
              //for(int index=0;index<tempObjDocumentFile.length;index++){
              //     file= (EFile) tempObjDocumentFile[index];
              //     objDocumentFile[finalIndex++]=file.getDocFileName();
              //     objDocumentFile[finalIndex++]=file.getDocFileContent();
              objDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
              //EFile[] efileArray = (EFile[]) = objDocumentFile;
              searchResult = new Object[efileArray.length*2];
              for (int i=0;i<efileArray.length;i=i+2)
                   EFile currentFile = efileArray[i];
                   searchResult[i] = currentFile.getDocFileName();
                   searchResult[i+1] = currentFile.getDocFileContent();
              searchResult=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
         }//end of try
         catch(Exception expt)
              //logger.finer(expt);
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in retrieve from SFX");
         //if exception occurs returns null as per initilisation above
         //logger.finer("mpsDocumentView size--"+objDocumentFile.length);
         return searchResult;
    //**************************** FILE RETRIEVE IMPLEMENTATION FOR MLOG PEOPLE*******************************
    * <b>
    * Used for Retrieval of a document.
    * </b>
    * This function is called from struts.
    * <p>
    * @param argDocumentId Documnet Id which gives the ID of the document in the eDoc database..
    * @param argUserId User Id of the user who wants to retrieve the document
    * @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
    public Object[] mlogOriginDocumentView(int argDocumentId,String argUserId) throws RemoteException
         //NGP/JDK Logging
         logger.finer("mlogOriginDocumentView called--");
         try{
              argUserId=argUserId.toUpperCase();
         catch(Exception e)
              //e.printStackTrace();
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in uppercase");
    //logger.finer("mlogOriginDocumentView-- argDocumentId---"+argDocumentId);
         /*FileHandler handler = null;
    Logger logger=null;
         try
    //PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
         //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
    //handler = new FileHandler("eDoc.log",0,1, tr

  • Bug on native code of OJVM java.util.zip.CRC32.updateBytes(CRC32.java)

    I want to unzip OpenOffice 1.0 files inside the OJVM but it fails into the native method java.util.zip.CRC32.updateBytes(CRC32.java).
    The first execution of the code runs OK, but the second not.
    After a long wait it shutdown the connection and the oracle trace file shows an stack trace like this:
    *** 2003-04-18 11:31:31.926
    *** SESSION ID:(17.97) 2003-04-18 11:31:31.926
    java.lang.IllegalArgumentException
    at java.util.zip.CRC32.updateBytes(CRC32.java)
    at java.util.zip.CRC32.update(CRC32.java)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java)
    at oracle.xml.parser.v2.XMLByteReader.fillByteBuffer(XMLByteReader.java:354)
    at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:142)
    at oracle.xml.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:448)
    at oracle.xml.parser.v2.XMLReader.fillBuffer(XMLReader.java:2012)
    at oracle.xml.parser.v2.XMLReader.skipWhiteSpace(XMLReader.java:1800)
    at oracle.xml.parser.v2.NonValidatingParser.parseMisc(NonValidatingParser.java:305)
    at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:274)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:254)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:225)
    at com.prism.cms.frontend.EditPropertiesActions.processUpload(EditPropertiesActions.java:1901)
    Exception signal: 11 (SIGSEGV), code: 1 (Address not mapped to object), addr: 0x6d3a74a0, PC: [0x40263600, eomake_reference_to_eobjec
    t()+80]
    Registers:
    %eax: 0x54a54000 %ebx: 0x40429c20 %ecx: 0x54a546bf
    %edx: 0x6d3a7478 %edi: 0x402b27d0 %esi: 0x45c718ac
    %esp: 0xbfffbf20 %ebp: 0xbfffbf48 %eip: 0x40263600
    %efl: 0x00010206
    The code of the java method is:
    public static void processUpload(String id_page, String longname,
    String filename, String filetype,
    String s00)
    throws SQLException {
    Integer p_id = new Integer(id_page);
    String toSource;
    XMLDocument doc = null;
    DOMParser theParser = null;
    InputStream XSLStream = null;
    BufferedWriter out = null;
    #sql { select path||name||'.html' into :toSource from pages where id_page=:p_id };
    if ("Cancel".equalsIgnoreCase(s00)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("no-file".equals(filename) && "no-contenttpye".equals(filetype)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("xml".equalsIgnoreCase(filetype))
    #sql { call CMSj.moveFromUpload(:filename,:p_id) };
    else if ("sxw".equalsIgnoreCase(filetype)) {
    XSLProcessor processor = new XSLProcessor();
    XSLStylesheet theXSLStylesheet = null;
    BLOB locator = null;
    // open sxw file, it will be in zip format with a file named content.xml
    // then convert content.xml to document-v10.dtd with an stylesheet
    #sql { select blob_content into :locator from wpg_document where name = :filename for update };
    ZipInputStream zin = new ZipInputStream(locator.binaryStreamValue());
    ZipEntry entry;
    try {
    while((entry=zin.getNextEntry())!=null)
    if ("content.xml".equalsIgnoreCase(entry.getName())) {
    Integer newVersion;
    CLOB dstDoc;
    CMSDocURLStreamHandlerFactory.enableCMSDocURLs();
    try {
    URL inUrl = new URL("cms:/stylesheets/sxw2document-v10.xsl");
    XSLStream = inUrl.openStream();
    // Create the Stylesheet from the stream
    theXSLStylesheet = processor.newXSLStylesheet(XSLStream);
    // Stores the document processing it with the given stylesheet
    theParser = new DOMParser();
    theParser.setValidationMode(theParser.NONVALIDATING);
    theParser.setBaseURL(new URL("cms:/dtd/"));
    theParser.parse(zin);
    doc = theParser.getDocument();
    #sql { SELECT NVL(MAX(version),0)+1 INTO :newVersion FROM content
    WHERE cn_id_page = :p_id };
    #sql { INSERT INTO content( cn_id_page, version, owner, status, source_file,
    file_size, content, created, modified, created_by,
    modified_by)
    VALUES ( :p_id, :newVersion, sys_context('cms_context','user_id'),
    'Uploaded', :filename, 0 , EMPTY_CLOB(), SYSDATE, SYSDATE,
    sys_context('cms_context','user_id'),
    sys_context('cms_context','user_id')) };
    #sql { SELECT content INTO :dstDoc FROM content
    WHERE cn_id_page = :p_id AND version = :newVersion for update };
    #sql { call DBMS_LOB.trim(:inout dstDoc,0) };
    out = new BufferedWriter(dstDoc.getCharacterOutputStream(),dstDoc.getChunkSize());
    processor.processXSL(theXSLStylesheet, doc, new PrintWriter(out));
    #sql { delete from wpg_document where name=:filename };
    } catch (SAXParseException spe) {
    throw new SQLException("processUpload SAXParseException: "+xmlError(spe));
    } catch (SAXException se) {
    throw new SQLException("processUpload SAXException: "+se.getLocalizedMessage());
    } catch (XSLException xsle) {
    throw new SQLException("processUpload XSLException: "+xsle.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream.close();
    if (theParser!=null)
    theParser = null;
    if (out!=null) {
    out.flush();
    out.close();
    zin.close();
    } catch (IOException ioe) {
    throw new SQLException("processUpload IOException: "+ioe.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream = null;
    if (out!=null)
    out = null;
    if (zin!=null)
    zin = null;
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    Basically it takes the content from a BLOB column of the wpg_document table, unzip it using java.util.zip package, look for the file content.xml and parse it using Oracle XML toolkit.
    Using an open source utility which replace java.util.package (http://jazzlib.sourceforge.net/) it works perfect because is a pure java application.
    Best regards, Marcelo.
    PD: I am using Oracle 9.2.0.2 on Linux.

    The cause of errors was a dying Westen Digital drive, specially the 48G partition reserved only for $ORACLE_BASE (/dev/sdb3 mounted on /opt/oracle).
    A simple quick scan of unmounted partition (badblocks -v /dev/sdb3) reported more than thousand new bad blocks (compared to the last scan six months ago). Although I strongly believe, specially in the case of WDC drives, that the best utility to "repair" bad blocks is the one that opens a window and prints the message: "Go to the nearest shop and buy a new drive", I was very curious to prove my suspicion just on this drive. After zero-filling the partition with dd, then formatting it (mke2fs -cc) and mounting again, the 11g installation and database creation (on the same partition) successfully completed, performing fast and smoothly. To make sure it was not a casual event, I repeated the installation once again with full success. The database itself is working fine (by now). Well, the whole procedure took me more than four hours, but I'm pretty satisfied. I learned once again - stay away from Western Digital. As Oracle cannot rely on dying drive, my friend is going tomorrow to spend a 150+ euro on two 250G Seagate Barracudas and replace both WDC drives, even though the first drive seems to be healthy.
    In general there is no difference between loading correct data from good disk into bad memory and loading the incorrect data from dying disk into good memory. In both cases the pattern is damaged. For everyone who runs into the problem similar to this, and the cause cannot be easily determined, the rule of thumb must be:
    1. test memory and, if it shows any error, check sockets and test memory modules individually
    2. check disks for bad blocks regardless of the result of memory testing
    Therefore I consider your answer being generally correct.
    Regards
    NJ

  • Cannot extract Zip file with Winzip after zipping with java.util.zip

    Hi all,
    I write a class for zip and unzip the text files together which can be zip and unzip successfully with Java platform. However, I cannot extract the zip file with Winzip or even WinRAR after zipping with Java platform.
    Please help to comment, thanks~
    Below is the code:
    =====================================================================
    package myapp.util;
    import java.io.* ;
    import java.util.TreeMap ;
    import java.util.zip.* ;
    import myapp.exception.UserException ;
    public class CompressionUtil {
      public CompressionUtil() {
        super() ;
      public void createZip(String zipName, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        FileOutputStream fos = null ;
        BufferedOutputStream bos = null ;
        ZipOutputStream zos = null ;
        File file = null ;
        try {
          file = new File(zipName) ; //new zip file
          if (file.isDirectory()) //check if it is a directory
         throw new UserException("Invalid zip file ["+zipName+"]") ;
          if (file.exists() && !file.canWrite()) //check if it is readonly
         throw new UserException("Zip file is ReadOnly ["+zipName+"]") ;
          if (file.exists()) //overwrite the existing file
         file.delete();
          file.createNewFile();
          //instantiate the ZipOutputStream
          fos = new FileOutputStream(file) ;
          bos = new BufferedOutputStream(fos) ;
          zos = new ZipOutputStream(bos) ;
          this.writeZipFileEntry(zos, fileName); //call to write the file into the zip
          zos.finish() ;
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (fos != null)
         fos.close() ;
          if (bos != null)
         bos.close();
          if (zos != null)
         zos.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
      private void writeZipFileEntry(ZipOutputStream zos, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        BufferedInputStream bis = null ;
        File file = null ;
        ZipEntry zentry = null ;
        byte[] bArray = null ;
        try {
          file = new File(fileName) ; //instantiate the file
          if (!file.exists()) //check if the file is not exist
         throw new UserException("No such file ["+fileName+"]") ;
          if (file.isDirectory()) //check if the file is a directory
         throw new UserException("Invalid file ["+fileName+"]") ;
          //instantiate the BufferedInputStream
          bis = new BufferedInputStream(new FileInputStream(file)) ;
          //Get the content of the file and put into the byte[]
          int size = (int) file.length();
          if (size == -1)
         throw new UserException("Cannot determine the file size [" +fileName + "]");
          bArray = new byte[(int) size];
          int rb = 0;
          int chunk = 0;
          while (((int) size - rb) > 0) {
         chunk = bis.read(bArray, rb, (int) size - rb);
         if (chunk == -1)
           break;
         rb += chunk;
          }//end of while (((int)size - rb) > 0)
          //instantiate the CRC32
          CRC32 crc = new CRC32() ;
          crc.update(bArray, 0, size);
          //instantiate the ZipEntry
          zentry = new ZipEntry(fileName) ;
          zentry.setMethod(ZipEntry.STORED) ;
          zentry.setSize(size);
          zentry.setCrc(crc.getValue());
          //write all the info to the ZipOutputStream
          zos.putNextEntry(zentry);
          zos.write(bArray, 0, size);
          zos.closeEntry();
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (bis != null)
         bis.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
    }

    Tried~
    The problem is still here~ >___<
    Anyway, thanks for information sharing~
    The message is:
    Cannot open file: it does not appear to be a valid archive.
    If you downloaded this file, try downloading the file again.
    The problem may be here:
    if (fos != null)
    fos.close() ;
    if (bos != null)
    bos.close();
    if (zos != null)
    zos.close();
    if (file != null)
    file = null ;
    The fos is closed before bos so the last buffer is not
    saved.
    zos.close() is enough.

  • Cannot use winzip to unzip the zip file zipped by java.util.zip

    Hi all,
    I use the followcode to create a zip file, and i downlaod it and try to use winzip to unzip this file but fail. The path is correct and i got the zip file. but it just cannot unzip.
    pls help
    thanks alot.
    Kin
              int count = 0;
              count = ContentDocuments.size();
              for (int i = 0; i < bb; i++)     {
                   System.out.println(filenames[i] + "");
              // Create a buffer for reading the files
              byte[] buf = new byte[10*1024*1024];
              try {      
                   String outFilename = MyDir + "zipfile/" + getContentID2()+".zip";
                   System.out.println("outFilename = " + outFilename);
                   ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
                   for (int i=0; i<filenames.length; i++) {           
                        FileInputStream in = new FileInputStream(filenames);
                        out.putNextEntry(new ZipEntry(filenames[i]));
                        int len;
                        while ((len = in.read(buf)) != -1) {               
                             out.write(buf, 0, len);
                        out.closeEntry();
                        in.close();
                   out.close();
              } catch (IOException e)     {
                   System.err.println("zipprocess " + e.getMessage());

    I've written a replacement zip file creator class. Not much tested but it seems to work, however I've yet to try it with the version of WINZIP that rejected my previous attempts. Oh, and the stored dates are garbage.
    * ZipOutputFile.java
    * Created on 25 March 2004, 13:08
    package zip;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    * <p>Creates a ZIP archive in a file which WINZIP should be able to read.</p>
    * <p>Unfortunately zip archives generated by the standard Java class
    * {@link java.util.zip.ZipOutputStream}, while adhering to PKZIPs format specification,
    * don't appear to be readable by some versions of WinZip and similar utilities. This is
    * probably because they use
    * a format specified for writing to a non-seakable stream, where the length and CRC of
    * a file is writen to a special block following the data. Since the length of the binary
    * date is unknown this makes an archive quite complicated to read, and it looks like
    * WinZip hasn't bothered.</p>
    * <p>All data is Deflated. Close completes the archive, flush terminates the current entry.</p>
    * @see java.util.zip.ZipOutputStream
    * @author  Malcolm McMahon
    public class ZipOutputFile extends java.io.OutputStream {
        byte[] oneByte = new byte[1];
        java.io.RandomAccessFile archive;
        public final static short DEFLATE_METHOD = 8;
        public final static short VERSION_CODE = 20;
        public final static short MIN_VERSION = 10;
        public final static int  ENTRY_HEADER_MAGIC = 0x04034b50;
        public final static int  CATALOG_HEADER_MAGIC = 0x02014b50;
        public final static int  CATALOG_END_MAGIC = 0x06054b50;
        private final static short DISC_NUMBER = 0;
        ByteBuffer entryHeader = ByteBuffer.wrap(new byte[30]);
        ByteBuffer entryLater = ByteBuffer.wrap(new byte[12]);
        java.util.zip.CRC32 crcAcc = new java.util.zip.CRC32();
        java.util.zip.Deflater def = new java.util.zip.Deflater(java.util.zip.Deflater.DEFLATED, true);
        int totalCompressed;
        long MSEPOCH;
        byte [] deflateBuf = new byte[2048];
        public static final long SECONDS_TO_DAYS = 60 * 60 * 24;
         * Entry stores info about each file stored
        private class Entry {
            long offset;        // position of header in file
            byte[] name;
            long crc;
            int compressedSize;
            int uncompressedSize;
            java.util.Date date;
             * Contructor also writes initial header.
             * @param fileName Name under which data is stored.
             * @param date  Date to label the file with
             * @TODO get the date stored properly
            public Entry(String fileName, java.util.Date date) throws IOException {
                name = fileName.getBytes();
                this.date = date == null ? new java.util.Date() : date;
                entryHeader.position(10);
                putDate(entryHeader);
                entryHeader.putShort(26, (short)name.length);
                offset = archive.getFilePointer();
                archive.write(entryHeader.array());
                archive.write(name);
                catalog.add(this);
                crcAcc.reset();
                totalCompressed = 0;
                def.reset();
             * Finish writing entry data. Save the lenghts & crc for catalog
             * and go back and fill them in in the entry header.
            public void close() throws IOException {
                def.finish();
                while(!def.finished())
                    deflate();
                entryLater.position(0);
                crc = crcAcc.getValue();
                compressedSize = totalCompressed;
                uncompressedSize = def.getTotalIn();
                entryLater.putInt((int)crc);
                entryLater.putInt(compressedSize);
                entryLater.putInt(uncompressedSize);
                long eof = archive.getFilePointer();
                archive.seek(offset + 14);
                archive.write(entryLater.array());
                archive.seek(eof);
             * Write the catalog data relevant to this entry. Buffer is
             * preloaded with fixed data.
             * @param buf Buffer to organise fixed lenght part of header
            public void writeCatalog(ByteBuffer buf) throws IOException {
                buf.position(12);
                putDate(buf);
                buf.putInt((int)crc);
                buf.putInt(compressedSize);
                buf.putInt(uncompressedSize);
                buf.putShort((short)name.length);
                buf.putShort((short)0);  // extra field length
                buf.putShort((short)0);  // file comment length
                buf.putShort(DISC_NUMBER);  // disk number
                buf.putShort((short)0); // internal attributes
                buf.putInt(0);      // external file attributes
                buf.putInt((int)offset); // file position
                archive.write(buf.array());
                archive.write(name);
             * This writes the entries date in MSDOS format.
             * @param buf Where to write it
             * @TODO Get this generating sane dates
            public void putDate(ByteBuffer buf) {
                long msTime = (date.getTime() - MSEPOCH) / 1000;
                buf.putShort((short)(msTime % SECONDS_TO_DAYS));
                buf.putShort((short)(msTime / SECONDS_TO_DAYS));
        private Entry entryInProgress = null; // entry currently being written
        private java.util.ArrayList catalog = new java.util.ArrayList(12);  // all entries
         * Start a new output file.
         * @param name The name to store as
         * @param date Date - null indicates current time
        public java.io.OutputStream openEntry(String name, java.util.Date date) throws IOException{
            if(entryInProgress != null)
                entryInProgress.close();
            entryInProgress = new Entry(name, date);
            return this;
         * Creates a new instance of ZipOutputFile
         * @param fd The file to write to
        public ZipOutputFile(java.io.File fd) throws IOException {
            this(new java.io.RandomAccessFile(fd, "rw"));
         * Create new instance of ZipOutputFile from RandomAccessFile
         * @param archive RandomAccessFile
        public ZipOutputFile(java.io.RandomAccessFile archive) {
            this.archive = archive;
            entryHeader.order(java.nio.ByteOrder.LITTLE_ENDIAN);  // create fixed fields of header
            entryLater.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            entryHeader.putInt(ENTRY_HEADER_MAGIC);
            entryHeader.putShort(MIN_VERSION);
            entryHeader.putShort((short)0);  // general purpose flag
            entryHeader.putShort(DEFLATE_METHOD);
            java.util.Calendar cal = java.util.Calendar.getInstance();
            cal.clear();
            cal.set(java.util.Calendar.YEAR, 1950);
            cal.set(java.util.Calendar.DAY_OF_MONTH, 1);
    //        def.setStrategy(Deflater.HUFFMAN_ONLY);
            MSEPOCH = cal.getTimeInMillis();
         * Writes the master catalogue and postamble and closes the archive file.
        public void close() throws IOException{
            if(entryInProgress != null)
                entryInProgress.close();
            ByteBuffer catEntry = ByteBuffer.wrap(new byte[46]);
            catEntry.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            catEntry.putInt(CATALOG_HEADER_MAGIC);
            catEntry.putShort(VERSION_CODE);
            catEntry.putShort(MIN_VERSION);
            catEntry.putShort((short)0);
            catEntry.putShort(DEFLATE_METHOD);
            long catStart = archive.getFilePointer();
            for(java.util.Iterator it = catalog.iterator(); it.hasNext();) {
                ((Entry)it.next()).writeCatalog(catEntry);
            catEntry.position(0);
            catEntry.putInt(CATALOG_END_MAGIC);
            catEntry.putShort(DISC_NUMBER);
            catEntry.putShort(DISC_NUMBER);
            catEntry.putShort((short)catalog.size());
            catEntry.putShort((short)catalog.size());
            catEntry.putInt((int)(archive.getFilePointer() - catStart));
            catEntry.putInt((int)catStart);
            catEntry.putShort((short)0);
            archive.write(catEntry.array(), 0, catEntry.position());
            archive.setLength(archive.getFilePointer());  // truncate if old file
            archive.close();
            def.end();
         * Closes entry in progress.
        public void flush() throws IOException{
            if(entryInProgress == null)
                throw new IllegalStateException("Must call openEntry before writing");
            entryInProgress.close();
            entryInProgress = null;
         * Standard write routine. Defined by {@link java.io.OutputStream}.
         * Can only be used once openEntry has defined the file.
         * @param b  Bytes to write
        public void write(byte[] b) throws IOException{
            if(entryInProgress == null)
                throw new IllegalStateException("Must call openEntry before writing");
            crcAcc.update(b);
            def.setInput(b);
            while(!def.needsInput())
                deflate();
         * Standard write routine. Defined by {@link java.io.OutputStream}.
         * Can only be used once openEntry has defined the file.
         * @param b  Bytes to write
        public void write(int b) throws IOException{
            oneByte[0] = (byte)b;
            crcAcc.update(b);
            write(oneByte, 0, 1);
         *  Standard write routine. Defined by {@link java.io.OutputStream}.
         * Can only be used once openEntry has defined the file.
         * @param b  Bytes to write
         * @param off Start offset
         * @param len Byte count
        public void write(byte[] b, int off, int len) throws IOException{
            if(entryInProgress == null)
                throw new IllegalStateException("Must call openEntry before writing");
            crcAcc.update(b, off, len);
            def.setInput(b, off, len);
            while(!def.needsInput())
                deflate();
        * Gets a buffer full of coded data from the deflater and writes it to archive.
        private void deflate() throws IOException {
            int len = def.deflate(deflateBuf);
            totalCompressed += len;
            if(len > 0)
                archive.write(deflateBuf, 0, len);

  • Java.util.zip java.util.jar API usage

    I have been trying unsuccessfully for the past two days to be able to programatically add and extract files into and from a JAR using the API. I haven't found any API docs that cover the basics and I have been stumped using the nuggets that I have found on the Forum so far. Below is the code so far. Feel free to use what works in your programs, but if you find out how to get this to work. Sorry for the long post, but I gather this is a common problem that needs to be solved.
    ___________JAR CLASS_______________
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    import java.util.zip.*;
    public class Jar {
        public Jar() {
        public boolean copyToJar(File[] sources, File destination) {
            if (destination == null) {
                return false;
            if (nameContainsWildcards(destination)) {
                return false;
            File[] sourceArray = expandWildcards(sources);
            if (sourceArray == null) {
                System.out.println("sourceArray was empty");
                return false;
              System.out.println("Ready to add " + sourceArray.length + " files to " + destination);
              //variables for copying the old destination file to the new destination
              File tmpFile = null;
              JarFile tmpJarFile = null;
              InputStream jarInput = null;
              JarInputStream jarIn = null;
            InputStreamReader jarDataFile = null;
              //variables for the destination
            OutputStream output = null;
            JarOutputStream jarOut = null;
            File input = null;
            FileInputStream dataFile = null;
            int buf = -1;
              if (destination.exists()) {
                   System.out.println("The destination file exists");
                   //copy the destination to temporary
                   //fix copyToJar to use the same .tmp file name as the destination (for reentrant code)
                   tmpFile = new File(destination.getParent() + "\\" + "jar.tmp");
                   if (tmpFile.exists()) {
                        tmpFile.delete();
                   //rename the original to the TempFile
                   destination.renameTo(tmpFile);
                   if (destination.exists()) {
                        destination.delete();
                   try {
                        tmpJarFile = new JarFile(tmpFile);
                   } catch (IOException ioe) {
                        System.out.println("Exception while creating JarFile " + ioe );
            try {
                   //initialize the destination
                output = new FileOutputStream(destination);
                jarOut = new JarOutputStream(output);
                   //if there is a tmpFile copy contents of tmpFile to the new destination
                   if (tmpFile != null) {
                        jarInput = new FileInputStream(tmpFile);
                        jarIn = new JarInputStream(jarInput);
                        ZipEntry ze = null;
                        boolean contains = false;
                        while((ze = jarIn.getNextEntry()) != null) {
                             System.out.println("Working on zipEntry " + ze.getName());
                             contains = false;
                             for (int i=0; i<sourceArray.length; i++) {
                                  if (ze.getName().compareToIgnoreCase(sourceArray.getName()) == 0) {
                                       contains = true;
                             if (contains == false) {
              jarDataFile = new InputStreamReader(tmpJarFile.getInputStream(ze));
                                  System.out.println("The zip Entry was copied from the old file");
                                  jarOut.putNextEntry(ze);
                                  buf = -1;
                                  buf = jarDataFile.read();
                                  while (buf != -1) {
                                       jarOut.write(buf);
                                       buf = jarDataFile.read();
                                  jarOut.closeEntry();
                                  jarDataFile.close();
                        jarIn.close();
                        jarInput.close();
                        tmpFile.delete();
                        tmpJarFile.close();
                   //copy the new files to the destination
    for (int i=0; i<sourceArray.length; i++) {
    if (sourceArray[i].isDirectory()) {
                             //fix copyToJar to copy entire directory if the directory is given as a source
    } else {
    System.out.println("Adding " + sourceArray[i].getAbsolutePath() + " to "
    + destination.getAbsolutePath());
    dataFile = new FileInputStream(sourceArray[i]);
    ZipEntry entry= new ZipEntry(sourceArray[i].getName());
    jarOut.putNextEntry(entry);
    buf = -1;
    buf = dataFile.read();
    while (buf != -1) {
    jarOut.write(buf);
    buf = dataFile.read();
    jarOut.closeEntry();
    jarOut.close();
    output.close();
    dataFile.close();
    } catch (IOException ioe) {
    System.out.println("Exception " + ioe + " occured while writing the backup jar file.");
    try {
    if (jarOut != null)
    jarOut.close();
    if (output != null)
    output.close();
    if (dataFile != null)
    dataFile.close();
    if (jarInput != null)
    jarInput.close();
    if (jarIn != null)
    jarIn.close();
    } catch (IOException ioe2) {
    System.out.println("Exception " + ioe2 + " closing the jar file.");
    return false;
    return true;
    public boolean copyToJar(File source, File destination) {
    File[] sourceArray = expandWildcards(source);
    if (sourceArray == null) {
    System.out.println("sourceArray was empty");
    return false;
    return copyToJar(sourceArray, destination);
         public boolean extractFromJar(File source, File extract, File destDirectory) {
              try {
                   JarFile jarIn = new JarFile(source);
                   ZipEntry ze = jarIn.getEntry(extract.getName());
                   if (ze == null) {
                        System.out.println("Could not find file " + extract + " in jarFile " + source);
                   } else {
                        JarInputStream jarInput = null;
                        InputStreamReader buf = null;
                        FileOutputStream out = null;
                        InputStream in = jarIn.getInputStream(ze);
                        buf = new InputStreamReader(in);
                        out = new FileOutputStream(extract);
                        int buffer = -1;
                        buffer = buf.read();
                        while (buffer != -1) {
                             out.write(buffer);
                             buffer = buf.read();
              } catch (IOException ioe) {
                   System.out.println("Could not extract the file " + extract + " from jarFile " + source);
                   return false;
              return true;
    public int numberOfLines(File fileToCount) {
    int num = 0;
    try {
    FileReader regRead = new FileReader(fileToCount);
    LineNumberReader regReadLine = new LineNumberReader(regRead);
    while (regReadLine.readLine() != null) {
    num = regReadLine.getLineNumber();
    regRead.close();
    regReadLine.close();
    } catch (IOException ioe) {
    System.out.println("Exception " + ioe + " occured in " + this.getClass().getName());
    return num;
    static public boolean nameContainsWildcards(File source) {
    if (source != null) {
    if ((source.getName().indexOf('*')) >=0) {
    return true;
    //fix this check to look for other wildcards
    return false;
    * Expands the * wildcard that does not start the expression. For example,
    * in a directory whose contents are TEST1.DAT, TEST2.DAT AND TEST3.DAT, this
    * funtion will return the following based on the input
    * Input Returns
    * TEST1.DAT File[] containing the first file
    * TEST*.DAT File[] containing all three files plus any that match TEST*.*
    * T*.* File[] containing all three files plus any that match T*.*
    * *.* File[] containing all three files plus any that match *.*
    * EST.DAT File[] containing no files (not a legal expression...yet)
    * ? or
    public File[] expandWildcards(File source) {
    if (source == null) {
    System.out.println("Cannot expand wildCards for a null File");
    return null;
    File[] sourceArray = null;
    if (nameContainsWildcards(source)) {
    FileFilter wildcardFilter = new WildcardFilter(source.getName());
    File sourceParent = new File(source.getParent());
    if (sourceParent != null) {
    sourceArray = sourceParent.listFiles(wildcardFilter);
    } else {
    sourceArray = new File[1];
    sourceArray[0] = source;
    } else {
    sourceArray = new File[1];
    sourceArray[0] = source;
    return sourceArray;
    public File[] expandWildcards(File[] sources) {
    File[] sourceArray = null;
    List fileArrays = new ArrayList();
    for (int i=0; i< sources.length; i++) {
    fileArrays.add(expandWildcards(sources[i]));
    int totalFiles = 0;
    for (int i=0; i < fileArrays.size(); i++) {
    File[] tmp = (File []) fileArrays.get(i);
    if (tmp != null) {
         //System.out.println("Adding " + tmp.length + " to total files");
         totalFiles += tmp.length;
    System.out.println("totalFiles expanded = " + totalFiles);
    sourceArray = new File[totalFiles];
    int nextIndex = 0;
    for (int i=0; i < fileArrays.size(); i++) {
    File[] tmp = (File []) fileArrays.get(i);
    if (tmp != null) {
                        for(int j=0; j < tmp.length; j++) {
                             //System.out.println("Adding file " + tmp[j] + " to sourceArray");
                             sourceArray[nextIndex] = tmp[j];
                             nextIndex++;
    return sourceArray;
    static public void main(String argv[]) {
    Jar jarRun = new Jar();
    File testFile = new File("D:\\test.jar");
              File testFile1 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultCustomers.jar");
              File testFile2 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultInventory.jar");
              File testFile3 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultVendors.jar");
              File testFile4 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultClerks.jar");
              if (argv.length >= 1) {
                   System.out.println("Creating the Jar File");
                   jarRun.copyToJar(testFile1, testFile);
                   jarRun.copyToJar(testFile2, testFile);
                   jarRun.copyToJar(testFile3, testFile);
                   jarRun.copyToJar(testFile4, testFile);
              } else {
                   System.out.println("Extracting from the Jar File");
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultCustomers.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultInventory.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultVendors.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultClerks.jar"), new File("d:\\"));
    ______________WILDCARD FILTER CLASS __________
    import java.io.File;
    import java.io.FileFilter;
    public class WildcardFilter implements FileFilter {
        private String compare = null;
        private String wildcardStart = null;
        private String wildcardMiddle = null;
        private String wildcardEnd = null;
        WildcardFilter(String comparison) {
            setCompare(comparison);
        public void setCompare(String comparison) {
            compare = comparison.toLowerCase();
            wildcardStart = null;
            wildcardMiddle = null;
            wildcardEnd = null;
            int index = compare.indexOf('*');
            if (index != -1) {
                wildcardStart = compare.substring(0, index);
                if (index + 1 < compare.length()) {
                    wildcardEnd = compare.substring(index + 1, compare.length());
                System.out.println("Expanding fileNames starting with " + wildcardStart
                          + " and ending with " + wildcardEnd);
        public boolean accept(File check) {
            String checkName = check.getName().toLowerCase();
            if (compare == null) {
                return false;
            if (((wildcardEnd == null) || (wildcardEnd.compareTo("") == 0))
                && ((wildcardStart == null) || (wildcardStart.compareTo("") ==0))) {
                return false;
            if (((wildcardStart == null) || (wildcardStart.compareTo("") ==0))
                && (wildcardEnd != null)) {
                if ((wildcardEnd.compareTo(".*") ==0) || (wildcardEnd.compareTo("*") == 0))
                    return true;
                if (checkName.endsWith(wildcardEnd))
                    return true;
            if (((wildcardEnd == null) || (wildcardEnd.compareTo("") == 0))
                && (wildcardStart != null)) {
                if (checkName.startsWith(wildcardStart))
                    return true;
            if ((checkName.startsWith(wildcardStart))
                && (checkName.endsWith(wildcardEnd))) {
                return true;
            return false;

    I figured it out based on some of the other posts I found on this Forum. Following is the working code. While this code is not as robust as it needs to be for production, it will at least get you started on extracting from jar files and writing to jarfiles.
    import java.io.*;
    import java.util.jar.*;
    import java.util.zip.*;
    //NOTE: You can only copy entries created by the Jar tool
    class JarTest {
        JarTest() {
        public boolean copyToJar(File[] fileList, File jarFile) {
            JarEntry je = null;
            File tmpFile = null;
            FileOutputStream fos = null;
            JarOutputStream jos = null;
            BufferedWriter bw = null;
            FileInputStream fis = null;
            JarInputStream jis = null;
            BufferedReader br = null;
            int buf = -1;
            boolean badZipFile = false;
            boolean refreshFromNewFile = false;
            String tmpFileName = jarFile.getAbsolutePath() + ".tmp";
            try {
                tmpFile = new File(tmpFileName);
                fos = new FileOutputStream(tmpFile);
                jos = new JarOutputStream(fos);
                bw = new BufferedWriter(new OutputStreamWriter(jos));
            } catch (IOException ioe) {
                ioe.printStackTrace();
        if(jarFile.exists()) {
                try {
                    fis = new FileInputStream(jarFile);
                    jis = new JarInputStream(fis);
                    br = new BufferedReader(new InputStreamReader(jis));
                } catch (IOException ioe) {
                    System.out.println(ioe);
                try {
                    while((je = jis.getNextJarEntry()) != null) {
                        refreshFromNewFile = false;
                        for (int i = 0; i < fileList.length; i++) {
                            if (je.getName().compareToIgnoreCase(fileList.getName()) == 0) {
    refreshFromNewFile = true;
    if (refreshFromNewFile) {
    //do nothing so we can add the new file below
    } else {
    jos.putNextEntry(je);
    int index = 0;
    buf = -1;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    index++;
    System.out.println("Copied entry " + je.getName() + " of " + index + " bytes from " + jarFile.getName());
    bw.flush();
    jos.closeEntry();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    badZipFile = true;
    try {
    br.close();
    jis.close();
    fis.close();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    for (int i = 0; i < fileList.length; i++) {
    try {
    fis = new FileInputStream(fileList[i]);
    br = new BufferedReader(new InputStreamReader(fis));
    // write the new entries to the tmpFile
    je = new JarEntry(fileList[i].getName());
    jos.putNextEntry(je);
    int index = 0;
    buf = -1;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    index++;
    bw.flush();
    System.out.println("Added entry " + je.getName() + " of " + index + " bytes.");
    jos.closeEntry();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    badZipFile = true;
    try {
    jos.close();
    if (tmpFile != null) {
    // rename the tmpFile to jarFile
    jarFile.delete();
    tmpFile.renameTo(jarFile);
    } catch (IOException ioe) {
    ioe.printStackTrace();
    return true;
    public boolean extractFromJar(File[] fileList, File jarFile) {
    ZipEntry zen = null;
    BufferedReader br = null;
    FileOutputStream fos = null;
    BufferedWriter bw = null;
    try {
    for (int i = 0; i < fileList.length; i++) {
    JarFile jar = new JarFile(jarFile);
    zen = jar.getEntry(fileList[i].getName());
    if (zen == null) {
    System.out.println("Could not find the file " + fileList[i].getName() + " in the zip file " + jar.getName());
    } else {
    File parentDirectory = new File(fileList[i].getParent());
    parentDirectory.mkdirs();
    InputStream in = jar.getInputStream(zen);
    br = new BufferedReader(new InputStreamReader(in));
    fos = new FileOutputStream(fileList[i]);
    bw = new BufferedWriter(new OutputStreamWriter(fos));
    int buf = -1;
    int index = 0;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    bw.flush();
    index++;
    System.out.println("Extracted file " + fileList[i] + " of " + index + " bytes from " + jarFile);
    br.close();
    bw.close();
    } catch (IOException ioe) {
    System.out.println(ioe);
    return false;
    return true;
    public static void main(String[] argv) {
    JarTest jt = new JarTest();
    File jarFile = new File("d:\\test\\test.zip");
    File[] fileList1 = new File[] {new File("d:\\test\\CustomerRefreshRequest.bat"),
                                            new File("d:\\test\\CustomerUpdateGet.bat"),
                                            new File("d:\\test\\CustomerUpdateRequest.bat"),
                                            new File("d:\\test\\LongmontDefaultClerks.jar"),
                                            new File("d:\\test\\LongmontDefaultCustomers.jar"),
                                            new File("d:\\test\\LongmontDefaultInventory.jar")};
    File[] fileList2 = new File[] { new File("d:\\test\\install.bat"),
    new File("d:\\test\\LongmontDefaultVendors.jar"),
    new File("d:\\test\\CustomerUpdateSend.bat") };
    jt.copyToJar(fileList1, jarFile);
    jt.copyToJar(fileList2, jarFile);
    File[] fileList3 = new File[] {new File("d:\\test\\temp\\CustomerRefreshRequest.bat"),
                                            new File("d:\\test\\temp\\CustomerUpdateGet.bat"),
                                            new File("d:\\test\\temp\\CustomerUpdateRequest.bat"),
                                            new File("d:\\test\\temp\\LongmontDefaultClerks.jar"),
                                            new File("d:\\test\\temp\\LongmontDefaultCustomers.jar"),
                                            new File("d:\\test\\temp\\LongmontDefaultInventory.jar")};
    File[] fileList4 = new File[] { new File("d:\\test\\temp\\INSTALL.BAT"),
    new File("d:\\test\\temp\\LongmontDefaultVendors.jar"),
    new File("d:\\test\\temp\\CustomerUpdateSend.bat") };
    jt.extractFromJar(fileList3, jarFile);
    jt.extractFromJar(fileList4, jarFile);

  • Java.util.zip.ZIPException

    We are using Oracle Application Server 10g (10.1.2) with AIX OS version 5.3 release 6.
    We are getting error while deploying a "*.war" file. Below is the full error we have got during the installation.
    Error starting from below.
    Failed to deploy web application. File /tmp/dir1341.tmp/abc.war is not a jar file.
    Resolution :
    Base Exception:
    java.util.zip.ZIPException
    Error opening zip file /tmp/dir1341.tmp/abc.war
    Error opening zip file /tmp/dir1341.tmp/abc.war
    Kindly suggest the best provided solution for the same.
    Also let us know about the error belongs Oracle AS application?
    OR
    AIX OS Level error?

    Well as the error suggests, it is neither related to OracleAS nor AIX OS. It is complaining about the WAR file you are trying to deploy. Make sure your abc.war is a well formed WAR file. You can search google for tool to validate a war file.
    Thanks
    Shail

  • Java.util.zip.ZipException Error

    I created a jar file, and put in C:\tools
    C:\tools>java -jar myjar.jar is working fine
    However, if I try to run myjar.jar in other directories, then I have problems.
    I already set the classpath:
    SET CLASSPATH=.;%CLASSPATH%;C:\tools\myjar.jar;
    Here's the error. Any ideas???
    C:\>java -jar myjar.jar
    Exception in thread "main" java.util.zip.ZipException: The system cannot find th
    e file specified
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:112)
    at java.util.jar.JarFile.<init>(JarFile.java:117)
    at java.util.jar.JarFile.<init>(JarFile.java:55)

    You always need to specify a proper file name when you use the -jar switch. If you are not in c:\tools you have to run with "java -jar c:\tools\myjar.jar".
    Setting the classpath in particular doesn't help becuase the file name given to the -jar switch will override all settings for classpath. http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html#userclass
    But since you now have myjar.jar in your classpath, you can run the application from any directory with "java your.main.ClassName" :)

  • [J2EE:160029] I/O error... java.util.zip.ZipException

    Hi,
    I'm using BEA WLS8.1 SP4 on HPUX Itanium2 with JDK 1.4.2.05.
    When I'm trying to deploy my app's ear file it's throwing
    out the error shown below (far below).
    I've placed the ear file in /opt/bea_wls/weblogic81/server/bin/myserver/upload directory with all the permissions set.
    Please could someone help me resolve this.
    Thanks
    Mouli
    [J2EE:160029]I/O error while reading deployment - java.util.zip.ZipException: Could not find End Of Central Directory. java.util.zip.ZipException: Could not find End Of Central Directory at java.util.zip.ZipFile.open(Ljava.lang.String;I)I(Unknown Source) at java.util.zip.ZipFile.<init>(Ljava.io.File;I)V(Unknown Source) at java.util.jar.JarFile.<init>(Ljava.io.File;ZI)V(JarFile.java:127) at java.util.jar.JarFile.<init>(Ljava.io.File;)V(JarFile.java:92) at weblogic.j2ee.J2EEUtils.getArchiveEarInfo(Ljava.io.File;)Lweblogic.j2ee.DeploymentInfo;(J2EEUtils.java:294) at weblogic.j2ee.J2EEUtils.getDeploymentInfo(Ljava.io.File;)[Lweblogic.j2ee.DeploymentInfo;(J2EEUtils.java:206) at weblogic.j2ee.J2EEUtils.getDeploymentInfo(Lweblogic.application.ApplicationFileManager;)[Lweblogic.j2ee.DeploymentInfo;(J2EEUtils.java:158) at weblogic.j2ee.J2EEApplicationContainerFactory.initializeDeployment(Ljava.io.File;Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)Lweblogic.management.configuration.ApplicationMBean;(J2EEApplicationContainerFactory.java:464) at weblogic.management.deploy.DeployerRuntime.unprotectedActivate(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.management.deploy.DeploymentData;Ljava.lang.String;Z)Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;(DeployerRuntime.java:854) at weblogic.management.deploy.DeployerRuntime.access$000(Lweblogic.management.deploy.DeployerRuntime;Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.management.deploy.DeploymentData;Ljava.lang.String;Z)Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;(DeployerRuntime.java:69) at weblogic.management.deploy.DeployerRuntime$1.run()Ljava.lang.Object;(DeployerRuntime.java:1532) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:121) at weblogic.management.deploy.DeployerRuntime.checkAndPerformDeployerActions(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.management.deploy.DeploymentData;Ljava.lang.String;ZI)Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;(DeployerRuntime.java:1523) at weblogic.management.deploy.DeployerRuntime.activate(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.management.deploy.DeploymentData;Ljava.lang.String;Z)Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;(DeployerRuntime.java:192) at jrockit.reflect.NativeMethodInvoker.invoke0(Ljava.lang.Object;ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source) at weblogic.management.internal.DynamicMBeanImpl.invokeLocally(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(DynamicMBeanImpl.java:754) at weblogic.management.internal.DynamicMBeanImpl.invoke(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(DynamicMBeanImpl.java:733) at com.sun.management.jmx.MBeanServerImpl.invoke(Ljava.lang.Object;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(MBeanServerImpl.java:1560) at com.sun.management.jmx.MBeanServerImpl.invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(MBeanServerImpl.java:1528) at weblogic.management.internal.RemoteMBeanServerImpl.private_invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(RemoteMBeanServerImpl.java:988) at weblogic.management.internal.RemoteMBeanServerImpl.invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(RemoteMBeanServerImpl.java:946) at weblogic.management.internal.MBeanProxy.invoke(Ljava.lang.String;[Ljava.lang.Object;)Ljava.lang.Object;(MBeanProxy.java:954) at weblogic.management.internal.MBeanProxy.invokeForCachingStub(Ljava.lang.String;[Ljava.lang.Object;)Ljava.lang.Object;(MBeanProxy.java:481) at weblogic.management.runtime.DeployerRuntimeMBean_Stub.activate(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.management.deploy.DeploymentData;Ljava.lang.String;Z)Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;(DeployerRuntimeMBean_Stub.java:1139) at weblogic.management.console.actions.mbean.ApplicationDeployAction.prePerform(Lweblogic.management.console.actions.ActionContext;Lweblogic.management.console.actions.RequestableAction;)Lweblogic.management.console.actions.RequestableAction;(ApplicationDeployAction.java:179) at weblogic.management.console.actions.mbean.DoMBeanWizardAction.perform(Lweblogic.management.console.actions.ActionContext;)Lweblogic.management.console.actions.Action;(DoMBeanWizardAction.java:215) at weblogic.management.console.actions.internal.ActionServlet.doAction(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ActionServlet.java:173)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi
    THis may be due to the file was FTP to the directory as ASCII mode ...
    Or the file is corrupt.
    Try to pacgake again (with jar command)
    Jin

  • Java.lang.Error: java.util.zip.ZipException: The system cannot find the fil

    I got maven 221 installed
    i got jdk 1.6 and 1.5 installed (have tested both)
    I have a strange error. All my co-workers can build but I cant. The only thing I can find is that I dont have installed BEA Weblogic but I dont want to have that installed. It should be able to run anyway.
    Could someone tell me what is wrong? If you need pom.xml I got that one as well.
    process-classes:
    [copy] Copying 4 files to C:\hudson\jobs\albpm_ip-identity-asserter_-_Build\workspace\target\mbean-content
    [mkdir] Created dir: C:\hudson\jobs\albpm_ip-identity-asserter_-_Build\workspace\target\mbean-jar
    [java] Creating an MJF from the contents of directory C:\hudson\jobs\albpm_ip-identity-asserter_-_Build\workspace\target\mbean-content...
    [java] Compiling the files...
    [java] Creating the list.
    [java] Doing the compile.
    [java] WLMaker-SubProcess: : Exception in thread "main" java.lang.Error: java.util.zip.ZipException: The system cannot find the file specified
    [java] WLMaker-SubProcess: :      at weblogic.management.commo.BeanGenDriver.getManagementTempDir(BeanGenDriver.java:93)
    [java] WLMaker-SubProcess: :      at weblogic.management.commo.BeanGenDriver.main(BeanGenDriver.java:117)
    [java] WLMaker-SubProcess: : Caused by: java.util.zip.ZipException: The system cannot find the file specified
    [java] WLMaker-SubProcess: :      at java.util.zip.ZipFile.open(Native Method)
    [java] WLMaker-SubProcess: :      at java.util.zip.ZipFile.<init>(ZipFile.java:203)
    [java] WLMaker-SubProcess: :      at java.util.jar.JarFile.<init>(JarFile.java:132)
    [java] WLMaker-SubProcess: :      at java.util.jar.JarFile.<init>(JarFile.java:97)
    [java] WLMaker-SubProcess: :      at weblogic.management.commo.BeanGenDriver.getManagementTempDir(BeanGenDriver.java:90)
    [java] WLMaker-SubProcess: :      ... 1 more
    [java] WLMaker-SubProcess: : Stopped draining WLMaker-SubProcess:
    [java] WLMaker-SubProcess: : Stopped draining WLMaker-SubProcess:
    [java] BeanGen code generation failed
    [HUDSON] Archiving C:\hudson\jobs\albpm_ip-identity-asserter_-Build\workspace\pom.xml to C:\hudson\jobs\albpmip-identity-asserter_-Build\modules\dk.skat.ip.integration.albpm$ip-identity-asserter\builds\2010-11-2213-41-28\archive\dk.skat.ip.integration.albpm\ip-identity-asserter\1.2\pom.xml
    [INFO] ------------------------------------------------------------------------

    from my experience, using weblogic jars can be a pain if the full install is not on the local box.
    Note that you dont have to 'install' it. Just copy the directory.
    Reason is that the jar files have manifests with relative classpaths.
    For an example of horror take a look at the weblogic.jar MANIFEST's classpath entry.
    -Fred

Maybe you are looking for