Problem with JNI and Tomcat (and threads???)

Howdy,
Here is the issue - I would like some help on HOW to debug and fix this problem:
2 test use cases -
1)
a)User goes to Login.jsp, enters user and password
b) User submits to LoginServlet
c) login calls JNI code that connects to a powerbuilder(Yes I know this is ugly) PBNI code module (this is a .dll) that authenticates the user with the database
d) the servlet then redirects to another .jsp page
e) user then submits to LogoutServlet - also a JNI call to a powerbuilder PBNI code module
f) REPEAT STEPS a-e over a few times (inconsistent) and then the call to the JNI code hangs
2)
a) users does NOT goto Login.jsp, but rather calls LoginServlet and passes the userid and password as GET parms
b) user does NOT get redirected to a page (redirect code commented out)
c) user calls LogoutServlet
d) repeat steps a-c at will and no failure, no hanging
The only difference is that in case 1 (with JSP), there is a redirect and it afffected the JNI call by haniging inside JNI code.
In case 2 (without JSP) there is still a JNI call, but it does not hang. In addition, when it hangs and I stop Tomcat, the logs show cleanup entries that say:
Oct 19, 2004 9:17:09 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Oct 19, 2004 9:17:10 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Oct 19, 2004 9:17:11 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Is this a threading issue in Tomcat???
On would assume that the JNI code is not cleaning up after itself, but I don't believe this is the case,
and even if it was, why would I get the tomcat log cleanup entries above???
What do those cleanup entries imply about the state of Tomcat????

hi ,
I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
==============================
error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
message: Waiting for 2 instance(s) to be deallocated
==============================
cause: the number of connection to database exceeded.another word,too many connections.
==============================
solution: close the connection when it becomes useless for your program. :)
==============================
ps. Sorry for my weak English . hehe ....

