How to solve java.io.IOException: Corrupt form data: premature ending

hei evryone!
Does anyone knows how to solve this bug?
java.io.IOException: Corrupt form data: premature ending
Im using Oreilly's cos.jar MultipartRequest
here is my form :
<FORM METHOD="POST" NAME="uploadform" action="mbbfile" ENCTYPE="multipart/form-data">
<TR>
<TD>Select a File:</TD>
<TD><INPUT TYPE="FILE" NAME="srcfile" style="width:400px"/></TD>
</TR>
<TR><TD><INPUT TYPE="SUBMIT" VALUE="Send"/></TD></TR>
</FORM>
HERE IS mbbfile which is a servlet :
package mbb.servlet;
import java.io.IOException;
import java.sql.Connection;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.oreilly.servlet.MultipartRequest;
import org.jconfig.Configuration;
import org.jconfig.ConfigurationManager;
public class MBBFileServlet extends HttpServlet{
     private static final Configuration conf = ConfigurationManager.getConfiguration("ConfigFile");
     public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
          String filePath = conf.getProperty("FilePath", "", "test");
          try{
          MultipartRequest multi = new MultipartRequest(req,filePath,5*1024*1024);
          }catch(Exception e){
               System.out.println("MBBFileServlet Exception ---> "+e.getMessage());
     public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
          doGet(req,res);
Sometimes it works meaning the file is uploaded in the directory without any exception, sometimes the file is uploaded but with exception on the log saying "MBBFileServlet Exception ---> Corrupt form data: Premature Ending". and sometimes the files is not uploaded at all and when i check the error is : "MBBFileServlet Exception ---> Corrupt form data: Premature Ending". Can anyone please help me on this matter. Thx!
Your response would be deeply appreciated.
br,
TAC

Hi all!
Since I've spent some days now trying to figure out what was wrong with my file upload in Struts 1.1, I would like to share my solution with the rest of you in order to spare you for the same amout of wasted time I've spent :-)
My platform is Resin 3.0.8 and Struts 1.1. My problem was that JPEG's got corrupted when arriviving at the server. After a few days searching on the net, I tried with a plain servlet and the O'Reilly package, and the app worked perfect.
Here is my servlet:
package no.yourcompany.yourapp.servlet;
import com.oreilly.servlet.multipart.MultipartParser;
import com.oreilly.servlet.multipart.Part;
import com.oreilly.servlet.multipart.FilePart;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class ImageUpload extends HttpServlet {
private static final String PAGE_RECEIPT = "/popImageUploadReceipt.do";
private static final int MAX_FILE_SIZE_IN_BYTES = 10000000; // 10 M
* Extracts image from request and puts it into person form.
* @see HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// custom beans from my project, not defined here
PersonRegistrationForm personRegistrationForm = null;
PortraitImage portraitImage = null;
ByteArrayOutputStream outputStream = null;
Part currentPart = null;
FilePart currFilePart = null;
personRegistrationForm = (PersonRegistrationForm) request.getSession().getAttribute(DsnSessionKeyConstantsIF.KEY_PERSON_FORM);
portraitImage = personRegistrationForm.getPortraitImage();
try {
MultipartParser parser = new MultipartParser(request, MAX_FILE_SIZE_IN_BYTES);
while ((currentPart = parser.readNextPart()) != null) {
if (currentPart.isFile()) {
currFilePart = (FilePart) currentPart;
outputStream = new ByteArrayOutputStream();
currFilePart.writeTo(outputStream);
// portraitImage is just a bean for encapsulating image data, not defined in this posting
portraitImage.setContentType(currFilePart.getContentType());
portraitImage.setImageAsByteArray(outputStream.toByteArray());
portraitImage.setOriginalFileName(currFilePart.getFileName());
break;
} // if (currentPart.isFile())
} // while ((currentPart = parser.readNextPart()) != null)
} catch (IOException ioe) {
// noop
// redirect to receipt page
ServletContext servletContext = this.getServletContext();
RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher(PAGE_RECEIPT);
requestDispatcher.forward(request, response);
} // doPost
} // ImageUpload
AND ADD THIS TO YOUR WEB.XML
<servlet>
<servlet-name>ImageUpload</servlet-name>
<servlet-class>no.yourcompany.yourapp.servlet.ImageUpload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageUpload</servlet-name>
<url-pattern>imageUpload.do</url-pattern>
</servlet-mapping>
AND THE HTML-FORM IS HERE
<form action="/yourapp/imageUpload.do" method="post" enctype="multipart/form-data" accept="image/*">
<p>
<input type="file" name="portraitImage" />
</p>
<p>
<input type="image" src="/dsn/img/btn_last_bilde.gif" border="0">
</p>
</form>

Similar Messages

