Catch of CONVT_NO_NUMBER does not work on 4.6c?

Hi Guys,
I'm having a strange problem. We have a 4.6C system here, an I have the following code:
DATA: h_sub   TYPE n.
DATA: h_part3 TYPE string.
CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
IF h_part3 > h_sub.
   h_sub = h_part3.
ENDIF.
ENDCATCH.
IF sy-subrc = 1.
   ADD 1 TO h_sub.
ENDIF.
So in cases that variable h_part3 does not contain a number the statement "IF h_part3 > h_sub." raises a CONVT_NO_NUMBER-exception. Strange thing now: My catch-mechanism does not work! I still get a short dump!
Any idea what went wrong?
Thanks and regards
Jan Hempel

I found the reason for this behaviour: it seems like that the if-statement ("IF h_part3 > h_sub") does not have its own conversion-functionality.
I changed my code by adding an explicit move-statement before the if-clause and that does the trick:
      CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
        MOVE h_part3 TO h_number.
      ENDCATCH.
      IF sy-subrc = 1.
        ADD 1 TO h_sub.
      ELSE.
        IF h_number > h_sub.
          h_sub = h_number.
        ENDIF.
      ENDIF.

Similar Messages

  • Open a view twice does not work

    Hello,
    I have a problem with bsp-views:
    I open a new window via the JavaScript command
    <script type="text/javascript" language="javascript">
      open( "<%= controller->mv_srch_url%>",
            "searchTask", "resizable=no, scrollbars=no,
             status=yes, menubar=no, width=320, height=522,
             top=50, left=50" );
    </script>
    If I close this window via the 'X' on the upper right corner of the window and want to open the popup again it doesn't work. This JavaScript command passes correctly but no window is opened.
    If I close the popup via a button where a submit is made to the calling (parent) document and open it again, everything works fine.
    Now I have two questions:
    1. Does anybody have an idea why the popup cannot be opened again?
    2. If not, I would like to make a submit if the popup is closed by the 'X'. I tried this in my bsp-view:
    <script language="javascript">
            function do_submit(){
            var theForm = window.opener.document.getElementById("theForm");
               theForm.submit();}
            window.onUnload = do_submit
    </script>
    but it did not work.
    I would be very grateful for any help.
    Best regards,
    Ralph
    Message was edited by: Ralph Rillig
    Catching the 'X' does not work, but opening the popup twice is working. I used the following coding:
    open( "<%= controller->mv_srch_url%>",
            "searchTask<%=sy-uzeit>", "resizable=no, scrollbars=no,
             status=yes, menubar=no, width=320, height=522,
             top=50, left=50" );

    Ralph
    try the following...
    1) create a new parameter or variable named callPopup (type CHAR01) with a default value 'N'.
    2) then in your view put the following;
    <% IF callPopup = 'S'. callPopup = 'N'. %>
    <script type="text/javascript" language="javascript">
    open( "<%= controller->mv_srch_url%>",
    "searchTask", "resizable=no, scrollbars=no,
    status=yes, menubar=no, width=320, height=522,
    top=50, left=50" );
    </script>
    <% ENDIF. %>
    3) Then when the user press the button to search (or the event to call the popup) just put the value of this variable to 'S'.
    Try it...
    Ariel

  • Help with util.zip up files... does not work

    I am writing a program so my mum can zip up new photos she takes and then send them to me. The program creates a html file for the webpage plus a smaller version of her original photo and places them all in a 1 folder with a new name. Al this part works... I want to afterwards place my files in a zipped up folder that she can e-mail me with her normal client. How... I picked up this code on the net and have changed it to incoporate my parameters. The files which are created ..paths are (String in an String[]) I then send to my zipping method.
    The zip file is created but does not work when I try to extract from it ??? I also know that the String [] works becuse I have made a loop to check its properties at each index.
    what am I doing wrong?
    This is a modified code I found on the internet but with no author??
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.*;
    public class Test{
        private File zipDir;
        private String[] filename;
        public Test(String[] recivedFilename){
            filename = recivedFilename;
            try {
                ZipOutputStream zos = new
                        ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
                from,
                zipDir("c:\\batviapictures\\", zos);
                zos.close();
            } catch(Exception e) {
                //handle exception
        public void zipDir(String dir2zip, ZipOutputStream zos) {
            try {File
                zipDir = new File(dir2zip);
                String[] dirList = filename;
                byte[] readBuffer = new byte[2156];
                int bytesIn = 0;
                //loop through dirList, and zip the files
                for(int i=0; i<dirList.length; i++) {
                    File f = new File(zipDir, dirList);
    if(f.isDirectory()) {
    String filePath = f.getPath();
    zipDir(filePath, zos);
    continue;
    FileInputStream fis = new FileInputStream(f);
    ZipEntry anEntry = new ZipEntry(f.getPath());
    zos.putNextEntry(anEntry);
    while((bytesIn = fis.read(readBuffer)) != -1) {
    zos.write(readBuffer, 0, bytesIn);
    fis.close();
    catch(Exception e) {

    I make no guarantees that this will completely solve all your problems, but I just know these calls are needed but missing from your OP:
    try {
        ZipOutputStream zos = new
                        ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
                        from,
                        zipDir("c:\\batviapictures\\", zos);
        zos.flush(); // ADD THIS after all files have been written to the zos
        zos.close();
    } catch(Exception e) {
        //handle exception
    }And
    while((bytesIn = fis.read(readBuffer)) != -1) {
        zos.write(readBuffer, 0, bytesIn);
    zos.closeEntry(); // ADD THIS after each file is written to the zos
    fis.close();

  • My weather forecast does not work!

    My weather forecast does not work, the animation background catching this.
    This equals the image of the print, it does not move.

    Try:
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings                 
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes
    - Restore to factory settings/new iOS device.                       

  • Applet does not work with a proxy server.URgent

    Hi,
    I have an asp page being hosted from a IIS server.
    The asp page has an applet which gets data from a server side component which is hosted as a service on the server side.For connection to the server I am using URLConnection object and trying to connect over a TCP connection.
    The problem occurs when I use an proxy in the middle.
    I have changed the browser settings to include the proxy.
    The following is the error I recieve:
    Full :http://172.25.11.63:4590/
    <-------------------------------->
    OPening input stream
    in Run ::::
    ERROR: Created data socket but can't open stream on
    it.172.25.11.63:4590//
    172.25.11.63:4590//
    java.io.FileNotFoundException: 172.25.11.63:4590//
         at com/ms/net/wininet/http/HttpInputStream.connect
         at com/ms/net/wininet/http/HttpInputStream.<init>
         at com/ms/net/wininet/http/HttpURLConnection.createInputStream
         at com/ms/net/wininet/WininetURLConnection.getInputStream
         at TalkClientApplet.rendezvous
         at TalkClientApplet.actionPerformed1
         at TalkClientApplet.start
         at com/ms/applet/AppletPanel.securedCall0
         at com/ms/applet/AppletPanel.securedCall
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run
    ...Disconnecting.
    Following is my code.
    url = new URL("http://" + host +":"+i);
    urlconnection = url.openConnection();
    urlconnection.setDoOutput(true);
    urlconnection.setDoInput(true);
    System.out.println("Successfully opened the URL connection at " + "http://" + host + ":" + i );
              System.out.println ("Protocol: " + url.getProtocol());
              System.out.println ("Host :" + url.getHost());     
              System.out.println ("Port :" + url.getPort());
              System.out.println ("File :" + url.getFile() );
              System.out.println ("Full :" + url.toExternalForm());
              System.out.println ("<-------------------------------->");
    os = new BufferedWriter(new OutputStreamWriter(urlconnection.getOutputStream()));
    System.out.println("OPening input stream ");
    // is = new DataInputStream(urlconnection.getInputStream());
         System.out.println(urlconnection.getInputStream());
    is = new DataInputStream(urlconnection.getInputStream());
    The exact place where I get the error is whn i call URLConnection.openInputStream().
    Usually this error comes with a malformed URL.But the same code words without a proxy.Also I am not making any changes to my code in both scenarios that is with or without proxy.
    Please help.This is urgent and a showstopper

    Thanks for your nice solution, but unfortunatelly it does not work with lines longer than 100 chars with Netscape. It works fine with IE and appletviewer too.
    Example:
    I use this code:
    try {
                URL url = new URL(protocol,hostName,portNumber,URLstring);
                InputStream in = url.openStream();
                BufferedInputStream bis = new BufferedInputStream(in);
                StringBuffer input = new StringBuffer(60);
                int c;
                while ((c = bis.read()) != -1){
                    System.out.print((char)c);
                    input.append((char)c);
                bis.close();
                dataFromServer = input.toString();
            catch(Exception ex) {
                ex.printStackTrace();
            }I use input file test.html with exactly 100 chars ('a')
    Netscape Java Console:
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadataFromServer : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaI use input file test.html with exactly 101 chars ('a')
    Netscape Java Console:
    ?JL?yyxk?cedataFromServer : ?

  • JasperReports does not work outside Netbeans

    Hi guys,
    Background story: application with a couple of forms, the data can be stored and saved from a sqlite database. In the end the forms need to be saved as a PDF.
    Netbeans 6.7, JasperReports 4.0.2.
    Libraries in my Classpath: Commons-beanutils, Commons collections, commons digester, commons javaflow, commons logging, iText, Jasperreports
    I tried to use JasperReports for this matter. It runs perfectly when in Netbeans, and my PDF is generated.
    However, when I try to run the compiled .jar file from windows explorer... the whole JasperReports part does not work at all.
    I made a simple example showing my problem. It produces a nice 1 line PDF when in netbeans, but outside Netbeans, nothing again.
    Could you give me some advice on this? Or maybe an alternative for JasperReports?
    Thanks alot,
    Elwin
    package jasperreportsproject2;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import net.sf.jasperreports.engine.*;
    import net.sf.jasperreports.engine.export.*;
    import java.util.*;
    * @author Elwin
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            String fileName = "test1.jrxml";
            String outFileName = "test.pdf";
            HashMap hm = new HashMap();
                // Fill the report using an empty data source
            try {
                JasperPrint print;
                JasperReport jasperreport;
                jasperreport = JasperCompileManager.compileReport(fileName);
                print = JasperFillManager.fillReport(jasperreport, hm, new JREmptyDataSource());
                // Create a PDF exporter
                JRExporter exporter = new JRPdfExporter();
                // Configure the exporter (set output file name and print object)
                exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
                // Export the PDF file
                exporter.exportReport();
                } catch (JRException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }The xml file used to build the report
    Test1.jrxml
    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="HelloWorld" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
         <property name="ireport.zoom" value="1.0"/>
         <property name="ireport.x" value="0"/>
         <property name="ireport.y" value="0"/>
         <detail>
              <band height="200" splitType="Stretch">
                   <staticText>
                        <reportElement x="0" y="0" width="500" height="20"/>
                        <textElement/>
                        <text><![CDATA[Hello Report World!]]></text>
                   </staticText>
              </band>
         </detail>
    </jasperReport>

    Another for xsql:
    Producing PDF Output with the FOP Serializer
    at
    http://www.stanford.edu/dept/itss/docs/oracle/10gR2/appdev.102/b14252/adx_j_xsqladv.htm
    NA
    http://nickaiva.blogspot.com

  • This.print(pp) with interactive type silent or automatic does not work  after upgrade acrobat reader 9 to acrobat reader 11

    After an upgrade of acrobat reader 9 to acrobat reader 11 the automatic printing of a pdf. The pdf is opened, but the print does not happen. With acrobat reader 9 it works. But with acrobat reader 11 the printing does not happen.
    I discovered when you specify pp.constants.interactionLevel.full it works on acrobat reader 11. But when you specify pp.constants.interactionLevel.silent or pp.constants.interactionLevel.automatic it does not work on acrobat reader 11. But with the full option we have a dialog  print box
    we do not want.
    In our jsp we load a pdf document and create a message handler to detect the print events of a pdf document that is in an <object> tag.
    In the pdf document we add
    package be.post.lpo.util;
    import org.apache.commons.lang.StringEscapeUtils;
    import org.apache.commons.lang.StringUtils;
    public class AcrobatJavascriptUtil {  
        public String getPostMessageToHostContainer(String messageName, String messageBody){
            return "var aMessage=['"+messageName+ "', '"+ messageBody+"'];this.hostContainer.postMessage(aMessage);";
        public String getAutoPrintJavaScript(String interactiveType, String printerName,String duplexType) {    
            String interactiveTypeCommand = "";
            if (StringUtils.isNotBlank(interactiveType)){
                interactiveTypeCommand = "pp.interactive = " + interactiveType + ";";
            String duplexTypeCommand = "";
            if (StringUtils.isNotBlank(duplexType)){
                duplexTypeCommand = "pp.DuplexType = " + duplexType + ";";
            return "" + // //
                    "var pp = this.getPrintParams();" + // //
                    // Nointeraction at all dialog, progress, cancel) //
                    interactiveTypeCommand + //
                    // Always print to a printer (not to a file) //
                    "pp.printerName = \"" + StringEscapeUtils.escapeJavaScript(printerName) + "\";" + //
                    // Never print to a file. //
                    "pp.fileName = \"\";" + //
                    // Print images using 600 DPI. This option MUST be set or some barcodes cannot //
                    // be scanned anymore. //
                    "pp.bitmapDPI = 600;" + //
                    // Do not perform any page scaling //
                    "pp.pageHandling = pp.constants.handling.none;" + //
                    // Always print all pages //
                    "pp.pageSubset = pp.constants.subsets.all;" + //
                    // Do not autocenter //
                    "pp.flags |= pp.constants.flagValues.suppressCenter;" + //
                    // Do not autorotate //
                    "pp.flags |= pp.constants.flagValues.suppressRotate;" + //
                    // Disable setPageSize i.e. do not choose paper tray by PDF page size //
                    "pp.flags &= ~pp.constants.flagValues.setPageSize;" + //
                    // Emit the document contents. Document comments are not printed //
                    "pp.printContent = pp.constants.printContents.doc;" + //
                    // printing duplex mode to simplex, duplex long edge, or duplex short edge feed //
                    duplexTypeCommand +
                    // Print pages in the normal order. //
                    "pp.reversePages = false;" + //
                    // Do the actual printing //
                    "this.print(pp);";
    snippets for java code that adds
    package be.post.lpo.util;
    import org.apache.commons.lang.StringUtils;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.pdf.PdfAction;
    import com.lowagie.text.pdf.PdfDestination;
    import com.lowagie.text.pdf.PdfImportedPage;
    import com.lowagie.text.pdf.PdfName;
    import com.lowagie.text.pdf.PdfReader;
    import com.lowagie.text.pdf.PdfWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    public class PdfMergerUtil{
        private static final PdfName DID_PRINT = PdfName.DP;
        private static final PdfName WILL_PRINT = PdfName.WP;
        private List<PdfActionJavaScriptHolder> actionJavaScripts = new ArrayList<PdfActionJavaScriptHolder>();
        private class PdfActionJavaScriptHolder{
            private final PdfName actionType;
            private final String javaScript;
            public PdfActionJavaScriptHolder(PdfName actionType, String javaScript) {
                super();
                this.actionType = actionType;
                this.javaScript = javaScript;
            public PdfName getActionType(){
                return this.actionType;
            public String getJavaScript(){
                return this.javaScript;
        public void writePdfs(OutputStream outputStream, List<InputStream> documents, String documentLevelJavaScript) throws Exception {
            Document document = new Document();
            try {          
              // Create a writer for the outputstream
              PdfWriter writer = PdfWriter.getInstance(document, outputStream);
              document.open();      
              // Create Readers for the pdfs.
              Iterator<PdfReader> iteratorPDFReader = getPdfReaders(documents.iterator());
              writePdfReaders(document, writer, iteratorPDFReader);
              if (StringUtils.isNotBlank(documentLevelJavaScript)){
                  writer.addJavaScript(documentLevelJavaScript);
              addAdditionalActions(writer);
              outputStream.flush();      
            } catch (Exception e) {
                e.printStackTrace();
                throw e;
            } finally {
                if (document.isOpen()){
                    document.close();
                try {
                    if (outputStream != null){
                        outputStream.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                    throw ioe;
        public void addAdditionalDidPrintAction(String javaScript){
            actionJavaScripts.add(new PdfActionJavaScriptHolder(DID_PRINT, javaScript));   
        public void addAdditionalWillPrintAction(String javaScript){
            actionJavaScripts.add(new PdfActionJavaScriptHolder(WILL_PRINT, javaScript));   
        private void writePdfReaders(Document document, PdfWriter writer,
                Iterator<PdfReader> iteratorPDFReader) {
            int pageOfCurrentReaderPDF = 0;      
              // Loop through the PDF files and add to the output.
              while (iteratorPDFReader.hasNext()) {
                PdfReader pdfReader = iteratorPDFReader.next();
                // Create a new page in the target for each source page.
                while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
                  document.newPage();
                  pageOfCurrentReaderPDF++;          
                  PdfImportedPage page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
                  writer.getDirectContent().addTemplate(page, 0, 0);          
                pageOfCurrentReaderPDF = 0;
        private void addAdditionalActions(PdfWriter writer) throws DocumentException{
            if (actionJavaScripts.size() != 0 ){
                PdfAction action = PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.FIT), writer);
                writer.setOpenAction(action);
                for (PdfActionJavaScriptHolder pdfAction : actionJavaScripts ){
                    if (StringUtils.isNotBlank(pdfAction.getJavaScript())){
                        action = PdfAction.javaScript(pdfAction.getJavaScript(), writer);
                        writer.setAdditionalAction(pdfAction.getActionType(), action);
        private Iterator<PdfReader> getPdfReaders(Iterator<InputStream> iteratorPDFs) throws IOException {
            List<PdfReader> readers = new ArrayList<PdfReader>();
              while (iteratorPDFs.hasNext()) {
                InputStream pdf = iteratorPDFs.next();
                PdfReader pdfReader = new PdfReader(pdf);
                readers.add(pdfReader);        
            return readers.iterator();
    JSP code
    <script type="text/javascript" src="<bean:message key="scripts.js.internal.jquery" bundle="app"/>"></script>
        <script language="javascript">
        function goToDidPrintUrl(){
            var url = "<%=didPrintUrl%>";
            window.location.assign(url);
        function createMessageHandler() {
            var PDFObject = document.getElementById("myPdf");
            PDFObject.messageHandler = {
                onMessage: function(msg) {
                     if (msg[0] == "WILL_PRINT"){      
                        $("#printingTransitFeedBackMessage").text('<%=willPrintMessage%>');                   
                     if(msg[0] == "DID_PRINT"){
                        $("#printingTransitFeedBackMessage").text('<%=didPrintMessage%>');               
                        setTimeout('goToDidPrintUrl()',4000);
                onError: function(error, msg) {
                    alert(error.message);
        </script>
    </head>
    <body onLoad="createMessageHandler();">
    <div id="printingTransitFeedbackArea">
      <div class="info" id="printingTransitFeedBackMessage"><%=documentOpenMessage%></div>
    </div>
    <object id="myPdf" type="application/pdf" width="100%" height="100%"  data="<%=toBePrintedUrl%>">
    </object>
    </body>

    From the JS API Reference of the print method:
    Non-interactive printing can only be executed during batch, console, and menu
    events.
    Outside of batch, console, and menu events, the values of bUI and of interactive are ignored
    and a print dialog box will always be presented.

  • Threads does not work correctly

    The follow program working with threads. We have two classses : Producer and Customer which working with the same object (which type is class Q). Producer produces data. Customer should capture the data. The Q class must be synchronized. But code does not work (compile under NetBeans 6.0)
    class Q {
    int number = 0;
    boolean filled = false;
    void put (int n) {
    while (filled){
    try {
    wait();
    catch(InterruptedException e) {
    System.out.println("Interrupted");
    number = n;
    System.out.println("Put : " + number);
    filled = true;
    notify();
    void get () {
    while (!filled) {
    try {
    wait();
    catch(InterruptedException e) {
    System.out.println("Interrupted");
    System.out.println("Got : " + number);
    filled = false;
    notify();
    class Producer implements Runnable {
    Q obj_link;
    Thread t;
    Producer (Q obj_link) {
    this.obj_link = obj_link;
    t = new Thread(this, "Producer");
    t.start();
    public void run () {
    int i = 0;
    while (true) {           
    obj_link.put(i++);
    class Customer implements Runnable {
    Q obj_link;
    Thread t;
    Customer (Q obj_link) {
    this.obj_link = obj_link;
    t = new Thread(this, "Customer");
    t.start();
    public void run () {
    while (true) {
    obj_link.get();
    public class Main {
    public static void main(String[] args) {
    Q common_obj = new Q();
    Producer pr = new Producer (common_obj);
    Customer cs = new Customer (common_obj);
    try{
    pr.t.join();
    cs.t.join();
    catch(InterruptedException e) {
    System.out.println("Interrupted");
    System.out.println("Program Over");
    }

    The follow program working with threads. We have two classses : Producer and Customer which working with the same object (which type is class Q). Producer produces data. Customer should capture the data. The Q class must be synchronized. But code does not work (compile under NetBeans 6.0).
    I.e. i am waiting for the follow result:
    1. pr thread starts with common_obj object
    2. cs thread starts with common_obj object
    3. pr thread tries call common_obj.put(i++) in infinite cycle:
    3.1 these lines does not work because filled now is set to false
            while (filled){
                try {
                    wait();
                catch(InterruptedException e) {
                    System.out.println("Interrupted");       
            }3.2 the follow code will be implemented:
            number = n;    // put value to number
            System.out.println("Put : " + number); // output result to console
            filled = true; // value was put. It can be got.
            notify(); // notify another thread (cs) that it should not waiting anymore.4. pr thread tries call common_obj.get() in infinite cycle:
    4.1 the following code will not be implemented anymore:
            while (!filled) {
                try {
                    wait();
                catch(InterruptedException e) {
                    System.out.println("Interrupted");       
            } since another thread notify current.
    4.2 the follow code will be implemented:
            System.out.println("Got : " + number);
            filled = false;
            notify();So the result of running this program should be:
    Put : 0
    Got: 0
    Put : 1
    Got: 1
    Put : 2
    Got: 2
    Put : 3
    Got: 3
    Put : 4
    Got: 4
    class Q {
        int number = 0;
        boolean filled = false;
        void put (int n) {
            while (filled){
                try {
                    wait();
                catch(InterruptedException e) {
                    System.out.println("Interrupted");       
            number = n;
            System.out.println("Put : " + number);
            filled = true;
            notify();
        void get () {
            while (!filled) {
                try {
                    wait();
                catch(InterruptedException e) {
                    System.out.println("Interrupted");       
            System.out.println("Got : " + number);
            filled = false;
            notify();
    class Producer implements Runnable {
        Q obj_link;
        Thread t;
        Producer (Q obj_link) {
           this.obj_link = obj_link;
           t = new Thread(this, "Producer");     
           t.start();
        public void run () {
            int i = 0;
            while (true) {           
                obj_link.put(i++);
    class Customer implements Runnable {
        Q obj_link;
        Thread t;
        Customer (Q obj_link) {
           this.obj_link = obj_link;
           t = new Thread(this, "Customer");     
           t.start();
        public void run () {
            while (true) {
                obj_link.get();
    public class Main {
        public static void main(String[] args) {
            Q common_obj = new Q();
            Producer pr = new Producer (common_obj);
            Customer cs = new Customer (common_obj);
            try{
                pr.t.join();
                cs.t.join();
            catch(InterruptedException e) {
                System.out.println("Interrupted");
            System.out.println("Program Over");
    }the follow result of implementation I found:
    run:
    Put : 0
    Exception in thread "Producer" java.lang.IllegalMonitorStateException
    Got : 0
    at java.lang.Object.notify(Native Method)
    at threadstudy2.Q.put(Main.java:19)
    Program Over
    at threadstudy2.Producer.run(Main.java:50)
    at java.lang.Thread.run(Thread.java:619)
    Exception in thread "Customer" java.lang.IllegalMonitorStateException
    at java.lang.Object.notify(Native Method)
    at threadstudy2.Q.get(Main.java:33)
    at threadstudy2.Customer.run(Main.java:68)
    at java.lang.Thread.run(Thread.java:619)
    BUILD SUCCESSFUL (total time: 1 second)

  • BUG: Oracle Schema Processor does not work in Servlets

    We found a bug with Oracle's Schema Processor. It does not work in Servlets.
    When we try to validate a XML document in a Servlet it does not work, but we can execute the same code in a stand alone application and it works.
    The following is the code we are using:
    try {
    File f =new File(filename);
    FileReader r = new FileReader(f);
    DOMParser dp = new DOMParser();
    URL url = createURL (filename);
    dp.setValidationMode(false);
    dp.setSchemaValidationMode(true);
    dp.setPreserveWhitespace(true);
    dp.parse(url);
    System.out.println("it is parsed");
    } catch(Exception e){System.out.println("there is Error"+e.getMessage());}
    null

    I don't think this is related to Servlets per se.
    Check that the Schema processor classes used by the servlet container, and your application are the same.
    Java does not have proper versioning of classes, I have seen many applications collapse. People compiled their code on developer machines, where it worked fine, but when moved to a production machine they failed because the production machine had a different version of classes. Usually the name of the class doesn't change, but either a method or a variable is missing in several classes. VM doesn't complain but simply crashes.
    In your Schema Processor classes that are used by the servlet engine might be different from the one that the app uses. Do a search on the file system to see how many copy of the same class bundle (zip, jar) you have on the system.

  • I have F.F 3.6 and windows 7.: 1) When i want to buy a airplane ticket and want to select 2 adults or 2 children, the draw down select, does not work in any websides,? WHY?. 2) Have FF any problems with SKYPE

    I have F.F 3.6 and windows 7.: 1) When i want to buy a airplane ticket and want to select 2 adults or 2 children, the draw down select, does not work in any websides,? WHY?. 2) Have FF any problems with SKYPE
    == This happened ==
    Not sure how often
    == After innstalling windows 7

    As a suggestion I'd put the Text_io segments into their own begin - exception - end sub-blocks within the main code. This way if Text_io does raise an exception you can catch it earlier as it may be able to recover - That is if it is a text_io exception.
    Other than that you;ll have to step through in Debug.

  • This program is well compiled but does not work.

    I would like to know why this program does not work properly:
    the idea is :
    1. the user introduces a text as a string
    2.the progam creates a file (with a FileOutputStream)
    3. then this file is encripted according to DES (using JCE, cipheroutputStream)
    4.the new filw is an encripte file, whose content is introduced in a string (with a FileInputStream)
    (gives no probles of compilation!!)
    (don know why it does not work)
    here goes the code:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    import java.security.*;
    import javax.crypto.*;
    public class cuadro extends Applet{
         private TextArea area1 =new TextArea(5,50);
         private TextArea area2 =new TextArea(5,50);
         private Button encriptar=new Button("encriptar");
         private Button decriptar=new Button("decriptar");
         public cuadro(){
              layoutApplet();
              encriptar.addActionListener(new ButtonHandler());
              decriptar.addActionListener(new ButtonHandler());
              resize(400,400);
              private void layoutApplet(){
              Panel keyPanel = new Panel();
              keyPanel.add(encriptar);
              keyPanel.add(decriptar);
              Panel textPanel = new Panel();
              Panel texto1 = new Panel();
              Panel texto2 = new Panel();
              texto1.add(new Label("               plain text"));
              texto1.add(area1);
              texto2.add(new Label("               cipher text"));
              texto2.add(area2);
              textPanel.setLayout(new GridLayout(2,1));
              textPanel.add(texto1);
              textPanel.add(texto2);
              setLayout(new BorderLayout());
              add("North", keyPanel);
              add("Center", textPanel);
              public static String encriptar(String text1){
              //generar una clave
              SecretKey clave=null;
              String text2="";
              try{
              FileOutputStream fs =new FileOutputStream ("c:/javasoft/ti.txt");
              DataOutputStream es= new DataOutputStream(fs);
                   for(int i=0;i<text1.length();++i){
                        int j=text1.charAt(i);
                        es.write(j);
                   es.close();
              }catch(IOException e){
                   System.out.println("no funciona escritura");
              }catch(SecurityException e){
                   System.out.println("el fichero existe pero es un directorio");
              try{
                   //existe archivo DESkey.ser?
                   ObjectInputStream claveFich =new ObjectInputStream(new FileInputStream ("DESKey.ser"));
                   clave = (SecretKey) claveFich.readObject();
                   claveFich.close();
              }catch(FileNotFoundException e){
                   System.out.println("creando DESkey.ser");
                   //si no, generar generar y guardar clave nueva
              try{
                   KeyGenerator claveGen = KeyGenerator.getInstance("DES");
                   clave= claveGen.generateKey();
                   ObjectOutputStream claveFich = new ObjectOutputStream(new FileOutputStream("DESKey.ser"));
                   claveFich.writeObject(clave);
                   claveFich.close();
              }catch(NoSuchAlgorithmException ex){
                   System.out.println("DES key Generator no encontrado.");
                   System.exit(0);
              }catch(IOException ex){
                   System.out.println("error al salvar la clave");
                   System.exit(0);
         }catch(Exception e){
              System.out.println("error leyendo clave");
              System.exit(0);
         //crear una cifra
         Cipher cifra = null;
         try{
              cifra= Cipher.getInstance("DES/ECB/PKCS5Padding");
              cifra.init(Cipher.ENCRYPT_MODE,clave);
         }catch(InvalidKeyException e){
              System.out.println("clave no valida");
              System.exit(0);
         }catch(Exception e){
              System.out.println("error creando cifra");
              System.exit(0);
         //leer y encriptar el archivo
         try{
              DataInputStream in = new DataInputStream(new FileInputStream("c:/javasoft/ti.txt"));
              CipherOutputStream out = new CipherOutputStream(new DataOutputStream(new FileOutputStream("c:/javasoft/t.txt")),cifra);
              int i;
              do{
                   i=in.read();
                   if(i!=-1) out.write(i);
              }while (i!=-1);
              in.close();
              out.close();
         }catch(IOException e){
              System.out.println("error en lectura y encriptacion");
              System.exit(0);
         try{
              FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
              DataInputStream le =new DataInputStream(fe);
                   int i;
                   char c;
                   do{
                        i=le.read();
                        c= (char)i;
                        if(i!=-1){
                        text2 += text2.valueOf(c);
                   }while(i!=-1);
                        le.close();
              /*}catch(FileNotFoundException e){
                   System.out.println("fichero no encontrado");
                   System.exit(0);
              }catch(ClassNotFoundException e){
                   System.out.println("clase no encontrada");
                   System.exit(0);
              */}catch(IOException e){
                   System.out.println("error e/s");
                   System.exit(0);
              return text2;
         class ButtonHandler implements ActionListener{
         public void actionPerformed(ActionEvent e){
              try{
              if (e.getActionCommand().equals(encriptar.getLabel()))
                   //     area2.setText(t1)
                   area2.setText(encriptar(area1.getText()));
                   //area2.setText("escribe algo");
                   else if (e.getActionCommand().equals(decriptar.getLabel()))
                        System.out.println("esto es decriptar");
                        //area2.setText("hola");
         }catch(Exception ex){
              System.out.println("error en motor de encriptacion");
                   //else System.out.println("no coge el boton encriptado/decript");

    If you don't require your code to run as an applet, you will probably get more mileage from refactoring it to run as an application.
    As sudha_mp implied, an unsigned applet will fail on the line
    FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
    due to security restrictions. (Which, incidentally, are there for a very good reason)

  • Reading message from MQ- works in WSAD (IDE) but does not work outside WSAD

    Read from MQ:
    Same code works within WASD but does not work outside WSAD.

    PDL - thanks for the suggestions - here are the results:
    A button on the form that executes "this.print();" works fine.
    Changing "this" to "event.target" results in the same error.
    document.getElementById("PDFObj").Print(); works fine.
    However, the reason that I'm using ".postMessage([message])" instead of ".Print()" is because I actually have a toolbar that has save, print, zoom in, zoom out, page up, page down, etc.... I simplified the switch statement in the post above to only include print, but in reality has a case for each of the functions above. The postMessage call is triggering the error, since the catch statement is printing out the error message above. Any idea why this would work with Professional but not Reader.

  • Maxl iferror goto does not work

    Hi,
    I have a vbscript which updates substitution variables in essbase.
    But if there is an error, for example, if the variable name is different in essbase than what is defined in the script, the script continues to run.
    the only time is actually catches an error is when it encounters the error in the last statement that is executed. i tried to put iferror goto, but it does not work either.
    Please help.
    Below is a portion of my script.
    Thanks.
    objOutputStream.writeline("login " & Username & " identified by " & password & " on " & Server &";")
    objOutputStream.writeline("spool on to "& logfile &";")
    objOutputStream.WriteLine("alter database " & APPname & "." & DBname & " set variable abcd " & strabcd &";")
    objOutputStream.WriteLine ("iferror goto exit;")
    objOutputStream.WriteLine("alter database " & APPname & "." & DBname & " set variable xyz" & strxyz &";")
    objOutputStream.WriteLine ("iferror goto exit;")
    objOutputStream.WriteLine("alter database " & APPname & "." & DBname & " set variable mnop" & strmnop &";")
    objOutputStream.WriteLine ("iferror goto exit;")
    objOutputStream.writeline("spool off;")
    objOutputStream.writeline("logout;")
    objOutputStream.WriteLine (":Exit")
    objOutputStream.writeline("exit;")
    objOutputStream.close

    Hi,
    we work with the exit label as follows:
    alter database ...
    iferror getmeout;
    alter database ...
    iferror getmeout...
    define label "getmeout";
    spool off;
    logout;
    EXIT;
    the spool off and logout command should be part of the defined lable (in your case, too), otherwise you wouldnt logout your session if an error occurs.
    Kind regards
    André

  • URLLoader does not work

    I am following the URLLoader example
    I'm compiling with -mxmlc -use-network=false Main.as
    Both main.swf and the file I'm trying to download (test.txt) reside in the same directory
    I get the open even then the HTTPStatus event (status == 0) then nothing happens
    I verified that the file is found: I changed the file name to xtest.txt and promptly got an ioError event.
    I tried to compile without -use-network=false and the load failed with an error #2148 as expected
    I changed the url to http://test.txt, compiled with -use-naetwork=flase and the load failed with error #2028 as expected
    I added a timer to make sure the flash is running, and it does
    In short I think it simply is broked!
    Compiled using flex sdk "Version 3.3.0 build 4852"
    The player's about sends me to http://www.adobe.com/software/flash/about/ ,  which reports "You have version 10,0,32,18 installed"
    The URLLoader is suported since player v9
    Browser is firefox, and I am running it on Linux
    Here's the code:
    package
        import flash.display.Sprite;
        import flash.text.TextField;
        import flash.utils.setInterval;
        import flash.net.URLRequest;
        import flash.net.URLRequestMethod;
        import flash.net.URLLoader;
        import flash.net.URLLoaderDataFormat;
        import flash.events.IEventDispatcher;
        import flash.events.Event;
        import flash.events.IOErrorEvent;
        import flash.events.HTTPStatusEvent;
        import flash.events.SecurityErrorEvent;
        import flash.utils.ByteArray;
        public class Main extends Sprite
            private var downloadUrl:String;
            private var downloadRequest:URLRequest;
            private var downloadLoader:URLLoader;
            private var downloadBytes:ByteArray;
            private var downloadStarted:Boolean = false;
            private var downloadDone:Boolean = false;
            private var statusLine:TextField;
            private var statusText:String = "";
            private var timerStep:Number = 100;
            private var elapsedTime:Number = 0;
            public function Main()
                statusLine = new TextField();
                statusLine.width = 400;
                statusLine.height = 400;
                statusLine.multiline = true;
                statusLine.wordWrap = true;
                statusLine.text = "Starting";
                addChild(statusLine);
                // NOTE: Adobe livedocs for setInterval says:
                // "Instead of using the setInterval() method, consider creating
                //  a Timer object, with the specified interval, ..."
                // except it does not work! stick with setInterval() for now
                elapsedTime = 0;
                setInterval(showStatus,timerStep);
                download("http://test.txt");
            private function showStatus():void
                var txt:String = "";
                elapsedTime += timerStep;
                if (downloadDone)
                    txt += "Download done ";
                else
                if (downloadStarted)
                    txt += "Downloading ";
                txt += statusText + "\n";
                txt += " > " + Math.round(elapsedTime/100)/10 + " < ";
                statusLine.text = txt;
            public function download(url:String):void
                downloadStarted = false;
                downloadDone = false;
                downloadUrl = url;
                downloadRequest = new URLRequest(downloadUrl);
                downloadLoader = new URLLoader();
                configureListeners(downloadLoader);
                try {
                    downloadLoader.dataFormat = URLLoaderDataFormat.TEXT;
                    downloadLoader.load(downloadRequest);
                } catch (error:Error) {
                    statusText = "download failed: " + error.message;
            private function configureListeners(dispatcher:IEventDispatcher):void
                dispatcher.addEventListener(Event.COMPLETE,downloadCompletedHandler);
                dispatcher.addEventListener(Event.OPEN,downloadStartedHandler);
                dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR,downloadSecurityErrorHandle r);
                dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS,downloadHttpStatusHandler);
                dispatcher.addEventListener(IOErrorEvent.IO_ERROR,downloadIOErrorHandler);
            private function downloadStartedHandler(event:Event):void
                downloadStarted = true;
                statusText += "Started " + event;
            private function downloadCompletedHandler():void
                downloadDone = true;
                statusText += "Completed ";
            private function downloadSecurityErrorHandler(event:Event):void
                statusText += "SecurityError (" + event + ")";
            private function downloadHttpStatusHandler(event:Event):void
                statusText += "HttpStatus(" + event + ")";
            private function downloadIOErrorHandler(event:Event):void
                statusText += "IOError (" + event + ")";

    silly mistake... notice how all callback functions take an argument "event"Event" ... all that is _except_ the downloadCompleted handler
    i changed
    private function downloadCompletedHandler():void
    to
    private function downloadCompletedHandler(event:Event):void
    and this code started to work
    unfortunatly, the compiler does not catch this sort of error.

  • DoClick does not work!!!

    For my simple browser I have created a button that allows you to enlarge the size of the text. Now when the page is loaded and you click this button the text size increases as desired.
    However I want the text to automatically change to large when the webpage is loaded. So after the setpage method I used largeTxt.doClick() this does not seem to work.
    Can you please help me solve this problem, my code is below.
    Thanks.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.border.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import java.util.*;
    public class simpleBrowser extends JFrame implements ActionListener, HyperlinkListener {
         public static final String HOME_DEFAULT = "http://www.cs.nott.ac.uk/~nza";
         protected String currentURL = HOME_DEFAULT;
    private BorderLayout border;
    private Container content;
    private JButton buttonGo, largeText ;
    private JTextField textURL;
    private JLabel labelEnterURL;
    private JEditorPane htmlMain;
    private JPanel panel;
    private JScrollPane scrollPane;
    private URL url;
    private String urlString;
    final JLabel statusBar = new JLabel(" ");
    String display;
         public simpleBrowser (String startPage) throws MalformedURLException, IOException {
         super("Simple Browser");
         setSize(600,500);
         addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
         we.getWindow().setVisible(false);
         System.exit(0);
         border = new BorderLayout();
         content = this.getContentPane();
         content.setLayout(border);
         buttonGo = new JButton("GO!");
         buttonGo.addActionListener(this);
         largeText = new JButton("Large Text");
         largeText.addActionListener(this);
         textURL = new JTextField(startPage, 40);
         textURL.setToolTipText("Key in the URL required here");
         labelEnterURL = new JLabel("Enter the URL:");
         url = new URL(startPage);
         htmlMain = new JEditorPane(url);
         htmlMain.setEditable(false);
         htmlMain.addHyperlinkListener(this);
         scrollPane = new JScrollPane(htmlMain);
         panel = new JPanel();
         panel.setLayout(new FlowLayout());
         panel.add(labelEnterURL);
         panel.add(textURL);
         panel.add(buttonGo);
         panel.add(largeText);
         content.add(panel, BorderLayout.NORTH);
         content.add(scrollPane, BorderLayout.CENTER);
         content.add(statusBar, BorderLayout.SOUTH);
         this.pack();
         this.setVisible(true);
    } // End constructor
    public void actionPerformed(ActionEvent e) {
         if (e.getSource().equals(buttonGo)){                    
         DisplayPage(textURL.getText());
         } // End if
         if (e.getSource().equals(largeText)){
              Thread runner = new Thread() {
              public void run() {
         HTMLDocument doc = ((HTMLDocument) htmlMain.getDocument());
              doc.setCharacterAttributes(0, htmlMain.getDocument().getLength(), doc.getStyleSheet()
                   .getDeclaration("font-size:24"), false);
    runner.start();
         } // End if
    } // End actionPerformed
    public void hyperlinkUpdate(HyperlinkEvent e) {
         HyperlinkEvent.EventType eventType = e.getEventType();
         if (eventType == HyperlinkEvent.EventType.ACTIVATED) {
         try {
              htmlMain.setPage(e.getURL());
         } catch (Exception myException) {
              htmlMain.setText("Link error");
         } // End try-catch
         } // End if
    } // End hyperlinkUpdate
    public static void main(String[] args) throws MalformedURLException, IOException {
         simpleBrowser myBrowser = new simpleBrowser(HOME_DEFAULT);
    } // End main
         public void DisplayPage(String strURL) {
         currentURL = strURL;
         textURL.setText(strURL);
         try {
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              htmlMain.setPage(strURL);
              //largeText.doClick();           
         catch (Exception exc) {
                   htmlMain.setText("");
                   statusBar.setText("Could not open starting page. Using a blank.");
         finally {
         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         } //end try
         largeText.doClick();
    } // End class

    I tried your suggesstions to change the methods as shown below but it still does not work. :(
    if (e.getSource().equals(largeText)){
              Thread runner = new Thread() {
              public synchronized void run() {
         HTMLDocument doc = ((HTMLDocument) htmlMain.getDocument());
              doc.setCharacterAttributes(0, htmlMain.getDocument().getLength(), doc.getStyleSheet()
                   .getDeclaration("font-size:24"), false);
    runner.start();
    SwingUtilities.invokeLater(runner);
         } // End if
    public void DisplayPage(String strURL) {
         currentURL = strURL;
         textURL.setText(strURL);
         //m_btnReload.setToolTipText(strURL);
         try {
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              htmlMain.setPage(strURL);
              SwingUtilities.invokeLater(new Runnable() {            
              public void run() {           
              largeText.doClick();
         catch (Exception exc) {
                   htmlMain.setText("");
                   statusBar.setText("Could not open starting page. Using a blank.");
         finally {
         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         } //end try
         //largeText.doClick();
    }

Maybe you are looking for