Similar Messages

  • Problem with JNI and Tomcat in windows

    Hello guys...
    I have the following problem.
    I used Tomcat 4 and I have following ApiEncriptacion class, in package com.servipag.sts;
    package com.servipag.sts;
    class ApiEncriptacion
         public native String encripta(String texto, String ubicacionLlavePublica, String semilla);
         static
              System.loadLibrary("apisdark");
         public native String desencripta(String texto, String ubicacionLlavePrivada);
         static
              System.loadLibrary("apisdark");
    the LD_LIBRARY_PATH is set in following dir c:\tomcat\bice
    the dll this in the following path = c:\tomcat\bice\apisdark.dll
    I run Tomcat at the following way..
    C:\jdk1.4\bin\java.exe -jar -Djava.library.path="c:\tomcat\bice" -Duser.dir="C:\Tomcat" "C:\Tomcat\bin\bootstrap.jar" start
    but, still appear the error:
    java.lang.UnsatisfiedLinkError: encripta
         at com.servipag.sts.ApiEncriptacion.encripta(Native Method)
         at com.servipag.sts.ServiciosServiPagImpl.rescatarFirma(ServiciosServiPagImpl.java:2143)
         at com.servipag.sts.ServiciosServiPagImpl.pagarCuenta(ServiciosServiPagImpl.java:310)
         at org.apache.jsp.SBCO_0005flogin_0005fbice_0005f4$jsp._jspService(SBCO_0005flogin_0005fbice_0005f4$jsp.java:265)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
         at java.lang.Thread.run(Thread.java:536)
    please help me
    Luis Navarro.
    Chile

    ApiEncripatcion.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ApiEncriptacion */
    #ifndef IncludedApiEncriptacion
    #define IncludedApiEncriptacion
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: ApiEncriptacion
    * Method: encripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_encripta
    (JNIEnv *, jobject, jstring, jstring, jstring);
    * Class: ApiEncriptacion
    * Method: desencripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_desencripta
    (JNIEnv *, jobject, jstring, jstring);
    #ifdef __cplusplus
    #endif
    #endif
    ApiEncriptacion.c
    #include "jni.h"
    #include <stdio.h>
    #include "files.h"
    #include "hex.h"
    #include "rsa.h"
    #include "randpool.h"
    USING_NAMESPACE(CryptoPP)
    USING_NAMESPACE(std)
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed);
    char RSAEncryptString(const char pubFilename, const char seed, const char message);
    char RSADecryptString(const char privFilename, const char *ciphertext);
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_encripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePublica, jstring semilla)
         try
              char *ciphertext = RSAEncryptString(ubicacionLlavePublica, semilla, texto);
              delete [] ciphertext;
              return(ciphertext);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_desencripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePrivada)
         try
              char *decrypted = RSADecryptString(ubicacionLlavePrivada, texto);
              return(decrypted);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    int main()
         return(0);     
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         priv.DEREncode(privFile);
         privFile.MessageEnd();
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
         pub.DEREncode(pubFile);
         pubFile.MessageEnd();
    char RSAEncryptString(const char pubFilename, const char seed, const char message)
         FileSource pubFile(pubFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Encryptor pub(pubFile);
         if (strlen(message) > pub.MaxPlainTextLength())
              cerr << "message too long for this key\n";
              abort();
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         char outstr = new char[2pub.CipherTextLength()+1];
         pub.Encrypt(randPool, (byte *)message, strlen(message), (byte *)outstr);
         HexEncoder hexEncoder;
         hexEncoder.Put((byte *)outstr, pub.CipherTextLength());
         hexEncoder.MessageEnd();
         hexEncoder.Get((byte *)outstr, 2*pub.CipherTextLength());
         outstr[2*pub.CipherTextLength()] = 0;
         return outstr;
    char RSADecryptString(const char privFilename, const char *ciphertext)
         FileSource privFile(privFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Decryptor priv(privFile);
         HexDecoder hexDecoder;
         hexDecoder.Put((byte *)ciphertext, strlen(ciphertext));
         hexDecoder.MessageEnd();
         SecByteBlock buf(priv.CipherTextLength());
         hexDecoder.Get(buf, priv.CipherTextLength());
         char *outstr = new char[priv.MaxPlainTextLength()+1];
         unsigned messageLength = priv.Decrypt(buf, (byte *)outstr);
         outstr[messageLength] = 0;
         return outstr;

  • Problem with JNI and Parallel Port dll

    Hi. I'm doing some testes with JNI. Firs i followed the netbeans tutorial for doing a C programa that prints somthing for java.. like.. "Hello java from C".
    So i tried to load a dll from my dll. Like, I have this dll to use the parallel port on windows Xp. So i created a dll to access it an comunicates eoth java.
    I did everything just fine.
    When I start my Java app, the first thing it does is to load this parallel port dll and configure the functions of it.
    After that .. I get this error
    EXCEPTION_FLT_STACK_CHECK (0xc0000092) at pc=0x0093d269, pid=2284, tid=3000
    Can someone explain why ?
    (Sorry if i wasn't clear enough, english is not my native language, so ask if you don't understand something.. )

    hi ,
    I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
    Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
    ==============================
    error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
    2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
    message: Waiting for 2 instance(s) to be deallocated
    ==============================
    cause: the number of connection to database exceeded.another word,too many connections.
    ==============================
    solution: close the connection when it becomes useless for your program. :)
    ==============================
    ps. Sorry for my weak English . hehe ....

  • Problem with JDialogs and Threads

    Hi. I'm new to this forum and I hope I'm not asking a repeat question. I didn't find what I needed after a quick search of existing topics.
    I have this problem with creating a new JDialog from within a thread. I have a class which extends JDialog and within it I'm running a thread which calls up another JDialog. My problem is that the JDialog created by the Thread does not seem to function. Everything is unclickable except for the buttons in the titlebar. Is there something that I'm missing out on?

    yeah, bad idea, don't do that.

  • Problem with socket and Threads

    Hi,
    I have coded a package that sends an sms via a gateway.
    Here is what is happening:
    * I create a singleton of my SMSModule.
    * I create an sms object.
    * I put the object in a Queue.
    * I start a new Thread in my sms module that reads sms from queue.
    * I connect to sms gateway.
    * I send the sms.
    * I disconnect from socket! This is where things go wrong and I get the following error (see below).
    I have a zip file with the code so if you have time to take a look at it I would appreciate it.
    Anyway all hints are appreciated!
    //Mikael
    GOT: !LogoffConf:
    mSIP Kommando var: !LogoffConf
    CoolFlix log: MSIPProtocolHandler;setLoggedin(false)
    We got LogOffConf
    Waiting ......for thread to die
    java.net.SocketException: Socket operation on nonsocket: JVM_recv in
    socket input stream read
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:116)
    at
    sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)

    Off the top of my head, probably the garbage collector cleared your SMSModule coz all classes loaded through other classloaders will be unloaded when that classloader is unloaded.
    mail in the code if you want me to look at it with greater detail.

  • Problem with StatelessConnectionPool and Threads on Windows XP

    I am trying to use a StatelessConnectionPool in a multithreaded app under Windows using 10g. The problem is that when my application is exiting and I go to terminate the StatelessConnectionPool, I get an access violation inside Environment::terminateStatlessConnectionPool.
    A short program that demonstrates the problem is at the end of this post. One thing I have noticed is that by calling terminateConnection inside the thread instead of releaseConnection the problem goes away. However, performance really degrades. Thanks in advance.
    #include <windows.h>
    #include <occi.h>
    #include "RegisterDataMappings.h"
    #include "Consumers.h"
    #include "Thread.h"
    using namespace oracle::occi;
    Environment* env = NULL;
    StatelessConnectionPool* connPool = NULL;
    //Derived from opur Thread class
    class TestThread : public Thread
    public:
         TestThread(void){}
    protected:
         //get an object 10 times, sleeping every 500 msecs in between
         virtual DWORD run(void)
              printf("Thread 0x%08x Enter...\n", GetCurrentThreadId());
              Sleep(500);
              int i = 0;
              while(i < 10)
                   try
                        Connection* conn = connPool->getConnection();
                        Statement* stmt = conn->createStatement("select Ref(c) from consumers c where pid = 7038878582");
                        ResultSet* rs = stmt->executeQuery();
                        if(rs->next())
                             Ref<Consumers> consumer = rs->getRef(1);
                             printf("Thread 0x%08x #%d - %.0f\n", GetCurrentThreadId(), i+1, (double)consumer->getconsumerid());
                        stmt->closeResultSet(rs);
                        conn->terminateStatement(stmt);
                        connPool->releaseConnection(conn);
                        //connPool->terminateConnection(conn);
                        Sleep(500);
                        ++i;
                   catch(SQLException& sql)
                        printf("Oracle exception: %s\n", sql.getMessage().c_str());
              printf("Thread 0x%08x Leave...\n", GetCurrentThreadId());
              return 0;
    //Helper function to create a connection
    void createConnection(void)
         env = Environment::createEnvironment((Environment::Mode)(Environment::OBJECT|Environment::THREADED_MUTEXED));
         RegisterDataMappings(env);
         connPool = env->createStatelessConnectionPool("user", "pass", "orcldev", 10, 10, 0, StatelessConnectionPool::HOMOGENEOUS);
    //Helper function to terminate a connection
    void terminateConnection(void)
         env->terminateStatelessConnectionPool(connPool);
         Environment::terminateEnvironment(env);
    int main(int argc, char* argv[])
         try
              //Connect to the database
              createConnection();
              //Create 10 threads and wait for them to complete
              const int numThreads = 10;
              HANDLE handles[numThreads];
              for(int i = 0; i < numThreads; i++)
                   TestThread* thread = new TestThread;
                   thread->start();
                   handles[i] = thread->getThreadHandle();
              WaitForMultipleObjects(numThreads, handles, TRUE, INFINITE);
              //Clean up
              terminateConnection();
         catch(SQLException& sql)
              printf("SQLException caught: %s\n", sql.getMessage().c_str());
         return 0;

    When I search MetaLink for bug 4183098, it says there's nobug 4183098. Any information on this?

  • Problem With Booleans and Threads

    Since using the .stop() and .resume() properties of a thread are dangerous, I resorted to using Booleans....
    I can get it to stop just fine by setting "keepGoing" to false. That works...
    But when I set the boolean to true... nothing happens. I think the while loop is broken when I set it to false and can't be fixed when the boolean is set back to true.
    There's some deep process I'm not getting with while loops and/or threads.
    Thanks for any help. The first segment of code is what's wrong. Post if it would help to see the rest.
    class startUpdatingThread extends Thread {
          public void run() {
              System.out.println("THREAD STARTING TO RUN!");
            while (keepGoing == true) {
                if (keepGoing == true) {
                Long nextGoAbout = imgTime + 5000;//five seconds more
                if ( ((nextGoAbout - connection.getDate()) < 10000) ) {
                    getnewPicture();
                    imgCanvas.repaint();
    }

    Still a missing }, and you'll still fall out the end of the thread. Something like this:
    class StartUpdatingThread extends Thread
         private volatile boolean     keepGoing = true;
         public void run()
              System.out.println("THREAD STARTING TO RUN!");
              for (;;)
                   synchronized (this)
                        while (!keepGoing)
                             try
                                  this.wait();
                             catch (InterruptedException exc)
                   Long nextGoAbout = imgTime + 5000;//five seconds more
                   if ( ( (nextGoAbout - connection.getDate()) < 10000) )
                        getnewPicture();
                        imgCanvas.repaint();
         public void pause()
              this.keepGoing = false;
         public synchronized void unpause()
              this.keepGoing = true;
              notifyAll();
    }//<--end of StartUpdatingThread()

  • Problem with Queue and threads

    Hello,
    the following is the code :
    public class Tester extends Thread
    private String fname;
    public String getFname()
       return fname;
    public void setFname(String fname)
       this.fname = fname;
    public Tester(String fname){
       super();
      this.fname = fname;
    }Heres another class
    class N {
        Thread r = null;
        public void checkQ()
          Queue q = new ConcurrentLinkedQueue<N>();
          for(int i = 0; i < 13; i++)
             System.out.println("FOR I is "+i);
             r = new Tester("Name" + i);
             q.offer(r);
             processq(q);
        public void processq(Queue queueOfM)
           if(queueOfM.size() > 10)
              System.out.println("size of queueofM is "+queueOfM.size());
            for(int j=0; j < queueOfM.size();j++)
                 System.out.println("J is "+j);
                 this.r = (Thread)queueOfM.poll();
                 this.r.start();
       }When run, the code prints :
    FOR I is 0
    FOR I is 1
    FOR I is 2
    FOR I is 3
    FOR I is 4
    FOR I is 5
    FOR I is 6
    FOR I is 7
    FOR I is 8
    FOR I is 9
    FOR I is 10
    size of queueofm is 11
    J is 0
    J is 1
    J is 2
    J is 3
    J is 4
    J is 5
    FOR I is 11
    FOR I is 12I was expecting the code to print the J till 11.
    Could you please help me find where I went wrong ?

    I think I may have been asking a wrong question.
    class N {
        Thread r = null;
        public void checkQ()
          Queue q = new ConcurrentLinkedQueue<N>();
          for(int i = 0; i < 13; i++)
             System.out.println("FOR I is "+i);
             r = new Tester("Name" + i);
             q.offer(r);
             processq(q);
        public void processq(Queue queueOfM)
           if(queueOfM.size() > 10)
              System.out.println("size of queueofM is "+queueOfM.size());
            for(int j=0; j < queueOfM.size();j++)
                 System.out.println("J is "+j);
                 this.r = (Thread)queueOfM.poll();
                 this.r.start();
              }The if in the processq method will come true when I is 11. so, once in the if, the for loop is executed. The j is checked till it is < 11 and then the value of j is being printed. So, as I was expecting J should print till atleast 10. However it is printing till 5 and quitting the loop, I dont know how or why, for which I was thinking if someone could show me why.

  • Problems with SwingWorker and classes in my new job, ;), can you help me?

    Hi all, ;)
    First of all, sorry about my poor English.
    I have a problem with Swing and Threads, I hope you help me (because I'm in the firsts two weeks in my new job)
    I have two classes:
    Form1: Its a JPanel class with JProgressBar and JLabel inside.
    FormularioApplet: (the main) Its a JPanel class with a form1 inside.
    I have to download a file from a server and show the progress of the download in the JProgressBar. To make it I do this:
    In Form1 I make a Thread that update the progress bar and gets the fole from the server.
    In FormularioApplet (the main) I call to the method getDownloadedFile from Form1 to get the File.
    THE PROBLEM:
    The execution of FormularioApplet finishes before the Thread of Form1 (with download the file) download the file. Then, when I call in FormularioApplet the variable with the file an Exception: Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException is generated.
    First main begins his execution, then call to Form1 (a thread) then continues his execution and when the execution is finished ends the execution os Form1 and his thread.
    How can I do for main class call the function and the Thread download his file after main class assign the file of return method?
    How can I pass information froma class include an a main class. Form1 can't send to main (because main class made a Form1 f1 = new Form1()) any information from his end of the execution. I think if Form1 can say to main class that he finishes is job, then main class can gets the file.
    I put in bold the important lines.
    Note: My level of JAVA, you can see, is not elevated.
    THANKS A LOT
    Form1 class:
    package es.cambrabcn.signer.gui;
    import java.awt.HeadlessException;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import javax.swing.SwingUtilities;
    public class Form1 extends javax.swing.JPanel {
        //Variables relacionadas con la clase original DownloadProgressBar
        private InputStream file;
        private int totalCicles;
        private int totalFiles;
        private int currentProgress;
        private SwingWorker worker;
        private ByteArrayOutputStream byteArray;
        private boolean done;
        /** Creates new form prueba */
        public Form1() {
            initComponents();
            this.byteArray = new ByteArrayOutputStream();
            progressBar.setStringPainted(true);
            //this.totalFiles = totalFiles;
            currentProgress = 0;
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" C�digo Generado ">                         
        private void initComponents() {
            label1 = new javax.swing.JLabel();
            progressBar = new javax.swing.JProgressBar();
            statusLabel = new javax.swing.JLabel();
            setBackground(new java.awt.Color(255, 255, 255));
            setMaximumSize(new java.awt.Dimension(300, 150));
            setMinimumSize(new java.awt.Dimension(300, 150));
            setPreferredSize(new java.awt.Dimension(300, 150));
            label1.setFont(new java.awt.Font("Arial", 1, 18));
            label1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            label1.setText("Barra de progreso");
            statusLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            statusLabel.setText("Cargando");
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, progressBar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, label1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(statusLabel)
                    .addContainerGap(73, Short.MAX_VALUE))
        }// </editor-fold>                       
        // Declaraci�n de variables - no modificar                    
        private javax.swing.JLabel label1;
        private javax.swing.JProgressBar progressBar;
        private javax.swing.JLabel statusLabel;
        // Fin de declaraci�n de variables                  
        public byte[] getDownloadedFile(String documentToSign){
             //Variables locales
             byte puente[] = null;
             try{
                //Leemos el documento a firmar
                StringTokenizer st = new StringTokenizer(documentToSign, ";");
                Vector<URL> fileURL = new Vector<URL>();
                HttpSender sender = new HttpSender(null);
                //Introducimos la lista de URLs de archivos a bajar en el objeto Vector
                for(; st.hasMoreTokens(); fileURL.add(new URL(st.nextToken())));
                //Para cada URL descargaremos un archivo
                for(int i = 0; i < fileURL.size(); i++) {
                    file = sender.getMethod((URL)fileURL.get(i));
                    if(file == null) {
                        Thread.sleep(1000L);
                        throw new RuntimeException("Error descarregant el document a signar.");
                    System.out.println("Form1 Dentro de getDownloadFile, Antes de startDownload()");
                    //Fijamos el valor del n�mero de ciclos que se har�n seg�n el tama�o del fichero
                    this.totalCicles = sender.returnCurrentContentLength() / 1024;
                    this.progressBar.setMaximum(totalCicles);
                    //Modificamos el texto del JLabel seg�n el n�mero de fichero que estemos descargando
                    this.statusLabel.setText((new StringBuilder("Descarregant document ")).append(i + 1).append(" de ").append(fileURL.size()).toString());
                    statusLabel.setAlignmentX(0.5F);
                    *//Iniciamos la descarga del fichero, este m�todo llama internamente a un Thread*
                    *this.startDownload();*
                    *System.out.println("Form1 Dentro de getDownloadFile, Despu�s de startDownload()");*
                    *//if (pane.showProgressDialog() == -1) {*
                    *while (!this.isDone()){*
                        *System.out.println("No est� acabada la descarga");*
                        *if (this.isDone()){*
                            *System.out.println("Thread ACABADO --> Enviamos a puente el archivo");*
                            *puente = this.byteArray.toByteArray();*
                            *System.out.println("Form1 getDownloadFile() tama�o puente: " + puente.length);*
                        *else{*
                            *Thread.sleep(5000L);*
    *//                        throw new RuntimeException("Proc�s de desc�rrega del document a signar cancel�lat.");*
            catch (HeadlessException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("UI: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (MalformedURLException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (HttpSenderException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (InterruptedException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            //System.out.println("Form1 getDownloadFile() tama�o puente: " + puente.length);
            return puente;
        public void updateStatus(final int i){
            Runnable doSetProgressBarValue = new Runnable() {
                public void run() {
                    progressBar.setValue(i);
            SwingUtilities.invokeLater(doSetProgressBarValue);
        public void startDownload() {
            System.out.println("Form1 Inicio startDownload()");
            System.out.println("Form1 Dentro de startDownload, antes de definir la subclase SwingWorker");
            System.out.println(done);
            worker = new SwingWorker() {
                public Object construct() {
                    System.out.println("Form1 Dentro de startDownload, dentro de construct(), Antes de entrar en doWork()");
                    return doWork();
                public void finished() {
                    System.out.println("Form1 Dentro de startDownload, dentro de finished(), Antes de asignar done = true");
                    System.out.println(done);
                    done = true;
                    System.out.println("Form1 Dentro de startDownload, dentro de finished(), Despu�s de asignar done = true");
                    System.out.println(done);
                    statusLabel.setText("Completado, tama�o del archivo: " + (byteArray.size() / 1024) + "KB");
            System.out.println("Form1 Dentro de startDownload, antes de worker.start()");
            worker.start();
            System.out.println("Form1 Dentro de startDownload, antes de salir de startDownload");
            System.out.println(done);
            System.out.println("Form1 Dentro de startDownload, despu�s de worker.start()");
         * M�todo doWork()
         * Este m�todo descarga por partes el archivo que es necesario descargar, adem�s de actualizar
         * la barra de carga del proceso de carga de la GUI.
        public Object doWork() {
            System.out.println("Form1 doWork() this.byteArray.size(): " + this.byteArray.size());
            try {
                byte buffer[] = new byte[1024];
                for(int c = 0; (c = this.file.read(buffer)) > 0;) {
                    this.currentProgress++;
                    updateStatus(this.currentProgress);
                    this.byteArray.write(buffer, 0, c);
                this.byteArray.flush();
                this.file.close();
                this.currentProgress = totalCicles;
                updateStatus(this.currentProgress);
            } catch(IOException e) {
                e.printStackTrace();
            System.out.println("Form1 doWork() FINAL this.byteArray.size(): " + this.byteArray.size());
            //done = true;
            System.out.println("AHORA DONE = TRUE");
            return "Done";
        public boolean isDone() {
            return this.done;
    FormularioApplet class (main)
    package es.cambrabcn.signer.gui;
    import java.awt.Color;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.net.URL;
    import java.security.Security;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import javax.swing.SwingUtilities;
    import netscape.javascript.JSObject;
    import org.bouncycastle.jce.provider.BouncyCastleProvider;
    import sun.security.provider.Sun;
    import be.cardon.cryptoapi.provider.CryptoAPIProvider;
    public class FormularioApplet extends java.applet.Applet {
        //Variables globales
        int paso = 0;
        private static final String JS_ONLOAD = "onLoad";
        private static final String JS_ONLOADERROR = "onLoadError";
        private static final int SIGNATURE_PDF = 1;
        private static final int SIGNATURE_XML = 2;
        //private String signButtonValue;
        private int signatureType;
        private String documentToSign;
        private String pdfSignatureField;
        private Vector<String> outputFilename;
        private Color appletBackground = new Color(255, 255, 255);
        private Vector<byte[]> ftbsigned;
         * Initializes the applet FormularioApplet
        public void init(){
            try {
                SwingUtilities.invokeLater(new Runnable() {
                //SwingUtilities.invokeAndWait(new Runnable() {
                //java.awt.EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        try{
                            readParameters();
                            initComponents();
                        catch(FileNotFoundException e){
                            javascript(JS_ONLOADERROR, new String[] {
                                (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                            e.printStackTrace();                       
                        catch(IOException e) {
                            javascript(JS_ONLOADERROR, new String[] {
                                (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                            e.printStackTrace();
            catch (Exception e) {
                javascript(JS_ONLOADERROR, new String[] {
                    (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                e.printStackTrace();
            javascript(JS_ONLOAD, null);
        /** This method is called from within the init() method to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" C�digo Generado ">
        private void initComponents() {
            this.setSize(350, 450);
            appletPanel = new javax.swing.JPanel();
            jPanel1 = new javax.swing.JPanel();
            jTextField1 = new javax.swing.JLabel();
            jPanel2 = new javax.swing.JPanel();
            label = new javax.swing.JLabel();
            jPanel3 = new javax.swing.JPanel();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            setLayout(new java.awt.BorderLayout());
            appletPanel.setBackground(new java.awt.Color(255, 255, 255));
            appletPanel.setMaximumSize(new java.awt.Dimension(350, 430));
            appletPanel.setMinimumSize(new java.awt.Dimension(350, 430));
            appletPanel.setPreferredSize(new java.awt.Dimension(350, 430));
            jPanel1.setBackground(new java.awt.Color(255, 255, 255));
            jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            jTextField1.setFont(new java.awt.Font("Arial", 1, 18));
            jTextField1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jTextField1.setText("SIGNATURA ELECTRONICA");
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel2.setBackground(new java.awt.Color(255, 255, 255));
            jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            label.setIcon(new javax.swing.ImageIcon("C:\\java\\workspaces\\cambrabcn\\firmasElectronicas\\logo.gif"));
            org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label)
                    .addContainerGap(229, Short.MAX_VALUE))
            jPanel3.setBackground(new java.awt.Color(255, 255, 255));
            jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            //this.jButton1.setVisible(false);
            //this.jButton2.setVisible(false);
            jButton1.setText("Seg\u00fcent");
            jButton1.setAlignmentX(0.5F);
            //Cargamos el primer formulario en el JPanel2
            loadFirstForm();
            //Modificamos el texto del bot�n y el contador de pasos.
            //this.jButton1.setText("Siguiente");
            //this.jButton1.setVisible(true);
            //this.jButton2.setVisible(true);
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jButton2.setText("Cancel\u00b7lar");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 112, Short.MAX_VALUE)
                    .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton2)
                        .add(jButton1))
                    .addContainerGap())
            org.jdesktop.layout.GroupLayout appletPanelLayout = new org.jdesktop.layout.GroupLayout(appletPanel);
            appletPanel.setLayout(appletPanelLayout);
            appletPanelLayout.setHorizontalGroup(
                appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, appletPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap())
            appletPanelLayout.setVerticalGroup(
                appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, appletPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            add(appletPanel, java.awt.BorderLayout.CENTER);
        }// </editor-fold>
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            this.destroy();
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            changeForms(this.paso);
        // Declaraci�n de variables - no modificar
        private javax.swing.JPanel appletPanel;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanel2;
        private javax.swing.JPanel jPanel3;
        private javax.swing.JLabel jTextField1;
        private javax.swing.JLabel label;
        // Fin de declaraci�n de variables
         * M�todo readParameters
         * M�todo que inicializa los valores de los par�metros internos, recibidos por par�metro.
        private void readParameters() throws FileNotFoundException, IOException {
             ???????????????? deleted for the forum
            addSecurityProviders();
         * M�tode loadFirstForm
         * Aquest m�tode carrega a jPanel2 el formulari que informa sobre la c�rrega dels arxius
        private void loadFirstForm(){
            //Form1 f1 = new Form1(stream, i + 1, fileURL.size(), sender.returnCurrentContentLength(), appletBackground);
            //Form1 f1 = new Form1(fileURL.size(), sender.returnCurrentContentLength());
            Form1 f1 = new Form1();
            //Lo dimensionamos y posicionamos
            f1.setSize(310, 150);
            f1.setLocation(10, 110);
            //A�adimos el formulario al JPanel que lo contendr�
            this.jPanel2.add(f1);
            //Validem i repintem el JPanel
            jPanel2.validate();
            jPanel2.repaint();
            //Descarreguem l'arxiu a signar
            *System.out.println("FormularioApplet Dentro de loadFirstForm(), antes de llamar a getDownloadFile()");*
            *byte obj[] = f1.getDownloadedFile(this.documentToSign);*
            if (obj == null){
                System.out.println("Lo que devuelve f1.getDownloadedFile(this.documentToSign) es NULL");
            else{
                System.out.println("Lo que devuelve f1.getDownloadedFile(this.documentToSign) NO es NULL");
                System.out.println("obj: " + obj.length);
            this.ftbsigned.add(obj);
            System.out.println("FormularioApplet Dentro de loadFirstForm(), despu�s de llamar a getDownloadFile()");
            //Indicamos que el primer paso ya se ha efectuado
            this.paso++;
         * M�tode changeForms
         * Aquest m�tode carrega a jPanel2 un formulari concret segons el valor de la variable global "paso"
        private void changeForms(int paso){
            /*A cada paso se cargar� en el JPanel y formulario diferente
             * Paso previo: Se realiza en la inicializaci�n, carga el formulario, descarga el archivo y muestra la barra de carga.
             * Case 1: Se carga el formulario de selecci�n de tipo de firma.
             * Case 2: Se carga el formulario de datos de la persona que firma.
            this.paso = paso;
            switch(paso){
                case 1:
                    //Creamos un objeto de formulario (seleccion de tipo de firma)
                    Form2 f2 = new Form2();
                    //Lo dimensionamos y posicionamos
                    f2.setSize(310, 185);
                    f2.setLocation(10, 110);
                    //Quitamos el formulario 1 y a�adimos el formulario 2 al JPanel
                    this.jPanel2.remove(1);
                    this.jPanel2.add(f2);
                    //Validem i repintem el JPanel
                    jPanel2.validate();
                    jPanel2.repaint();
                    //Modificamos el contador de pasos.
                    this.paso++;
                    break;
                case 2:
                    //Creamos un objeto de formulario (seleccion de tipo de firma)
                    Form3 f3 = new Form3();
                    //Lo dimensionamos y posicionamos
                    f3.setSize(310, 175);
                    f3.setLocation(15, 130);
                    //Quitamos el formulario 1 y a�adimos el formulario 3 al JPanel
                    this.jPanel2.remove(1);
                    this.jPanel2.add(f3);
                    //Validem i repintem el JPanel
                    jPanel2.validate();
                    jPanel2.repaint();
                    //Modificamos el texto del bot�n y el contador de pasos.
                    this.jButton1.setText("Finalizar");
                    this.paso++;
                    break;
                default:
                    //Finalizar el Applet
                    //C�digo que se encargue de guardar el archivo en el disco duro del usuario
                    break;
        private void addSecurityProviders() throws FileNotFoundException, IOException {
            Security.addProvider(new CryptoAPIProvider());
            if (signatureType == SIGNATURE_PDF) {
                Security.addProvider(new BouncyCastleProvider());
            else {
                Security.addProvider(new Sun());
        private File createOutputFile(String filename, int index) {
            return new File((String)outputFilename.get(index));
        protected Object javascript(String function, String args[]) throws RuntimeException {
            //Remove
            if (true) return null;
            try {
                Vector<String> list = new Vector<String>();
                if(args != null) {
                    for(int i = 0; i < args.length; i++) {
                        list.addElement(args);
    if(list.size() > 0) {
    Object objs[] = new Object[list.size()];
    list.copyInto(objs);
    return JSObject.getWindow(this).call(function, objs);
    } catch(UnsatisfiedLinkError e) {
    e.printStackTrace();
    throw new RuntimeException((new StringBuilder()).append(e).append("\nFunci�: ").append(function).toString());
    } catch(Throwable e) {
    e.printStackTrace();
    throw new RuntimeException((new StringBuilder()).append(e).append("\nFunci�: ").append(function).toString());
    return JSObject.getWindow(this).call(function, new Object[0]);
    Edited by: Kefalegereta on Oct 31, 2007 3:54 AM
    Edited by: Kefalegereta on Oct 31, 2007 4:00 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    Additional things to try.
    Try this first. Turn Off your iPad. Then turn Off (disconnect power cord) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    Change the channel on your wireless router. Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    Another thing to try - Go into your router security settings and change from WEP to WPA with AES.
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • Awkward problems with JNI on J2SE 5.0

    I'm experiencing a strange problem with JNI and I hope someone can help me out.I've installed Cygwin, MinGW and then the CDT plug-in for Eclipse C/C++ development. This means I've used the MinGW make utility. It successfully creates the DLL file, but for some awkward reason, function www_tutorial_jni_HelloWorld_displayHelloWorld cannot be found (UnsatisfiedLinkError: displayHelloWorld).
    The Java class looks like this:
    package www.tutorial.jni;
    public class HelloWorld {
        public native void displayHelloWorld();
        static {
            System.loadLibrary("hello");
        public static final void main(String[] args) {
             try {
                  HelloWorld hw = new HelloWorld();
                  hw.displayHelloWorld();
             } catch (Exception e) {
                  System.out.println(e.toString());
    }The header that was generated by javah.exe (version 1.5.0_01) looks like this:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class www_tutorial_jni_HelloWorld */
    #ifndef _Included_www_tutorial_jni_HelloWorld
    #define _Included_www_tutorial_jni_HelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     www_tutorial_jni_HelloWorld
    * Method:    displayHelloWorld
    * Signature: ()V
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld
      (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endifThe C++ implementation looks like this:
    #include <jni.h>
    #include "www_tutorial_jni_HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld(JNIEnv
    *env, jobject obj)
        printf("Hello world!\n");
        return;
    }I've made sure that the fully qualified name of the implementation function is identical to the one in the header. I don't understand why I still get the error; especially since checking the DLL reveals that a function called "Java_www_tutorial_jni_HelloWorld_displayHelloWorld" exists.
    Could someone try and produce a successfull DLL/SO from the C++ code and then try and run the Java part on a 5.0 version of Java? I'm really curious as to what on Earth is going on...

    ... Otherwise, I would have
    to add whatever directory I put my DLL into to the
    PATH variable.Not necessarily. I believe the "PATH" also implicitly includes the "current directory". I also think that most JNI users put their DLL in a directory from which they also launch java (so it's in the current directory).
    >
    ... a java.library.path set.
    If I don't explicitly set a Java library path,
    Eclipse can't even find the DLL. I'm beginning to
    believe that Eclipse somehow screws up running Java
    programs with native code...I don't know about that... Probably just something extra you have to do with your Eclipse project so that it can find the DLL.
    But like I said, I don't really know - just trying to throw out ideas, small as they may be.

  • Problem with JFrame and busy/wait Cursor

    Hi -- I'm trying to set a JFrame's cursor to be the busy cursor,
    for the duration of some operation (usually just a few seconds).
    I can get it to work in some situations, but not others.
    Timing does seem to be an issue.
    There are thousands of posts on the BugParade, but
    in general Sun indicates this is not a bug. I just need
    a work-around.
    I've written a test program below to demonstrate the problem.
    I have the problem on Solaris, running with both J2SE 1.3 and 1.4.
    I have not tested on Windows yet.
    When you run the following code, three JFrames will be opened,
    each with the same 5 buttons. The first "F1" listens to its own
    buttons, and works fine. The other two (F2 and F3) listen
    to each other's buttons.
    The "BUSY" button simply sets the cursor on its listener
    to the busy cursor. The "DONE" button sets it to the
    default cursor. These work fine.
    The "SLEEP" button sets the cursor, sleeps for 3 seconds,
    and sets it back. This does not work.
    The "INVOKE LATER" button does the same thing,
    except is uses invokeLater to sleep and set the
    cursor back. This also does not work.
    The "DELAY" button sleeps for 3 seconds (giving you
    time to move the mouse into the other (listerner's)
    window, and then it behaves just like the "SLEEP"
    button. This works.
    Any ideas would be appreciated, thanks.
    -J
    import java.awt.BorderLayout;
    import java.awt.Cursor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class BusyFrameTest implements ActionListener
    private static Cursor busy = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
    private static Cursor done = Cursor.getDefaultCursor();
    JFrame frame;
    JButton[] buttons;
    public BusyFrameTest (String title)
    frame = new JFrame (title);
    buttons = new JButton[5];
    buttons[0] = new JButton ("BUSY");
    buttons[1] = new JButton ("DONE");
    buttons[2] = new JButton ("SLEEP");
    buttons[3] = new JButton ("INVOKE LATER");
    buttons[4] = new JButton ("DELAY");
    JPanel buttonPanel = new JPanel();
    for (int i = 0; i < buttons.length; i++)
    buttonPanel.add (buttons);
    frame.getContentPane().add (buttonPanel);
    frame.pack();
    frame.setVisible (true);
    public void addListeners (ActionListener listener)
    for (int i = 0; i < buttons.length; i++)
    buttons[i].addActionListener (listener);
    public void actionPerformed (ActionEvent e)
    System.out.print (frame.getTitle() + ": " + e.getActionCommand());
    if (e.getActionCommand().equals ("BUSY"))
    frame.setCursor (busy);
    else if (e.getActionCommand().equals ("DONE"))
    frame.setCursor (done);
    else if (e.getActionCommand().equals ("SLEEP"))
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    else if (e.getActionCommand().equals ("INVOKE LATER"))
    frame.setCursor (busy);
    SwingUtilities.invokeLater (thread);
    else if (e.getActionCommand().equals ("DELAY"))
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    System.out.println();
    Runnable thread = new Runnable()
    public void run()
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.println (" finished");
    public static void main (String[] args)
    BusyFrameTest f1 = new BusyFrameTest ("F1");
    f1.addListeners (f1);
    BusyFrameTest f2 = new BusyFrameTest ("F2");
    BusyFrameTest f3 = new BusyFrameTest ("F3");
    f2.addListeners (f3); // 2 listens to 3
    f3.addListeners (f2); // 3 listens to 2

    I've had the same problems with cursors and repaints in a swing application, and I was thinking of if I could use invokeLater, but I never got that far with it.
    I still believe you would need a thread for the time consuming task, and that invokeLater is something you only need to use in a thread different from the event thread.

  • Problem with DAQmx and Real Time PCI-7041/6040E.

    Problem with DAQmx and Real Time PCI-7041/6040E.
    I have a problem with the Real Time card PCI-7041/6040E, I think it is properly installed because my software run with the traditional NI-DAQ. When I try to use the new DAQmx to acquire one signal, Labview doesn't see any device for de DAQ card 6040E.
    Information, I work on Windows XP and LabView v7.0.0 (NIDAQ RT v7.0.0, NI-Serial RT v2.5.2, NI-VISA v3.0.1 and NI-Watchdog v2.0.0).
    Could Labview RT run with new DAQmx ?
    What can I do to use DAQmx with PCI-7041/6040E?
    Thanks for your help !

    Hello,
    I refer to your posts because i am using the PCI 7041/6040E card as
    well but without any success to make it work. The problem I have
    already described in the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=120198
    Would be nice if you had a look on it, maybe you can help me. BTW, the
    thread starts with a problem of someone else, the difficulties I
    encountered are to be found a little bit to the bottom of the thread's
    page.
    Thank you!
    Dirk Völlger
    Darmstadt
    Message Edited by ratschnowski on 07-28-2005 07:14 AM

  • Problem with attachments and antivirus.scanners

    Hi!
    Problem is: Sending any attachment from Tiger (10.4.8) mail, all attachments are removed by a virus scanner at receiving end:
    This message was modified by F-Secure Anti-Virus E-Mail Scanning.
    Tried Windows friendly, text only, repair permissions, sending under other isp etc. no help.
    If this same message with same attachment is send from next mac with Panther, it is received ok.
    Receiving company is big and wont alter their virus-scanners and the problem clearly lies in Tiger.
    Any help welcome.
      Mac OS X (10.4.8)  

    The subject of your message should have been "Problems with attachments and F-Secure antivirus" since this is not a problem with all antivirus software, only with F-Secure.
    Check this thread for a possible temporary solution when sending attachments to those who use F-Secure.
    http://discussions.apple.com/thread.jspa?messageID=2837384&#2837384

  • Problems with email and SMS after 1.3.5

    Let me first say that I love the Pre. Up until this point it has been perfect - I have a replacement, but that is because I dropped it (wrong angle, wrong location, broken screen). However, following the 1.3.5 update I'm now having a fairly important problem with email and sms - I can receive email and messages, but not send them.
    I have two email accounts. My personal account is with earthlink. My work account goes through an ISP using the domain name of my employer. I'm not using Microsoft Exchange or Outlook. I have tried deleting and reentering the accounts and that did not work. I can receive messages but get error messages when I try to send. 
    The same for messaging. I don't use it very often. But yesterday I get a text message  and tried to respond and got the error message.
    I power the phone off every night because I have a landline and use that as the primary phone at home.
    I have been looking around message boards trying to find a fix for this.  Has anyone had this issue and resolved it?
    Thank you.
    Post relates to: Pre p100eww (Sprint)
    Message Edited by starburst42 on 01-05-2010 07:06 AM
    This question was solved.
    View Solution.

    I forgot to add that this is a stock Pre. There are no patches or homebrew apps. 
    Edit:
    I found a fix for the email problem, in posts on precentral and this board from a few months ago. The info came up in a Google search, and not searches of the boards, which is kind of frustrating.  Here is the info, and the link.  I really wish Palm would put info about this work around on their site, or at least make it easy for people to find.  The solution is the last message in the thread linked below:
    Had the same problem.  Checked with Earthlink - no help.  Checked with Sprint - no help.  Checked with Palm - no help.  Here is what finally worked:
    Delete the earthlink account and start over.  When you do - this is the key - set up the account manually!  If you use the Pre defaults and try to change the settings it will not correct the problem. Your settings for outgoing mail must be:
    "smtpauth.earthlink.net"
    Use Authentication set to "on"
    username is your email address
    your email password
    port set to "587"
    encryption "none"
    Again, the key is to set up manually.
    smtp email fix
    Message Edited by starburst42 on 01-06-2010 12:08 PM
    Message Edited by starburst42 on 01-06-2010 12:09 PM

  • Problems with RAC and XA: Fallback

    Hello,
    we are seing problems with RAC and XA (Tuxedo 11, DB 11.2), specifically encountering "ORA-24798: cannot resume the distributed transaction branch on another instance".
    The first scenario relates to fallback after a RAC node failure. There are two servers, S1 and S2. S1 makes an ATMI call to S2. Both servers are in the same Tuxedo group, using TMS_ORA. RAC is set up for failover (BASIC), no load balancing.
    The sequence is:
    - S1 and S2 are connected to the same RAC node n1. All is well.
    - RAC node n1 fails. S1, S2 and the TMS_ORA all fail over to RAC node n2. After the failover has happened, all is well.
    - RAC node n1 recovers. All is still well (as there is no automatic fallback).
    - S1 (or S2) is restarted (either intentionally or because of a crash). Since n1 is up again, S1 connects to n1. Now we get ORA-24798. Permanently.
    S1 is connected to n1 and S2 is connected to n2. Since both are in the same group, both use the same XA transaction branch. When called, S2 attempts to JOIN the transaction branch that S1 started. But the DB (11.2) does not allow the same branch to span more than one node. Hence the ORA-24798.
    This seems to be a severe limitation in the combination of Tuxedo, XA and RAC. It basically means we still have to use DTP services, even with Tuxedo 11 and DB 11.2. Or are we missing something?
    We could put S1 and S2 into different groups, but that seems to be inefficient, and not practical for a real application (10s of servers).
    I am extrapolating from this that RAC load balancing would also not work, as S1 and S2 could be connected to different RAC nodes.
    Roger

    Roger,
    When using an external transaction manager such as Tuxedo you should still declare Oracle services as DTP services when using Oracle Database 11g. The Tuxedo documentation is not clear about this. The relevant 11gR2 RAC documentation is at http://download.oracle.com/docs/cd/E11882_01/rac.112/e16795/hafeats.htm and states
    "An XA transaction can span Oracle RAC instances by default, allowing any application that uses the Oracle XA library to take full advantage of the Oracle RAC environment to enhance the availability and scalability of the application.
    "GTXn background processes support global (XA) transactions in an Oracle RAC environment. The GLOBAL_TXN_PROCESSES initialization parameter, which is set to 1 by default, specifies the initial number of GTXn background processes for each Oracle RAC instance. Use the default value for this parameter clusterwide to allow distributed transactions to span multiple Oracle RAC instances. Using the default value allows the units of work performed across these Oracle RAC instances to share resources and act as a single transaction (that is, the units of work are tightly coupled). It also allows 2PC requests to be sent to any node in the cluster.
    "Before Release 11.1, the way to achieve tight coupling in Oracle RAC was to use Distributed Transaction Processing (DTP) services, that is, services whose cardinality (one) ensured that all tightly-coupled branches landed on the same instance—regardless of whether load balancing was enabled. Tightly coupled XA transactions no longer require the special type of singleton services to be deployed on Oracle RAC databases if the XA application does not join or resume XA transaction branches. XA transactions are transparently supported on Oracle RAC databases with any type of service configuration.
    A"n external transaction manager, such as Oracle Services for Microsoft Transaction Server (OraMTS), coordinates DTP/XA transactions. However, an internal Oracle transaction manager coordinates distributed SQL transactions. Both DTP/XA and distributed SQL transactions must use the DTP service in Oracle RAC."
    This issue came up earlier this year in another newsgroup thread at https://forums.oracle.com/forums/thread.jspa?threadID=2165803
    Regards,
    Ed

Maybe you are looking for

  • Installing more RAM in Macbook Pro

    I know this question has been asked a thousand times before, but I want to know if my specific MacBook Pro model, bought in October 2007 can take 4GB of RAM? I know that some of the older MacBook Pros can only take 3GB, but I'm unclear as to whether

  • A simple question of output to EXCEL

    Hi, all I am using WS_EXCEL to output a interntable to excel file.( filename will be input on dynpro). the file will be created. the Problem is, everytime i run the following codes, 1. the file content is not well formated is poor, words in the colum

  • Canvas background via Java

    Is there a way to set the background color of a canvas via Java. I am using FocusLost and FocusGained to change the background color of textfields to be able to better show where the cursor is on a form. I have a couple of forms that have multiple ca

  • Pan details

    dear sirs, i need to have a list of vendor codes who's PAN details are not maintained. which table or transaction code shall help me to get this.

  • To learn mdm.

    i whant to learn mdm currently iam working on bw past two yerars onwardws so is there to best learn any one provding for training for mdm any one suggest me.......................there is any company recurting on mdm or not.....