  • MultipartRequest java.io.IOException: Corrupt form data: premature ending

    i try to upload a file using MultipartRequest
    i want to get the name of the file uploaded with html form
    and display it on jsp page (just for now to see if it works)
    in server.log i see Error creating file: java.io.IOException: Corrupt form data: premature ending
    thank You

    Then whatever is uploading the file, isn't doing it correctly.

  • Java.io.IOException: Corrupt form data: no leading boundary

    Hi,
    I am trying to upload pdf files using a servlet. The Enctype of the form which calls this servlet is multipart/formdata. I use O'Reilly upload component which uses the class MultipartRequest to do the uploading. The form has textboxes and textareas whose data is also submitted.
    The problem is, when I try uploading with Greek text in these text area and textbox, I get the exception
    java.io.IOException: Corrupt form data: no leading boundary: -----------------------------7d21b8c1502c0 != -----------------------------7d21c2c1502c0
    Has anyone encountered this problem? Any help will be greatly appreciated.
    Sairam

    just check this
    http://www.servlets.com/cos/faq.html
    and http://www.oreilly.com/catalog/jservlet/errata/jservlet.unconfirmed

  • Corrupt JPEG Data: Premature End of Data Segment

    I've searched and searched this error for ever and everyone
    says remove images from folders (an option i do not have), and no
    one seems to have error i have.
    I need to find out how to remove this error, it causes me
    endless grief, stops my uploads (sometimes it comes up in the
    middle of an upload), sometimes shows up behind dreamweaver, so i
    don't see it.
    Help
    I'm using Dreamweaver 8.01 (govt office, can't easily
    upgrade).
    on XP PRO Sp2
    if any other specs are needed, pls let me know.
    thank you.

    You are not the only one. I'm dealing with the same issue. I
    did you ever get an anwer anywhere?
    Thanks,
    Doug Collins

  • How to solve 'java/lang/OutOfMemoryError' when apply weblogic patch 10.3.6.0.10?

    Hi All:  Our platform is IBM AIX power system 64 bit, os level 6.  Oracle Fusion Middleware version is 10.3.6.0.8.  We tried to patch 10.3.6.0.10 on it, but encounter ‘out of memory error’ when  applied WebLogic patch 10.3.6.0.10 on UAT report server.  Currently UAT has 3GB memory (currently is 3G) .
    JVMDUMP006I Processing dump event "systhrow",
    detail "java/lang/OutOfMemoryError
    JVMDUMP032I JVM requested Heap dump using
    '/ora_bin01/u01/oracle/Middleware/utilhd' in response to an event
    JVMDUMP010I Heap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152727.6422620.0001.phd
    JVMDUMP032I JVM requested Java dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152727.6422620.0002.txt'
    in response to an event
    JVMDUMP010I Java dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152727.6422620.0002.txt
    JVMDUMP032I JVM requested Snap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152727.6422620.0003.trc'
    in response to an event
    JVMDUMP006I Processing dump event "systhrow",
    detail "java/lang/OutOfMemoryError" - please wait.
    JVMDUMP010I Snap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152727.6422620.0003.trc
    JVMDUMP013I Processed dump event "systhrow",
    detail "java/lang/OutOfMemoryError".
    JVMDUMP032I JVM requested Heap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152735.6422620.0004.phd'
    in response to an event
    JVMDUMP010I Heap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152735.6422620.0004.phd
    JVMDUMP032I JVM requested Java dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152735.6422620.0005.txt'
    in response to an event
    JVMDUMP010I Java dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152735.6422620.0005.txt
    JVMDUMP032I JVM requested Snap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152735.6422620.0006.trc'
    in response to an event
    Exception in thread "main"
    java.lang.OutOfMemoryError at
    java.lang.StringBuffer.ensureCapacityImpl(StringBuffer.java:335)
    at
    java.lang.StringBuffer.append(StringBuffer.java:201)
    at
    java.lang.Class.throwNoSuchMethodException(Class.java:278)
    at
    java.lang.Class.getMethod(Class.java:845)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.isValueSet(XBeanDataHandler.java:958)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.getValueFromObject(XBeanDataHandler.java:589)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.getSimpleValue(XBeanDataHandler.java:431)
    at
    com.bea.plateng.patch.dao.cat.PatchDependency.getRule(PatchDependency.java:48)
    at
    com.bea.plateng.patch.dao.cat.PatchCatalogHelper.getInvalidatedPatchMap(PatchCatalogHelper.java:1625)
    at com.bea.plateng.patch.PatchSystem.updatePatchCatalog(PatchSystem.java:436)
    at
    com.bea.plateng.patch.PatchSystem.refresh(PatchSystem.java:130)
    at
    com.bea.plateng.patch.PatchSystem.setCacheDir(PatchSystem.java:201)
    at
    com.bea.plateng.patch.Patch.main(Patch.java:281)
    JVMDUMP010I Snap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152735.6422620.0006.trc
    JVMDUMP013I Processed dump event "systhrow",
    detail "java/lang/OutOfMemoryError".
    Exception in thread "Attach API wait loop"
    java.lang.OutOfMemoryError
       at
    com.ibm.tools.attach.javaSE.CommonDirectory.waitSemaphore(CommonDirectory.java:222)
    at
    com.ibm.tools.attach.javaSE.AttachHandler$WaitLoop.waitForNotification(AttachHandler.java:329)
    at com.ibm.tools.attach.javaSE.AttachHandler$WaitLoop.run(AttachHandler.java:396)
    bsu.sh -install -patch_download_dir=/ora_bin01/u01/oracle/Middleware/utils/bsu/cache_dir -patchlist=12UV -prod_dir=/ora_bin01/u01/oracle/Middleware/wlserver_10.3
    we followed the README.txt instructions, and stop/start weblogic service before/after apply patch. Can anyone suggest a solution or Doc ID for helping us?
    thank you very much!

    Solutions: Bounce the applications and check the arguments if you can increase it.  It is due to memory issue
    You can set these values in CommEnv.sh (.cmd for windows) file located in the weblogic_home/common/bin directory.
    This gets applied to all the domains under that wls home.
    If you want to make the changes to specific domain then edit the SetDomainEnv.sh file located under the domain/bin directory.
    How to solve java.lang.OutOfMemoryError: Java heap space
    solutions:  export JVM_ARGS="-Xms1024m -Xmx1024m"
    How to solve java.lang.OutOfMemoryError: PermGen space
    solution : export JVM_ARGS="-XX:PermSize=64M -XX:MaxPermSize=256m"

  • Java.io.IOException: Corrupt GZIP trailer

    I have some code to gunzip a byte array of data. I've used this code frequently and it works well. However, I just tried unzipping a byte[] array that is 4,529,218 bytes which expands to a file that is 2,157,763,194 bytes (on an SGI).
    I get a:
    java.io.IOException: Corrupt GZIP trailer
    thrown from the while ( ( length = zipin.read(buffer, 0, sChunk) ) != -1) line below.
    I did a quick Google search and found these links:
    http://www.aoindustries.com/docs/aocode-public/com/aoindustries/util/zip/CorrectedGZIPInputStream.html
    http://www.sanger.ac.uk/Software/Artemis/artemis_docs/uk.ac.sanger.pathogens.WorkingGZIPInputStream.html
    with comments like:
    Works around the "Corrupt GZIP trailer" problem in GZIPInputStream by catching and ignoring this exception.
    A wrapper class to work around a bug in GZIPInputStream. The read() method sometimes throws a IOException complaining about a Corrupt GZIP trailer on the jdk 1.1.8-13 on the Alphas. This wrapper catches and ignores that exception.
    The code below writes out the correct number of bytes to the filesystem, but I get the IOException. From my Google search, it appears that some people have run into this problem before. Does anyone here know if this is a bogus error, or if it is valid? Is this a known "bug" in Java?
    Note: the file size is larger than the Integer.MAX_SIZE. Is there an integer somewhere in the code that checks the trailer that was exceeded because of the file size?
    (I ommited some catch code to make reading it easier)
    private void gunzip(byte[] data, File file)
        int sChunk = 8192;
        // create input stream
        GZIPInputStream zipin;
        try
            ByteArrayInputStream in = new ByteArrayInputStream(data);
            zipin = new GZIPInputStream(in);
        catch (IOException e)
            // omitted for clarity
        byte[] buffer = new byte[sChunk];
        FileOutputStream out = null;
        // decompress the data
        try
            out = new FileOutputStream(file);
            while ( ( length = zipin.read(buffer, 0, sChunk) ) != -1) // error here
                out.write(buffer, 0, length);
        catch (IOException e)
            // omitted for clarity
        finally
            try
                out.close();
                zipin.close();
            catch(IOException e)
                // omitted for clarity
    }

    In GZIPInputStream.java:
         * Reads GZIP member trailer.
        private void readTrailer() throws IOException {
         InputStream in = this.in;
         int n = inf.getRemaining();
         if (n > 0) {
             in = new SequenceInputStream(
                   new ByteArrayInputStream(buf, len - n, n), in);
         long v = crc.getValue();
         if (readUInt(in) != v || readUInt(in) != inf.getTotalOut()) {
             throw new IOException("Corrupt GZIP trailer");
        }This line
    if (readUInt(in) != v || readUInt(in) != inf.getTotalOut())appears to be verifying the CRC value and data size from the trailer with data actually read from the stream.
    The inf.getTotalOut() returns an integer. My file size is greater than a 32 bit integer value.
    I looked at the GZip file specification at:
    http://www.faqs.org/rfcs/rfc1952.html
    and see that the trailer input size is defined as:
    ISIZE (Input SIZE)
                This contains the size of the original (uncompressed) input
                data modulo 2^32.I assume data modulo 2^32 means that this is supposed to be a 32 bit integer.

  • BIAPPS how can we manually set both ETL start date and end date?

    Dears experts,
    how can we manually set both ETL start date and end date while conducting incremental load IN DAC?
    Please advise me.
    thanks,
    Joe.

    You can set those dates in the DAC system parameters tab. You should see lots of $$xxxxxx parameters.
    If I may, I'd suggest you use the OBI Applications forum for questions on DAC.
    Antonio
    BExpert, Brazil

  • How to use java programe in oracle form

    Hello Expert,
    My Config is : -
    Forms [32 Bit] Version 11.1.1.3.0 (Production)
    Jdeveloper - 10.1.3
    I want to use the java programe in form builder. I create the one java class in Jdeveloper -
    package demo;
    import java.net.InetAddress;
    import java.net.NetworkInterface;
    import java.net.SocketException;
    import java.net.UnknownHostException;
    public class get_info{
       public static void main(String[] args){
       ch_add();
       public static void ch_add()
      InetAddress ip;
      try { 
      ip = InetAddress.getLocalHost();
      /*System.out.println("Current IP address : " + ip.getHostAddress());  */
      NetworkInterface network = NetworkInterface.getByInetAddress(ip);
      byte[] mac = network.getHardwareAddress();
      /*System.out.print("Current MAC address : ");   */
      StringBuilder sb = new StringBuilder();            
      for (int i = 0; i < mac.length; i++)
      sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
      System.out.println(sb.toString()); 
      } catch (UnknownHostException e) {
      e.printStackTrace();
      } catch (SocketException e){
      e.printStackTrace();
    and this into Formweb.cfg and default.env and also add into Form_class_path. After that i import this java into forms.
    Code genertated -
    PACKAGE BODY get_info IS
      -- DO NOT EDIT THIS FILE - it is machine generated!
      args   JNI.ARGLIST;
      -- Constructor for signature ()V
      FUNCTION new RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := NULL;
        RETURN (JNI.NEW_OBJECT('demo/get_info', '()V', args));
      END;
      -- Method: main ([Ljava/lang/String;)V
      PROCEDURE main(
        a0    ORA_JAVA.JARRAY) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
        JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'main', '([Ljava/lang/String;)V', args);
      END;
      -- Method: ch_add ()V
      PROCEDURE ch_add IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'ch_add', '()V', args);
      END;
      -- Method: wait (J)V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT,
        a0    NUMBER) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_LONG_ARG(args, a0);
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(J)V', args);
      END;
      -- Method: wait ()V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '()V', args);
      END;
      -- Method: wait (JI)V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT,
        a0    NUMBER,
        a1    NUMBER) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(2);
        JNI.ADD_LONG_ARG(args, a0);
        JNI.ADD_INT_ARG(args, a1);
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(JI)V', args);
      END;
      -- Method: equals (Ljava/lang/Object;)Z
      FUNCTION equals(
        obj   ORA_JAVA.JOBJECT,
        a0    ORA_JAVA.JOBJECT) RETURN BOOLEAN IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_OBJECT_ARG(args, a0, 'java/lang/Object');
        RETURN JNI.CALL_BOOLEAN_METHOD(FALSE, obj, 'demo/get_info', 'equals', '(Ljava/lang/Object;)Z', args);
      END;
      -- Method: toString ()Ljava/lang/String;
      FUNCTION toString(
        obj   ORA_JAVA.JOBJECT) RETURN VARCHAR2 IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'demo/get_info', 'toString', '()Ljava/lang/String;', args);
      END;
      -- Method: hashCode ()I
      FUNCTION hashCode(
        obj   ORA_JAVA.JOBJECT) RETURN NUMBER IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_INT_METHOD(FALSE, obj, 'demo/get_info', 'hashCode', '()I', args);
      END;
      -- Method: getClass ()Ljava/lang/Class;
      FUNCTION getClass(
        obj   ORA_JAVA.JOBJECT) RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_OBJECT_METHOD(FALSE, obj, 'demo/get_info', 'getClass', '()Ljava/lang/Class;', args);
      END;
      -- Method: notify ()V
      PROCEDURE notify(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notify', '()V', args);
      END;
      -- Method: notifyAll ()V
      PROCEDURE notifyAll(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notifyAll', '()V', args);
      END;
    BEGIN
      NULL;
    END;
    Now i want to call the o/p of Java programe in oracle text item. Please help me. It's very urgent. I am not good in Java.

    Sir i use java importer.
    PACKAGE BODY get_info IS
      -- DO NOT EDIT THIS FILE - it is machine generated!
      args   JNI.ARGLIST;
      -- Constructor for signature ()V
      FUNCTION new RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := NULL;
        RETURN (JNI.NEW_OBJECT('demo/get_info', '()V', args));
      END;
      -- Method: main ([Ljava/lang/String;)V
      PROCEDURE main(
        a0    ORA_JAVA.JARRAY) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
        JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'main', '([Ljava/lang/String;)V', args);
      END;
      -- Method: ch_add ()V
      PROCEDURE ch_add IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'ch_add', '()V', args);
      END;
      -- Method: wait (J)V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT,
        a0    NUMBER) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_LONG_ARG(args, a0);
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(J)V', args);
      END;
      -- Method: wait ()V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '()V', args);
      END;
      -- Method: wait (JI)V
      PROCEDURE wait(
        obj   ORA_JAVA.JOBJECT,
        a0    NUMBER,
        a1    NUMBER) IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(2);
        JNI.ADD_LONG_ARG(args, a0);
        JNI.ADD_INT_ARG(args, a1);
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(JI)V', args);
      END;
      -- Method: equals (Ljava/lang/Object;)Z
      FUNCTION equals(
        obj   ORA_JAVA.JOBJECT,
        a0    ORA_JAVA.JOBJECT) RETURN BOOLEAN IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_OBJECT_ARG(args, a0, 'java/lang/Object');
        RETURN JNI.CALL_BOOLEAN_METHOD(FALSE, obj, 'demo/get_info', 'equals', '(Ljava/lang/Object;)Z', args);
      END;
      -- Method: toString ()Ljava/lang/String;
      FUNCTION toString(
        obj   ORA_JAVA.JOBJECT) RETURN VARCHAR2 IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'demo/get_info', 'toString', '()Ljava/lang/String;', args);
      END;
      -- Method: hashCode ()I
      FUNCTION hashCode(
        obj   ORA_JAVA.JOBJECT) RETURN NUMBER IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_INT_METHOD(FALSE, obj, 'demo/get_info', 'hashCode', '()I', args);
      END;
      -- Method: getClass ()Ljava/lang/Class;
      FUNCTION getClass(
        obj   ORA_JAVA.JOBJECT) RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := NULL;
        RETURN JNI.CALL_OBJECT_METHOD(FALSE, obj, 'demo/get_info', 'getClass', '()Ljava/lang/Class;', args);
      END;
      -- Method: notify ()V
      PROCEDURE notify(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notify', '()V', args);
      END;
      -- Method: notifyAll ()V
      PROCEDURE notifyAll(
        obj   ORA_JAVA.JOBJECT) IS
      BEGIN
        args := NULL;
        JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notifyAll', '()V', args);
      END;
    BEGIN
      NULL;
    END;
    I read both document which is given by you.
    Basicaly i don't know how to call java program in form builder.
    I wrote this code on When-button-pressed
    DECLARE
    jo ora_java.jobject;
    rv varchar2(1500);
    ex ora_java.jobject;
    BEGIN
    jo := get_info.new;
    rv:=get_info.ch_add(jo );
    EXCEPTION
    WHEN ORA_JAVA.JAVA_ERROR then
      message (' Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR );
      message('');
    WHEN ORA_JAVA.EXCEPTION_THROWN then
      ex := ORA_JAVA.LAST_EXCEPTION;
      message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
      message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
    END;
    No error comes and no output comes. I want the client MAC ID. please guide me where i need to change the code.

  • How to use java code in my forms.................

    Hi All,
    I want to use the below java code in my form 6i ..but don't know how????????
    related function is also given below..........
    Any idea .......Please
    Thanks
    Harry.....
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class MyProgram {
    private static Connection con = null;
    private static Statement st;
    public static ResultSet rs;
    public static String s;
    /* public void setlable(int n)
    rs = st.executeQuery("SELECT number_to_words("+n+") FROM dual");
    while (rs.next())
    output.setText(rs.getString(1));
    public static void main(String[] args) {
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@172.19.193.38:1525:ITSTIN", "scott", "tiger");
    st = con.createStatement();
    }catch(Exception exp){
    System.out.println("Error"+exp.toString());
    JFrame f = new JFrame("Conver Digit to Words..");
    JLabel input = new JLabel("Enter Numeric digits :");
    final JLabel output = new JLabel("Please enter value into TestBox.....",JLabel.CENTER);
    final JTextField TF1 = new JTextField(90);
    final JButton B1 = new JButton("Close");
    f.setSize(750, 250);
    f.setLocation(300,200);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = f.getContentPane();
    contentPane.setLayout(null);
    contentPane.setBackground(Color.CYAN);
    TF1.setLocation(300,25);
    TF1.setSize(150,30);
    input.setLocation(175,25);
    input.setSize(150,30);
    input.requestFocus();
    output.setLocation(15,100);
    output.setSize(650,30);
    output.setForeground(Color.RED);
    B1.setSize(100,32);
    B1.setLocation(620,175);
    contentPane.add(TF1);
    contentPane.add(input);
    contentPane.add(output);
    contentPane.add(B1);
    f.setVisible(true);
    B1.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent me)
    System.exit(0);
    TF1.addKeyListener(new KeyAdapter(){
    public void keyReleased(KeyEvent event){
    if (TF1.getText().equals("") )
    output.setText("Please enter value into TestBox.....");
    else
    try
    if (TF1.getText().length()<12)
    s = "SELECT initcap(number_to_words("+Long.parseLong(TF1.getText())+")) FROM dual";
    rs = st.executeQuery(s); //Function number_to_words exists in scott@itstin created by AMUY-IN
    while (rs.next())
    output.setText(rs.getString(1));
    }catch(Exception e)
    System.out.println("Error-2"+e.toString());
    ================================function===============
    CREATE OR REPLACE FUNCTION amuy_con_to_eng(nm2 NUMBER) RETURN VARCHAR2 IS
    nm1 NUMBER(10,0) := nm2;
    NM VARCHAR2(100):='';
    div NUMBER;
    BEGIN
    WHILE nm1>0 LOOP
    IF nm1>=20 THEN
    div :=Floor(nm1/10);
    NM := NM||' '||base_convert(div*10);
    nm1:=Mod(nm1,10);
    END IF;
    IF nm1>=1 AND nm1<20 THEN
    NM := NM||' '||base_convert(nm1);
    nm1:=nm1/10;
    END IF;
    nm1 :=Floor(nm1/10);
    END LOOP;
    RETURN NM;
    END;
    CREATE OR REPLACE FUNCTION number_to_words(inm NUMBER) RETURN VARCHAR2 IS
    /* Function that converts number's to word's*/
    /* Created buy amuy-in */
    l_inm NUMBER(35,0);
    NM VARCHAR2(1000):='';
    div NUMBER;
    BEGIN
    l_inm := inm;
    IF inm<=0 THEN
    RETURN 'ZERO';
    ELSE
    WHILE l_inm>0 LOOP
    case when Length(l_inm) >= 1 AND Length(l_inm)<=2
    then RETURN NM||' '||sf_num_to_words(l_inm);
    when Length(l_inm) = 3
    then div :=Floor(l_inm/RPad(1,3,0));
    l_inm := Mod(l_inm,RPad(1,3,0));
    NM :=NM||' '||sf_num_to_words(div)||' '||'HUNDRED';
    when Length(l_inm) >= 4 AND Length(l_inm) <= 5
    then div :=Floor(l_inm/RPad(1,4,0));
    l_inm := Mod(l_inm,RPad(1,4,0));
    NM :=NM||' '||sf_num_to_words(div)||' '||'THOUSAND';
    when Length(l_inm) >= 6 AND Length(l_inm) <= 7
    then div :=Floor(l_inm/RPad(1,6,0));
    l_inm := Mod(l_inm,RPad(1,6,0));
    NM :=NM||' '||sf_num_to_words(div)||' '||'LAKH';
    when Length(l_inm) >= 8 AND Length(l_inm) <= 9
    then div :=Floor(l_inm/RPad(1,8,0));
    l_inm := Mod(l_inm,RPad(1,8,0));
    NM :=NM||' '||sf_num_to_words(div)||' '||'CRORE';
    when Length(l_inm) >= 10 AND Length(l_inm) <= 11
    then div :=Floor(l_inm/RPad(1,10,0));
    l_inm := Mod(l_inm,RPad(1,10,0));
    NM :=NM||' '||sf_num_to_words(div)||' '||'ARAB';
    ELSE RETURN 'ERROR {Length of input value should be <12}';
    END CASE;
    END LOOP;
    RETURN NM ;
    END IF;
    END;
    /

    You cannot use java directly inside forms. You can either create a java-bean to enhance the GUI (as you have some UI-components in your java-code, i guess this would be the direction) or use the java-importer and call server-side-java. Both require that you are running forms in a web-version and not as client-server.
    What exactly is your requirement?

  • How to call java function in Oracle forms?

    Hi I am having Oracle 9i with 10g Developer Suite.
    I am new to Oracle forms..
    I had one function in java getDatas()..
    How can I call this function in Oracle Forms..
    Pls help
    Thanks

    Thanks Francois,
    I want to display values from my java code in the Forms..
    For that purpose only i am installing 10g Developer Suite..
    The below is java code..
    public class DBTest {
              public static String callDB(int id,String name){
              String ss="Hai";
              Connection con=null;
              try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("url","id","pwd");
                   Statement st=con.createStatement();
                   System.out.println("Connected...");
              int r=st.executeUpdate("Insert into FORM_TEST VALUES('"+id+"','"+name+"')");
                   if(r==1){
                        ss="Inserted Sucessfully";
                   else{
                        ss="Insertion Failed";
              }catch(final Exception e){
              System.out.println(e);
              return ss;
         public static void main(String[] args) {
              int empid=102;
              String empname="Gilbert";
              String resultStr=callDB(empid,empname);
              System.out.println(resultStr);
    I want to dispaly Inserted or Insertion Failed in Oracle Forms..
    As per Gerd Volberg suggestion, i had placed DBTest.jar in
    E:\DevSuite\forms\java\DBTest.jar
    and in formsweb.cfg the below jar is added..
    archive_jini=frmall_jinit.jar,DBTest.jar
    But in Fomrs Builder-->Program-->Import Java Classes-->Oracle
    org,ice,com and subnodes are available.
    But my jar is not available..
    Is my way is coorect?
    Pls provide soln..
    Thanks

  • How to use Java Script in Oracle Forms 10g

    Hello,
    Appreciate if anyone could help me using Java Script in Oracle Forms 10g?
    Thanks
    GM

    Thank you for your reply. I was reading on the metalink that we could use the to call the java script from oracle Forms 10g (Doc ID 265863.1)
    Example:
    WEB.SHOW_DOCUMENT ('javascript:void(window.open("http://www.oracle.com","","location=no,toolbar=no,menubar=no,status=no,"));self.close()','_blank');
    I tried it but it did not open the any window as it claims. Am I missing anything? Is there any IE related setting which I need to modify for the above to work?
    Regards
    GM

  • How to import java library file to forms 6i

    Hi all,
    Is it possible to import java library file to forms 6i. Please help me.

    The Java importer is introduced in 9i.
    However, most java functionality is added to Forms in the client, not the server. In 6i you can add Java pluggable components to your forms. You need to make a Java Pluggable Component to do this. Stand-alone Java beans can only be called from Forms 9i on using the fbean package.
    So it depends on what you want to do with the java whether it is possible to use it in 6i.

  • How to solve delay in a program with data aquisition and processing

    Hello, I am a starter in Labview programing. I am working on a system which contains a roller, a piston and a A/D cart which is from Data Translation Inc (DT304). I am using labview to get speed data of the roller (which is voltage first then be converted into speed) from Analog Input Channels, and then using Analog Output Channels to control the friction force being appylied to the roller by using a piston.
    I am using a Waveform Chart to show the speed of roller. However, as I am adding more components to the program, I always get delay in the speed display and also the output control of the piston. Also, as I spent more time using the program eg. from morning to night, it became slower too.
    My question is, how does labview store data and how are the data been stored and released in the buffer.Is it because I am loading too much data in the buffer so that it became slower? And also how to solve these delays?
    I am using the "save to file" function to write data to a ".lvm" file, but I did some changes to the saving by using a button to enable and disable saving. So I don't think the problem is because I am always saving the data into a file.
    Thank you very much.
    Jessie

    I'm betting it's two things:
    1. Program Architecture
    and 2. Dynamically resizing arrays.
    With the program architecture... if you have one do-while loop that acquires data from teh DAQ, processes it, opens/indexes/writes/closes a file, then comes back around... as your arrays and files increase in size, the loop is going to take longer to execute.  A Producer-Consumer loop (a good tutorial on them can be found here) has one loop that acquires data and stuffs the data into a queue.  This will buffer the data while it's in transition between acquisition and processing.  A second loop in parallel takes data in from the queue, processes it, then comes back around.  The two loops operate independently of each other, so even if the consumer loop takes longer as the files or math gets more complex, the producer loop continues to run full speed.
    Second is the arrays.  Every time you append data into an array, LabVIEW has to make a copy of the data that's in the array.  If you append small amounts of data to an array over and over and over again, eventually LabVIEW is going to be copying very large amounts of data over and over and over again.  The producer-consumer architecture can alleviate this problem.

  • How to perform validity checks just before form data is saved?

    hello all,
    i need to perform some checks on various fields just before data on a standard form is saved, and to eventually rollback the transaction.
    if the checks are succesful i have to perform some db operation in transaction with main data.
    solution ( if existent! )  has to be addin only -> no triggers / no procedures / no sbo_transaction thingies
    scenario:
    involved tables:
    OITM
    USERDEFINEDTABLE1
    USERDEFINEDTABLE2
    involved forms:
    Items - OITM - formtypeex = "150"
    logic:
    an user defined field U_UDFCHECKACTIVE has been added to OITM, a combo box has been added to items form containing values Y and N, bound to OITM.U_UDFCHECKACTIVE.
    when the user saves an item, if OITM.U_UDFCHECKACTIVE == Y we have to perform additional checks on USERDEFINEDTABLE1
    if the check result is true we have to save OITM current data and insert a record in USERDEFINEDTABLE2 containing itmgrp value (  )
    if the check result is false we have to block save operation
    if OITM.U_UDFCHECKACTIVE == N no check is performed and everything works normally
    we started hooking the form data event for oitm / form type 150:
    Application.SBO_Application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(FormDataEventHandler.SBO_Application_FormDataEvent);
    then we filtered the event
    switch (BusinessObjectInfo.FormTypeEx)
                        case "150":
                            if (BusinessObjectInfo.BeforeAction &&
                                (BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE ||
                                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD))
                                BL.Items_BusinessLogic.SBO_Application_FormDataEvent(ref BusinessObjectInfo, out BubbleEvent);
    in our business logic class i don't know how to correctly check the values just before they are saved to db
    for example i tried using oitm.browser :
    if (oitm.Browser.GetByKeys(BusinessObjectInfo.ObjectKey))
                            String value =  oitm.UserFields.Fields.Item("U_UDFCHECKACTIVE ").Value as String;
                             //perform checks
                                  //if ok insert records and bubbleevent = true
                                  //if ko rollback the bubbleevent = false
    //if checks are not to be performed then bubbleevent = true....
    but it's wrong, as it populates oitm object from db, and not from the form. i have old values stored in the object, values tha are to be overwritten with those present on form.
    i tried inspecting the form for data sources but i don't know how to navigate to the right one, i found only system generated objects with SYS_##, with no clue about the related dbfield
    i tried getting the values directly from the form, but in object BusinessObjectInfo i don't have anything that identifies univocally the form i'm editing.
    i mean if i have 2 item forms open, i don't know which one is the one i'm saving.
    i'm expecting to find somewhere a temporary oitm business object containing values that are to be saved, values that i can easily check.
    so i'm asking you how to find those values in order to perform my bl checks
    thank you in advance

    Hi Christian,
    The values that are about to be saved should be in the datasources:
    form.DataSources.DBDataSources.Item("OITM");
    form.DataSources.DBDataSources.Item("ITM1");
    The form variable should be form 150.
    Best regards,
    Pedro Magueija

  • How to run recordset SQL query in FORM DATA event

    How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?

    Hi Slamet,
    When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
    With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
    There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
    <i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
    Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
    Hope it helps
    Trinidad.

Maybe you are looking for

  • Finger sticks when playing games

    Does anyone else have a problem with their thumb sticking real bad when playing games that use a directional pad or joystick on screen? Maybe im the only one but it makes some games almost impossible to play. Any ideas or solutions?

  • Urgent, SELECT statement results in error

    hi all, this is very urgent, could you guys have a look at my SELECT statement?   SELECT vk~kunnr         "customer no           vk~vbeln         "sales order no           vk~audat         "date           vk~vbtyp         "SD DOCUMENT CATEGORY       

  • Purchase requisition to purchase order with different delivery dates

    Hi, Could any body explaon me , when ever a Purchase order is created with ref to purchase requisition the delivery dates can not be split up .(system shows an error message : error in net px calculation). Please revert back with your suggestions. Re

  • X1 Carbon model numbers 34442HU and 3444AZU - what's the difference?

    Hi guys, I'm ready to buy a new X1 Carbon (non-touch version) but I found two model codes for the same price and would like to know if there's any difference between them. They're model numbers 3444-2HU and 3444-AZU. I checked Lenovo's Maintenance Ma

  • Problème avec ma mise à jour

    Je suis perdue ! j'ai téléchargé la dernière mise à jour de iphoto par apple store. Depuis, plus rien ne marche ! Je transfère de mon appareil photo vers mon Mac puis sur iphoto. jusque là pas de problème. ensuite si je veux lire les photos ou faire