Delay in executing Native Methods in Java

Hi,
I have the following code in my Java application.
After calling, there is a long delay in actual execution of the native methods call. I noticed, when the program is about to terminate, then the ouput is coming from the native method.
Here is the sample code & output of the program:
Source :
======
for (int i=0; i<5; i++) {
System.out.println("Before : " + out);
new SchedulerTimer().displayHelloWorld();
System.out.println("After");
Output:
=====
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
After
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Expected :
========
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
Hello world!
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
Hello world!
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
Hello world!
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
Hello world!
After
Before : Agent : Tue Nov 09 20:51:50 GMT+05:30 2004
Hello world!
After
(In the above output, "Hello world!" is the output expected from the native method)
(displayHelloWorld - is the native method)
Thanks,

Ivar's guess is probably right.
If you use
cout << "Hello world!\n";
in a C++ program most probably the output will be buffered.
Even
cout << "Hello world!" << endl;
is not a total guarantee for flushing the buffer, although endl promises to do that. Check your C++ documentation.

Similar Messages

  • How can I return in a native method a Java type?

    Hi,
    i want to return in the native methode ja Java type java.awt.Dimension!
    How can I do this?
    Java code:--------------------------------------------------------------------------------
    public native java.awt.Dimension getSize()
    generating the JNI header file
    JNI header code:--------------------------------------------------------------------------------
    JNIEXPORT jobject JNICALL Java_Video_getSize(JNIEnv *, jobject)
    my c function looks like this
    code:--------------------------------------------------------------------------------
    JNIEXPORT jobject JNICALL Java_Video_getSize(JNIEnv *env, jobject obj)
    return ???????
    how can I return in C an object like jawa.awt.Dimension?
    Thx
    Ronny

    Here is my 2 cents for a way we pass data between Java and C via the Java Native Interface. This excerpt is an example of passing an int value through a locally created Integer wrapper class, which must be adapted for local use. Note that because of the wrapper, return values are not needed.
    1. Create the Java class file.
    * This class encapsulates a Java <CODE>int</CODE> primitive.
    * This class was created to allow programmers to change
    * the value of an existing integer object without being
    * forced to create a new object (as is the case with the
    * Java Integer object).
    public class LocalInteger
         private int     value;
         * Creates a LocalInteger object and initializes
         * it to <I>0</I> (the default in Java).
         public LocalInteger ()
              super ();
         * Creates a LocalInteger object and initializes
         * it using the given <I>int</I> value.
         * @param i Integer value to use in initializing
         * the object.
         public LocalInteger (int i)
              super ();
              value = i;
         * Gets the value of the object.
         * @return The value of the object.
         public int getValue ()
              return (value);
    2. Create the jni header file.
    DLL_EXTERN void jni_GetValue_from_LocalInteger(int* LocalInteger, JNIEnv *env, jobject thisLocalInteger);
    3. Create the C file.
    /*start of jni header****************************************
    *NAME/TITLE:       jni_GetValue_from_LocalInteger
    *DESCRIPTION:      This routine copies the integer value
    * from the Java LocalInteger object to the
    * C 'int' variable.
    *CALLING SEQUENCE: jni_GetValue_from_LocalInteger (LocalInteger,
    * env,
    * thisLocalInteger)
    *PARAMETERS:
    * Type Name I/O Description
    * int * LocalInteger I/O C variable
    * JNIEnv * env I JNIEnv pointer
    * jobject thisLocalInteger I Java object
    *RETURN:           N/A
    **end of header*********************************************/
    /* ********************** BEGIN CODE ********************** */
    DLL_EXPORT
    void jni_GetValue_from_LocalInteger(int* LocalInteger, JNIEnv *env, jobject thisLocalInteger)
         LocalInteger = (int) (env)->GetIntField(env, thisLocalInteger, LocalInteger_Value);

  • Executing native library under Java - shell script problem

    I am running a Java application on the command line bash shell. I have a few JAR files in the directory and a few native libraries. When I run the application using the command line, all works fine. This is the command I use:
    java -classpath MyGame.jar:log4j-1.2.16.jar:jme/jme-colladabinding.jar:jme-audio.jar:jme-awt.jar:jme-collada.jar:jme-editors.jar:jme-effects.jar:jme-font.jar:jme-gamestates.jar:jme-model.jar:jme-ogrexml.jar:jme-scene.jar:jme-swt.jar:jme-terrain.jar:jme.jar:jogl/gluegen-rt.jar:jogl/jogl.jar:jorbis/jorbis-0.0.17.jar:junit/junit-4.1.jar:lwjgl/jinput.jar:lwjgl/lwjgl.jar:lwjgl/lwjgl_util.jar:lwjgl/lwjgl_util_applet.jar:swt/windows/swt.jar:jbullet/jbullet-jme.jar:jbullet/asm-all-3.1.jar:jbullet/jbullet.jar:jbullet/stack-alloc.jar:jbullet/vecmath.jar:trove-2.1.0.jar:sceneMonitor/jmejtree_jme2.jar:sceneMonitor/propertytable.jar:sceneMonitor/scenemonitor_jme2.jar:sceneMonitor/sm_properties_jme2.jar -Djava.library.path="lwjgl/native/linux" -Xmx1024m -Xms768m -ea com.mygame.MainThis works fine and the application starts up as expected. LWJGL native library is loaded in and works fine as expected.
    The problem occurs when I try to run this command via the shell using a shell script. Here is my script:
    #!/bin/bash
    # Set the minimum and maximum heap sizes
    MINIMUM_HEAP_SIZE=768m
    MAXIMUM_HEAP_SIZE=1024m
    if [ "$MYAPP_JAVA_HOME" = "" ] ; then
        MYAPP_JAVA_HOME=$JAVA_HOME
    fi
    _JAVA_EXEC="java"
    if [ "$MYAPP_JAVA_HOME" != "" ] ; then
        _TMP="$MYAPP_JAVA_HOME/bin/java"
        if [ -f "$_TMP" ] ; then
            if [ -x "$_TMP" ] ; then
                _JAVA_EXEC="$_TMP"
            else
                echo "Warning: $_TMP is not executable"
            fi
        else
            echo "Warning: $_TMP does not exist"
        fi
    fi
    if ! which "$_JAVA_EXEC" >/dev/null ; then
        echo "Error: No Java environment found"
        exit 1
    fi
    _MYAPP_CLASSPATH="MyGame.jar:log4j-1.2.16.jar:jme/jme-colladabinding.jar:jme-audio.jar:jme-awt.jar:jme-collada.jar:jme-editors.jar:jme-effects.jar:jme-font.jar:jme-gamestates.jar:jme-model.jar:jme-ogrexml.jar:jme-scene.jar:jme-swt.jar:jme-terrain.jar:jme.jar:jogl/gluegen-rt.jar:jogl/jogl.jar:jorbis/jorbis-0.0.17.jar:junit/junit-4.1.jar:lwjgl/jinput.jar:lwjgl/lwjgl.jar:lwjgl/lwjgl_util.jar:lwjgl/lwjgl_util_applet.jar:swt/windows/swt.jar:jbullet/jbullet-jme.jar:jbullet/asm-all-3.1.jar:jbullet/jbullet.jar:jbullet/stack-alloc.jar:jbullet/vecmath.jar:trove-2.1.0.jar:sceneMonitor/jmejtree_jme2.jar:sceneMonitor/propertytable.jar:sceneMonitor/scenemonitor_jme2.jar:sceneMonitor/sm_properties_jme2.jar"
    _VM_PROPERTIES="-Djava.library.path=\'lwjgl/native/linux\'"
    _MYAPP_MAIN_CLASS="com.mygame.Main"
    $_JAVA_EXEC -classpath $_MYAPP_CLASSPATH $_VM_PROPERTIES -Xmx${MAXIMUM_HEAP_SIZE} -Xms${MINIMUM_HEAP_SIZE} -ea $_MYAPP_MAIN_CLASSThe shell script is in the same directory as the JAR files (the same directory where I ran the Java command above). When I execute the shell script ( sh MyGame.sh ), I get the UnsatisfiedLinkError message:
        14-Feb-2011 19:46:28 com.wcg.game.DefaultUncaughtExceptionHandler uncaughtException
        SEVERE: Main game loop broken by uncaught exception
        java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
           at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
           at java.lang.Runtime.loadLibrary0(Runtime.java:823)
           at java.lang.System.loadLibrary(System.java:1028)
           at org.lwjgl.Sys$1.run(Sys.java:73)
           at java.security.AccessController.doPrivileged(Native Method)
           at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
           at org.lwjgl.Sys.loadLibrary(Sys.java:82)
           at org.lwjgl.Sys.<clinit>(Sys.java:99)
           at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
           at com.jme.system.lwjgl.LWJGLDisplaySystem.setTitle(LWJGLDisplaySystem.java:118)
           at com.wcg.game.WcgStandardGame.initSystem(WcgStandardGame.java:287)
           at com.wcg.game.WcgStandardGame.run(WcgStandardGame.java:185)
           at java.lang.Thread.run(Thread.java:662)I don't understand what I am doing wrong. I am executing the exact same command via a shell script and it is not working. Any ideas, solutions, most welcome.
    I am running Linux Mint Debian 201012, Linux mint 2.6.32-5-amd64 #1 SMP Thu Nov 25 18:02:11 UTC 2010 x86_64 GNU/Linux. JDK is 1.6.0_22 64-bit. I have 64-bit .so files in the correct place too.
    Thanks
    Riz

    Thanks for the replies guys/gals.
    I have modified the script and echoed my command that should be running under the shell script, it is:
    java -classpath WcgFramework.jar:WcgPocSwordplay.jar:log4j-1.2.16.jar:jme/jme-colladabinding.jar:jme-audio.jar:jme-awt.jar:jme-collada.jar:jme-editors.jar:jme-effects.jar:jme-font.jar:jme-gamestates.jar:jme-model.jar:jme-ogrexml.jar:jme-scene.jar:jme-swt.jar:jme-terrain.jar:jme.jar:jogl/gluegen-rt.jar:jogl/jogl.jar:jorbis/jorbis-0.0.17.jar:junit/junit-4.1.jar:lwjgl/jinput.jar:lwjgl/lwjgl.jar:lwjgl/lwjgl_util.jar:lwjgl/lwjgl_util_applet.jar:swt/windows/swt.jar:jbullet/jbullet-jme.jar:jbullet/asm-all-3.1.jar:jbullet/jbullet.jar:jbullet/stack-alloc.jar:jbullet/vecmath.jar:trove-2.1.0.jar:sceneMonitor/jmejtree_jme2.jar:sceneMonitor/propertytable.jar:sceneMonitor/scenemonitor_jme2.jar:sceneMonitor/sm_properties_jme2.jar -Djava.library.path="lwjgl/native/linux" -Xmx1024m -Xms768m -ea com.mygame.MainI am more confident that now the shell script should be fine (I am a shell script noob) because this very command if I copy from terminal and paste into the terminal, runs the application no problem at all. But I am amazed that it is still not working. I must be doing something obviously wrong. :-(
    I used the code as suggested:
    _VM_PROPERTIES='-Djava.library.path="lwjgl/native/linux"'I am stumped!? :-(
    Thanks for help.

  • Problem finding native methods in java packages

    Hi,
    I have a java class which uses some native methods written in OCamL. I wrote a C file which calls the OCamL code, and created the corresponding shared library using the jni. I then tested my java file and everything works fine, I can nicely call the OCamL functions. However, I need this java file to be included in a package, but whenever I add the line:
    package somepackage;
    on top of the java code, my java file simply doesn't seem to find the C and OCamL implementation anymore :
    javac -cp :./path/of/somepackage
    -Djava.library.path=/full/path/of/somepackage MyProgram args
    Exception in thread "main" java.lang.UnsatisfiedLinkError:functionName
    at somepackage.ClassName.functionName(NativeMethod)
    I have of course put everything (java, C, .h , libsomelibrary.so, and OCamL files) in a directory called somepackage, and written another java file which creates an instance of the first one from outside the package, imports the package, and calls its methods in main(). It just doesn't work anymore.
    I then added a simple hello-world function (not C nor OCamL code) to the java file inside the package. And when invoked from outside, it worked. Question is then... Am I forgetting something to be done, in order to get C and CamL files efectively included in the java package (same as "package somepackage;" in C or OCaml, perhaps)??? Why isn't the java file able to find them inside its very own directory (having into account that without the package definition it worked well)?
    Thanks,
    PS Im using jsdk 1.4.1 on lunyx redhat 8.0

    Did you change the name of the function in the library, too?
    If the function name was
    "Java_YourClass_functionname",
    it should be now
    "Java_path_to_your_package_YourClass_functionname".

  • At java.lang.Throwable.fillInStackTrace(Native Method)

    Hello,
    I have a Jsp,which has a hyper link to another Jsp.Some times very rarely i get this error when i click on the
    link.
    java.lang.RuntimeException: IOException occured
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at java.lang.RuntimeException.<init>(Compiled Code)
    at weblogic.servlet.internal.ServletOutputStreamImpl.write(Compiled Code)
    at weblogic.servlet.internal.WLOutputStreamWriter.flushBuffer(Compiled Code)
    at weblogic.servlet.internal.WLOutputStreamWriter.write(Compiled Code)
    at weblogic.servlet.internal.WLOutputStreamWriter.write(Compiled Code)
    at java.io.Writer.write(Compiled Code)
    at weblogic.servlet.jsp.JspWriterImpl.print(Compiled Code)
    at examples.jsp._pfsonline._https._showhide.__sso_showhide_cur._jspService(Compiled Code)
    at weblogic.servlet.jsp.JspBase.service(Compiled Code)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled Code)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled Code)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled Code)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled Code)
    at weblogic.servlet.internal.ServletContextManager.invokeServlet(Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(Compiled Code)
    at weblogic.kernel.ExecuteThread.run(Compiled Code)
    can some one tell me when does this happen.Is it something to do with the configuration.
    Thanks
    Shashi

    Did you ever find out the answer to this question?
    I have been getting a similar error. My page draws
    fine, but I get an occasional error:
    java.lang.RuntimeException: IOException occured
    at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:178)
    at weblogic.servlet.internal.WLOutputStreamWriter.flushBuffer(WLOutputStreamWriter.java:139)
    at weblogic.servlet.internal.WLOutputStreamWriter.write(WLOutputStreamWriter.java:104)
    at weblogic.servlet.internal.WLOutputStreamWriter.write(WLOutputStreamWriter.java:111)
    at java.io.Writer.write(Unknown Source)
    at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:155)
    at jspc._admin._offering.__offering_intro._jspService(__offering_intro.java:433)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:138)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:941)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:905)
    at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:391)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:273)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
    Let me know if you get any answers.
    Best,
    JL
    [email protected]

  • Java.lang.OutOfMemoryError(Native Method)

    Hello Everybody,
    We hava a java.lang.OutOfMemoryError,the problem weblogic server installed in windows 2003 x64,weblogic version 9.2 MP1,sun jdk 1.5.0_22 32bit,the memory configuration below:
    set MEM_ARGS=-server -Xms1024m -Xmx1024m -verbose:gc -Xloggc:%SERVER_NAME%_GC.log -XX:SurvivorRatio=3 -XX:NewSize=512M -XX:MaxNewSize=512M -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+HeapDumpOnCtrlBreak -XX:+HeapDumpOnOutOfMemoryError
    if "%JAVA_VENDOR%"=="Sun" (
         set MEM_ARGS=%MEM_ARGS% %MEM_DEV_ARGS% -XX:MaxPermSize=512m
    The error in log below:
    ####<2013-2-16 上午11时08分15秒 CST> <Error> <Kernel> <CWGK-APP-2> <node2> <[STANDBY] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1360984095564> <BEA-000802> <ExecuteRequest failed
    java.lang.OutOfMemoryError.
    java.lang.OutOfMemoryError
         at java.io.RandomAccessFile.readBytes(Native Method)
         at java.io.RandomAccessFile.read(RandomAccessFile.java:315)
         at weblogic.diagnostics.archive.FileUtils.readFile(FileUtils.java:46)
         at weblogic.diagnostics.archive.filestore.FileIndexMetaInfo.buildIndex(FileIndexMetaInfo.java:403)
         at weblogic.diagnostics.archive.filestore.FileIndexMetaInfo.buildIndex(FileIndexMetaInfo.java:319)
         at weblogic.diagnostics.archive.filestore.FileDataArchive.computeFullIndices(FileDataArchive.java:521)
         at weblogic.diagnostics.archive.filestore.FileDataArchive.computeIndices(FileDataArchive.java:629)
         at weblogic.diagnostics.archive.filestore.FileDataIndexer$IndexCommand.run(FileDataIndexer.java:199)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    >
    How can i solution the problem?
    Please help.

    Need more log information to diagnose it.
    Kinds,
    Gabriel Abelha

  • Executing UNIX command in Java

    I am having problems executing a command in Java. Here's the code I have for executing:
    Process p = Runtime.getRuntime().exec(cmd);
                                            BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
         while((display = input.readLine()) != null)
                             num_1 = Double.parseDouble(display);
                             percent = (num_1 * 100) / (50000000);
                        flip = 1;
                        catch(IOException e)
                        e.printStackTrace();     
                        System.exit(1);
    Now, when I run the script, I receive the following errors:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.io.FilePermission /Netadmin/UCDSNMP/bin/snmpdelta execute)
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at java.lang.RuntimeException.<init>(RuntimeException.java:47)
    at java.lang.SecurityException.<init>(SecurityException.java:39)
    at java.security.AccessControlException.<init>(AccessControlException.java:57)
    at java.security.AccessControlContext.checkPermission(Compiled Code)
    at java.security.AccessController.checkPermission(Compiled Code)
    at java.lang.SecurityManager.checkPermission(Compiled Code)
    at java.lang.SecurityManager.checkExec(SecurityManager.java:789)
    at java.lang.Runtime.exec(Compiled Code)
    at java.lang.Runtime.exec(Compiled Code)
    at java.lang.Runtime.exec(Runtime.java:152)
    at snmp.actionPerformed(Compiled Code)
    at java.awt.Button.processActionEvent(Button.java:308)
    at java.awt.Button.processEvent(Button.java:281)
    at java.awt.Component.dispatchEventImpl(Compiled Code)
    at java.awt.Component.dispatchEvent(Compiled Code)
    at java.awt.EventQueue.dispatchEvent(Compiled Code)
    at java.awt.EventDispatchThread.pumpOneEvent(Compiled Code)
    at java.awt.EventDispatchThread.pumpEvents(Compiled Code)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
    The user is entering the parameters for the UNIX command from a Java applet. Everything looks right, but I can't seem to run the file? Please help! All is appreciated.
    Jason Banks
    Northeastern University

    Sorry, this is a bug that I've reported -- see Sun's response and my original report (along with how to get around the problem) shown below:
    Hi Vira Van.,
    The bug you have reported is a duplicate of Bug ID: 4522533.
    Thank you for providing us with additional information
    that can be used in the resolution of this bug.
    This bug can be monitored via the the Java Developer
    Connection Bug Parade at:
    http://developer.java.sun.com/developer/bugParade/index.jshtml
    The Java Developer Connection is a free channel that is
    maintained by staff here at Sun.  Access this web page to join:
    http://developer.java.sun.com/servlet/RegistrationServlet
    The home page for the JDC is:
    http://java.sun.com/jdc
    Regards,
    Girish
    ----------------- Original Bug Report-------------------
    category : java
    release : 1.4
    subcategory : jar
    type : bug
    synopsis : signed applet: bad major version number on NN4.79 and ClassNotFound in IE5.5
    description : FULL PRODUCT VERSION :
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    FULL OPERATING SYSTEM VERSION : Windows 98 [Version
    4.10.2222]
    ADDITIONAL OPERATING SYSTEMS :
    BROWSERS: Netscape Navigator 4.79
            : Internet Explorer 5.5
    EXTRA RELEVANT SYSTEM CONFIGURATION :
    Applet failed to start in Netscape, the following error
    message appeared in the Java Console:
    Netscape Communications Corporation -- Java 1.1.5
    Type '?' for options.
    Symantec Java! ByteCode Compiler Version 210.065
    Copyright (C) 1996-97 Symantec Corporation
    # Applet exception: error: java.lang.ClassFormatError: Bad
    major version number
    java.lang.ClassFormatError: Bad major version number
      at java.lang.ClassLoader.defineClass(Compiled Code)
      at netscape.applet.AppletClassLoader.findClass(Compiled
    Code)
      at netscape.applet.AppletClassLoader.loadClass1(Compiled
    Code)
    * at netscape.applet.AppletClassLoader.loadClass(Compiled
    Code)
      at netscape.applet.AppletClassLoader.loadClass(Compiled
    Code)
      at
    netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(
    Compiled Code)
      at
    java.awt.EventDispatchThread$EventPump.dispatchEvents(Compil
    ed Code)
      at java.awt.EventDispatchThread.run(Compiled Code)
      at
    netscape.applet.DerivedAppletFrame$AppletEventDispatchThread
    .run(Compiled Code)
    The same applet
    A DESCRIPTION OF THE PROBLEM :
    Unable to run signed applet with Netscape 4.79 and IE5.5
    native JVM.
    REGRESSION.  Last worked in version 1.3.1
    STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    1.compile program and copy class files to a temp directory
    2.sign the applet for Netscape as follows:
    signtool -k aok -d \progra~1\netscape\users\viravan -Z
    FIO.jar temp
    3.sign the applet for Internet Explorer as follows:
    cabarc -p n FileIO.cab FileIO*.class
    setreg 1 true
    makecert -sk aok -n "CN=aok" aok.cer
    cert2spc aok.cer aok.spc
    signcode -j javasign.dll -jp LOWX -spc aok.spc -k aok
    FileIO.cab
    Run the applet with the following HTML file:
    <html><head><Title>Self-Signed Applet</Title>
    <script>
    document.layers ? parm=1 : parm=0;
    </script>
    <body>
    This file I/O applet lets you read and write to the user's
    local disk.<br>
    <br>
    <script>
    document.writeln('<APPLET CODE = "FileIO" CODEBASE = "."
    ARCHIVE = "FIO.jar" WIDTH = 10 HEIGHT = 10 NAME = "JSF">');
    document.writeln('<param name="Netscape"
    value="'+parm+'">');
    document.writeln('<param name="cabbase"
    value="FileIO.cab">');
    document.writeln('</APPLET>');
    </script>
    </body>
    </html>
    EXPECTED VERSUS ACTUAL BEHAVIOR :
    A frame with a textarea and some buttons should popup in the
    center of the screen.
    ERROR MESSAGES/STACK TRACES THAT OCCUR :
    Applet signed with signtool failed to start in Netscape, the following error
    message appeared in the Java Console:
    Netscape Communications Corporation -- Java 1.1.5
    Type '?' for options.
    Symantec Java! ByteCode Compiler Version 210.065
    Copyright (C) 1996-97 Symantec Corporation
    # Applet exception: error: java.lang.ClassFormatError: Bad major version number
    java.lang.ClassFormatError: Bad major version number
      at java.lang.ClassLoader.defineClass(Compiled Code)
      at netscape.applet.AppletClassLoader.findClass(Compiled Code)
      at netscape.applet.AppletClassLoader.loadClass1(Compiled Code)
    * at netscape.applet.AppletClassLoader.loadClass(Compiled Code)
      at netscape.applet.AppletClassLoader.loadClass(Compiled Code)
      at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled Code)
      at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
      at java.awt.EventDispatchThread.run(Compiled Code)
      at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled
    Code)
    The same applet signed with signcode failed to start in Internet explorer, the
    error message in the Java Console is:
    Error loading class: FileIO
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: FileIO
            at com/ms/vm/loader/URLClassLoader.loadClass
            at com/ms/vm/loader/URLClassLoader.loadClass
            at com/ms/applet/AppletPanel.securedClassLoad
            at com/ms/applet/AppletPanel.processSentEvent
            at com/ms/applet/AppletPanel.processSentEvent
            at com/ms/applet/AppletPanel.run
            at java/lang/Thread.run
    This bug can be reproduced always.
    ---------- BEGIN SOURCE ----------
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class FileIO extends Applet implements ActionListener {
       public static void main(String[] args) {
          new FileIO();
          F.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
                System.exit(0);
       public void init() {
          String tmp=getParameter("Netscape");
          if (tmp!=null) {
             if (tmp.equals("1")) {
                try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileAccess");
                   NS=true;
                } catch (Throwable exception) {}
          new FileIO();
          F.setResizable(false);
       public void stop() {
          F.dispose();
       public FileIO() {
          newline=System.getProperty("line.separator");
          F.setLayout(new BorderLayout(0,0));
          String line,inbuf="";
          String newline=System.getProperty("line.separator");
          text=new TextArea(inbuf,24,80,TextArea.SCROLLBARS_BOTH);
          text.setFont(new Font("Courier",Font.PLAIN,12));
          text.setBackground(Color.cyan);
          text.setForeground(Color.black);
          F.add("Center",text);
          Panel pan=new Panel();
          pan.setLayout(new FlowLayout(1,0,0));
          pan.setBackground(Color.yellow);
          TF=new TextField(40);
          TF.setFont(new Font("Courier",Font.PLAIN,12));
          pan.add(TF);
          OP=new Button("Open");
          OP.addActionListener(this);
          pan.add(OP);
          FS=new Button("Save");
          FS.addActionListener(this);
          pan.add(FS);
          SA=new Button("Save-As");
          SA.addActionListener(this);
          pan.add(SA);
          reset=new Button("Reset");
          reset.addActionListener(this);
          pan.add(reset);
          F.add("South",pan);
          F.pack();
          Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
          Dimension size=F.getSize();
          int X=(screen.width-size.width)/2;
          int Y=(screen.height-size.height)/2;
          F.setLocation(X,Y);
          F.setVisible(true);
       public void actionPerformed(ActionEvent event) {
          String tmp="";
          String O=text.getText();
          StringTokenizer tkn=new StringTokenizer(O,newline);
          int ntkn=tkn.countTokens();
          Object ev=event.getSource();
          if (ev.equals(OP)) {
             FileDialog fd=new FileDialog(F,"File to open",FileDialog.LOAD);
             fd.setFile("*.java");
             fd.show();
             tmp=fd.getDirectory();
             if (fd.getFile()==null) {text.requestFocus(); return;}
             tmp+=fd.getFile();
             TF.setText(tmp);
             try {
                if (NS)
    {netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");}
                BufferedReader reader=new BufferedReader(new FileReader(tmp));
                String line;
                String crlf="";
                tmp="";
                while ((line=reader.readLine())!=null) {
                   tmp+=crlf+line;
                   crlf="\n";
                reader.close();
                text.setText(tmp);
             } catch (Throwable e) {
                e.printStackTrace();
          } else if (ev.equals(FS) || ev.equals(SA)) {
             try {
                if (ev.equals(SA)) {
                   FileDialog fd=new FileDialog(F,"File to save",FileDialog.SAVE);
                   fd.setFile("*.java");
                   fd.show();
                   tmp=fd.getDirectory();
                   tmp+=fd.getFile();
                } else {
                   tmp=TF.getText();
                if (tmp.length()==0) {text.requestFocus(); return;}
                if (tmp.indexOf(".java")<0) tmp+=".java";
                TF.setText(tmp);
                if (NS)
    {netscape.security.PrivilegeManager.enablePrivilege("UniversalFileWrite");}
                FileOutputStream fos=new FileOutputStream(tmp);
                BufferedWriter out=new BufferedWriter(new OutputStreamWriter(new
    DataOutputStream(fos)));
                for (int i=0;i<ntkn;i++) out.write(tkn.nextToken()+newline);
                out.flush();
                out.close();
                if (NS)
    {netscape.security.PrivilegeManager.revertPrivilege("UniversalFileWrite");}
                System.out.println(tmp+" saved");
             } catch (Throwable e) {
                e.printStackTrace();
          } else if (ev.equals(reset)) {
             text.setText("");
             TF.setText("");
          text.requestFocus();
       private String replace(String input, String srch, String repl) {
          int i=input.indexOf(srch);
          while (i>=0) {
             input=input.substring(0,i)+repl+input.substring(i+srch.length());
             i=input.indexOf(srch);
          return input;
       private Button OP,FS,SA,reset,TB;
       private boolean newLine,NS=false;
       private TextArea text;
       private TextField TF;
       private final char NL='\n';
       private String content,newline;
       private static Frame F=new Frame("FileIO");
    ---------- END SOURCE ----------
    CUSTOMER WORKAROUND :
    build the signed applet with SDK1.3.1 or make it a signed
    applet that uses Java Plugin 1.4.0 (i.e., sign it with jarsigner).
    workaround :
    suggested_val :
    cust_name : Vira Van.
    dateCreated : 2002-03-24 19:52:18.4
    dateEvaluated : 2002-04-01 18:48:10.858

  • Execute unix command using java

    Hello
    Can we execute a unix command using java? If it is how we can execute. Is this affect the performance of the program.
    Thanks

    I tried what you said. But its not working and returning error message,
    java.io.IOException: CreateProcess: ls -a error=2
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    If i try this statement,
    Runtime.getRuntime().exec("c\windows\notepad");
    It is working fine.
    Any idea about this.
    Plz ...........

  • Errors in compiling native method

    I am trying to call a native method from a java source program. I generated header file by javah and wrote c file for native method implementation. I work on RedHat Linux-7.2.
    Java file for native method:-
    class HelloNative
    {  public static native void greeting();
    static
    {  System.loadLibrary("HelloNative");
    Java file for calling native method(main java file):-
    class HelloNativeTest
    {  public static void main(String[] args)
    {  HelloNative.greeting();
    C file implementing native method:-
    #include <stdio.h>
    JNIEXPORT void JNICALL Java_HelloNative_greeting
    (JNIEnv* env, jclass cl)
    {  printf("Hello world!\n");
         I am using following command for compiling c source file:-
    cc -G -I/usr/java/jdk1.3.1/include -I/usr/java/jdk1.3.1/include/linux HelloNative.c -o HelloNative.so
    It gave me followig errors on compiling:-
    cc: unrecognized option `-G'
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start':
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'
    collect2: ld returned 1 exit status.

    Looks to me like you're not telling the linker to create a library (DLL). I'm not familiar with Linux, but clearly if the linker if looking for 'main' then its trying to build an executable.

  • Exception in Class class native method

    Hi Guys,
    I am getting an Exception in the Class class native method getMethod0. The Exception is java.lang.NoSuchMethodException. Can some put light on this, as to why is this coming???
    Here's the starckTrace........
    java.lang.NoSuchMethodException
         at java.lang.Class.getMethod0(Native Method)
         at java.lang.Class.getMethod(Class.java:888)
         at com.gepower.gees.vc.utility.VCComparator.compare(VCComparator.java:67)
         at java.util.Arrays.mergeSort(Arrays.java:1181)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.sort(Arrays.java:1128)
         at java.util.Collections.sort(Collections.java:121)
    Thanx,
    Chandan.

    Class.getMethod() throws that exception if the method that is being searched for does not exist.
    And VCComparator.compare() used Class.getMethod().
    So something is wrong in VCComparator.compare().

  • UnsatisfiedLinkError,   Load Library Successfully, Native Method Not Found

    I am using JNI to call a ".dll" file I made on windows.
    I got the exception:
    Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: com.aspectgaming.core.io.JniInnocore.Dpci.waitEvent(Ljava/lang/Object;J)I
    at com.aspectgaming.core.io.JniInnocore.Dpci.waitEvent(Native Method)
    at com.aspectgaming.core.io.JniInnocore.IDLPThread.run(IDLPThread.java:19)
    at java.lang.Thread.run(Unknown Source)
    The code for loading c dll library:
    URL url = Thread.currentThread().getContextClassLoader().getResource("");
    String baseClassPath = url.getPath();
    System.load(baseClassPath "com/aspectgaming/libjnidpcicore.dll");+
    The  ".dll"  file is already loaded,  because when I changed the dll file name to any other ones,  a "library file not found" exception will be caught.
    The problem is Dpci.waitEvent and all the native methods could not be found.
    I used a PE viewer to view the dll exports I got:
    Export table
    Characteristics=0, TimeDateStamp=1237366066, MajorVersion=0, MinorVersion=0, Name=36994, Base=1, NumberOfFunctions=9, NumberOfNames=9, AddressOfFunctions=36904, AddressOfNames=36940, AddressOfNameOrdinals=36976,
    TimeDateStamp:Wed Mar 18 16:47:46 GMT+08:00 2009
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_getEventName@12 (Ordinal: 1, Entry Point RVA: 147ah (5,242))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_getNumOfEvents@8 (Ordinal: 2, Entry Point RVA: 11a5h (4,517))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_getNumOfInputPorts@12 (Ordinal: 3, Entry Point RVA: 1789h (6,025))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_getSramSize@8 (Ordinal: 4, Entry Point RVA: 1190h (4,496))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_readEvent@12 (Ordinal: 5, Entry Point RVA: 11bah (4,538))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_readPort@12 (Ordinal: 6, Entry Point RVA: 17a7h (6,055))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_waitEvent@20 (Ordinal: 7, Entry Point RVA: 14b8h (5,304))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_waitIOPort@24 (Ordinal: 8, Entry Point RVA: 17dbh (6,107))
    Java_com_aspectgaming_core_io_JniInnocore_Dpci_writePort@16 (Ordinal: 9, Entry Point RVA: 182ch (6,188))
    The java class "Dpci" is exactly in this package : com.aspectgaming.core.io.JniInnocore;
    I compiled it by gcc on linux as a ".so" file and everything is working on linux.
    On windows I am compiling this by Mingw gcc.
    Here is the make file on Windows which is used by Mingw32-make:
    dpci_core:
    gcc -o ../../../java/com/aspectgaming/libjnidpcicore.dll -shared -IC:\jdk1.6.0_10\include -IC:\jdk1.6.0_10\include\win32 -I'D:\Program Files\Innocore Gaming Ltd\DirectPCI SDK & Run-time\include' dpci_core.c libdpci_static.lib
    dpci_core.c is my code file and  libdpci_static.lib is the library that my c dll will depend on.
    Any thought to this UnsatisfiedLinkError exception problem?
    Thanks!

    I recompile my codes under visual c++ 2008 express on Windows XP professional, and I have already got rid of this problem.
    But when I move the compiled java jar application to windows xp embedded edition, an exception will be caught:
    C:\AspectGamingCore>java -jar Aspect.jar
    Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\AspectGamingCore\l
    ib\libjnidpcicore.dll: This application has failed to start because the applicat
    ion configuration is incorrect. Reinstalling the application may fix this proble
    m
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.aspectgaming.core.io.JniInnocore.Dpci.loadLibraryOnWindows(Unknow
    n Source)
    at com.aspectgaming.core.io.JniInnocore.DpciTest.main(Unknown Source)
    I don't know if there is any compatible problem bewteen xp and xpe but one possible reason is that xpe may be lack of some dll files like msvcr90.dll.
    So I tried to compile the dll as static library in vc++2008, but this does not run even on my winxp professional:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\AspectGamingCore\l
    ib\libjnidpcicore.dll: %1 is not a valid Win32 application
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.aspectgaming.core.io.JniInnocore.Dpci.loadLibraryOnWindows(Unknow
    n Source)
    at com.aspectgaming.core.io.JniInnocore.DpciTest.main(Unknown Source)
    Could JNI call a c static library? Why it says "not a valid Win32 application"?

  • Calling native method

    Guys please help me with following error.
    I am running a simple JNI program,after creating and loading the dll i am getting following error.......
    Exception in thread "main" java.lang.UnsatisfiedLinkError: print
    "print" is the native method in java class Hello.java
    Hello.h has method declaration as :
    JNIEXPORT void JNICALL Java_Hello_print
    (JNIEnv *, jobject);
    and C++ file has method defined as :
    JNIEXPORT void JNICALL
    Java_Hello_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    please help me out...it has been 3 days banging against JNI ...

    Guys please help me with following error.
    I am running a simple JNI program,after creating and
    loading the dll i am getting following error.......
    Exception in thread "main"
    java.lang.UnsatisfiedLinkError: print
    "print" is the native method in java class
    Hello.java
    Hello.h has method declaration as :
    JNIEXPORT void JNICALL Java_Hello_print
    (JNIEnv *, jobject);
    and C++ file has method defined as :
    JNIEXPORT void JNICALL
    Java_Hello_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    please help me out...it has been 3 days banging
    against JNI ...If your Java code is in a package, then your native header file declaration is wrong. The javah tool expects the fully qualified class name. So, if your Hello class is in package com.foo.hello, you should generate the header file like this:
    javah com.foo.hello.HelloThen the native header declaration will look like this:
    JNIEXPORT void JNICALL Java_com_foo_hello_Hello_print
    (JNIEnv *, jobject);

  • NoClassDefFoundError problems -native method

    hi all,
    i've got a wierd problem... when i try to run a java appln ( for instance curl.java whose class is stored in a jar file) without giving a proper argument say like:
    java XX.RR.YY.curl
    a message prompts me to input a valid argument :
    Usage: XX.RR.YY.hyd <options>
    but when i try to run the same program - this time giving it a valid argument- like :
    java XX.RR.YY.curl -curltest.xml
    it spews out the following error messages along many others
    Exception in thread "main" java.lang.NoClassDefFoundError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:130)
    my point is why does java fail to find the class when i give it a valid argument and not when i do not give it any.
    thanks in advance

    exactly ... my java program has a similar code in it
    regarding the arg checking .
    so it does mean that java had found my appln
    class(yay! my classpath is right) and had run thru a
    few lines of code to get to the point where it
    realized it needed some arguments and so gently asked
    me supply an argument (a valid filename in my case)...Did you write this code? Did you put in the line where it displays the usage?
    so the next thing i do is run the same command java
    xx.xx.xx -curltest.xml ( i've supplied a valid
    argument this time ) ... the result :
    Exception in thread "main"
    java.lang.NoClassDefFoundError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:130)
    why did java fail to grab my appln class this time -
    in contrast to the first time where it found the class
    file w/o any problems. Try just using "java xx.xx.xx curltest.xml" (without the '-').

  • SharePoint Web Part: "Unable to Execute Service Method getLocaleStrings

    When using the UCM Web Part to promote content from SharePoint 2007 to UCM 11.1.1.3, I am getting an error: "Unable to Execute Service Method getLocaleStrings"
    Does this mean there is an incompatibility between the UCM web part and UCM 11.1.1.3, or is there a workaround?
    In my UCM logs, I am seeing:
    Unable to execute service method 'getLocaleStrings'. java.lang.NoSuchFieldError: m_locales. [ Details ]
    An error has occurred. The stack trace below shows more information.
    !csUserEventMessage,weblogic,10.2.20.96!$!csUnableToExecMethod,getLocaleStrings!syJavaExceptionWrapper,java.lang.NoSuchFieldError: m_locales
    intradoc.common.ServiceException: !csUnableToExecMethod,getLocaleStrings
    at intradoc.server.ServiceRequestImplementor.buildServiceException(ServiceRequestImplementor.java:2071)
    at intradoc.server.Service.buildServiceException(Service.java:2207)
    at intradoc.server.Service.createServiceExceptionEx(Service.java:2201)
    at intradoc.server.Service.createServiceException(Service.java:2196)
    at intradoc.server.Service.doCodeEx(Service.java:583)
    at intradoc.server.Service.doCode(Service.java:504)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1622)
    at intradoc.server.Service.doAction(Service.java:476)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1439)
    at intradoc.server.Service.doActions(Service.java:471)
    at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1371)
    at intradoc.server.Service.executeActions(Service.java:457)
    at intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:723)
    at intradoc.server.Service.doRequest(Service.java:1865)
    at intradoc.server.ServiceManager.processCommand(ServiceManager.java:435)
    at intradoc.server.IdcServerThread.processRequest(IdcServerThread.java:265)
    at intradoc.server.IdcServerThread.run(IdcServerThread.java:160)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.NoSuchFieldError: m_locales
    at intradoc.custom.integrationsupport.services.LocaleStringsService.getLocaleStrings(LocaleStringsService.java:45)
    at sun.reflect.GeneratedMethodAccessor549.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at intradoc.common.IdcMethodHolder.invokeMethod(IdcMethodHolder.java:86)
    at intradoc.common.ClassHelperUtils.executeMethodEx(ClassHelperUtils.java:310)
    at intradoc.common.ClassHelperUtils.executeMethod(ClassHelperUtils.java:295)
    at intradoc.server.Service.doCodeEx(Service.java:549)
    ... 15 more

    did you solve the problem???

  • ArrayOutOfBoundsException in socketRead0 (native method)

    Hello,
    I have a problem with the following code:
      public static void socketOverload() throws Exception {
        Thread serverThread = new Thread(new Runnable() {
          public void run() {
            try {
              ServerSocket serverSocket = new ServerSocket(10000);
              Socket socket = serverSocket.accept();
              System.out.println("Server OK");
              InputStream in = socket.getInputStream();
              byte[] b = new byte[10];
              while (true) {
                in.read(b,0,b.length);
            } catch (Exception e) {
              System.out.println("Server Error");
              e.printStackTrace();
        Thread clientThread = new Thread(new Runnable() {
          public void run() {
            try {
              // put your local ip here, do not use 127.0.0.1!
              Socket socket = new Socket("129.132.130.156",10000);
              System.out.println("Client OK");
              OutputStream out = socket.getOutputStream();
              byte[] b = new byte[1000];
              for (int i = 0; i < b.length; i++) {
                b[i] = 0;
              while (true) {
                out.write(b,0,b.length);
            } catch (Exception e) {
              System.out.println("Client Error");
              e.printStackTrace();
        serverThread.start();
        synchronized (Thread.currentThread()) {
          try {
            Thread.currentThread().sleep(2000);
          } catch (Exception e) {
        clientThread.start();
      }The client contacts the server and sends the server much more data than it can process.
    My question is, why does the server crash (sometimes immediately, sometimes after a short moment) with an ArrayOutOfBoundsException in the (native code) readSocket0 method?
    java.lang.ArrayIndexOutOfBoundsException
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:129)
      at testproject.TestApp$8.run(TestApp.java:401)
      at java.lang.Thread.run(Thread.java:536)Sure, the server is overloaded and might drop some data on TCP/IP-layer because of a BufferOverflow or something like that. But why does it crash with an ArrayOutOfBounds? And why is the socket/stream closed afterwards? (OK, if it drops data it is out of synch with the byte-stream and can't go on.)
    The next question that arises: Why does the server crash and not the client? Is it possible to detect or circumvent the problem on client-side? Usually I would suppose the .write()-method to fail in this situation?
    And last: Why does it crash only with a local IP number, but not with "127.0.0.1"/localhost? I always thought there should be no difference? (I tried at least several minutes, but it never crashes.)
    Thanks :-).

    I get similar nonsensical errors in my heavy-socket use web crawling application. There are no bad parameters passed in from my code; as is seen from the following stack trace fragment, the problem location is reached via no-argument java runtime library methods, which then compose their own parameters to the native method:
    java.lang.ArrayIndexOutOfBoundsException
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.net.SocketInputStream.read(SocketInputStream.java:182)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
         at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:109)
    I definitely don't see these with the IBM Linux JVM, and I don't think I've ever seen them with the Sun Linux JVM. But they're fairly common with heavy client (web-fetching) activity in the 1.4.2 Windows JVM.
    Any insights on what's happening appreciated.

Maybe you are looking for

  • OIM 11g High Availability Deployment

    Hi Experts, I'm deploying OIM 11g in High Available schema, following Oracle docs: http://download.oracle.com/docs/cd/E14571_01/core.1111/e10106/imha.htm#CDEFECJF, I have succesfully installed and configured OIM & SOA in weblogic domain on 'OIMHOST1'

  • Open a New Window when using a Jump Query

    I have created a URL jump via RSBBS transaction.  I have also created a Web Application that contains my query with the jump.  I want the jump to open in a new window with the Address Bars and navigational bars (Back button, etc) to show.  I know the

  • OT: Miro Video Converter

    This is a head's up to anyone looking for Video converters.  I had the misfortune of downloading the latest free Miro Video Converter. I was horrified by all the garbage software it attempted to install on my system. Nevertheless, I used the Advanced

  • Displaying dynamic table in OOPS ALV

    Hi, I am creating a dynamic internal table which consists of some fields which are being filled dynamically and some fields which are being filled from a static internal table. I am facing two issues in the development:- 1. The static fields are bein

  • Schedule documents to email in Business Objects XI R3.1

    Hello I need to schedule documents to email. how do i configure the email  in Business Objects XI R3.1 ? can i have any document regarding the scheduling ? Any solution, it helps me a lot. Thanks mahesh Edited by: mahesh ch on Feb 19, 2009 11:51 AM