Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6476706
Votes 58
Synopsis Error AGENT_ERROR_NO_JNI_ENV printed sometimes to console when JVM finishes
Category java:debugger
Reported Against b99
Release Fixed
State 3-Accepted, bug
Priority: 4-Low
Related Bugs
Submit Date 29-SEP-2006
Description
The following error is printed to console when debugger is about to finish:

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]

It was found by other people as well:

http://www.google.co.uk/search?hl=en&q=AGENT_ERROR_NO_JNI_ENV%28183%29++util.c%3A820&btnG=Google+Search&meta

I am able to reproduce it with  xxxxx  IDE (http://www.netbeans.org/issues/show_bug.cgi?id=85538):

- install  xxxxx  IDE 6.0
- create a java project
- add two lines to main method (System.out.println("aaa");System.out.println("bbb");)
- add  customer  to the first line
- start debugger (F5)
- continue when it stops at  customer . The error message above is SOMETIMES
printed to output window.

Build NB 6.0 20060919-0644, JDK1.6.0-b99, WindowsXP.
Posted Date : 2006-09-29 11:59:37.0

An e-mail comment from Alan:

> It sounds like a timing issue in the shutdown with the agent still running.
Posted Date : 2007-03-13 16:11:28.0
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   

Submitted On 22-NOV-2006
Still in 
Sun Microsystems Inc. 1.6.0-rc


Submitted On 13-DEC-2006
i have same errors too...


Submitted On 16-DEC-2006
I get this error also...


Submitted On 17-DEC-2006
Me too...


Submitted On 28-DEC-2006
Mikhail0s
same


Submitted On 02-JAN-2007
njusohohchaser
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 02-JAN-2007
so wot?


Submitted On 10-JAN-2007
Betlista
Same problem with eclipse :-/


Submitted On 10-JAN-2007
Betlista
In main method there could be no code and error occures, so there will be (I think) no workaround...


Submitted On 12-JAN-2007
I got similar error.

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 14-JAN-2007
JonRWoods
Happens one in ten times for me too when debugging short programs.  JDK 1.6.0 (build 1.6.0-b105) on Windows XP Professional from Eclipse 3.2.1.  As for others:

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 21-JAN-2007
Still appears in build 105


Submitted On 23-JAN-2007
Happened to me this morning debugging in NetBeans


Submitted On 24-JAN-2007
jwcarman
Happens to me within IntelliJ IDEA.  I wrote a simple "Hello, World" main() method and tried to debug it.  Got the same exact error message.  


Submitted On 05-FEB-2007
netrice
I get this error also...


Submitted On 10-FEB-2007
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]

I first use JDK6.0 to debug my program,but it shown me above, sign


Submitted On 18-FEB-2007
Orclev
still showing up in 1.6.0-b105
reproduced using MyEclipse Enterprise Workbench 5.5.0 Milestone 1 and Maven 2.0.5
Exact error is same as posted previously, but I'll repost for clarity:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 18-FEB-2007
Orclev
Still in 1.6.0-b105 JDK on WindowsXP
Was able to reproduce it using Maven 2.0.5, so it seems to be related to any sort of debuger, specificly it occurs during the test phase of the Maven build. Exact error follows:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 12-MAR-2007
I made a console program with JDI and worked it on JDK1.4 and JDK1.5 without problems. But on JDK1.6,  same message is sometimes found (not always). 
--
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]
--
My environment is:
  - JDK1.6 (build 1.6.0-b105)
  - Windows XP SP2


Submitted On 15-MAR-2007
Eu tambem tive esse erro


Submitted On 16-MAR-2007
joejoes75
Me Too!


Submitted On 17-MAR-2007
same here


Submitted On 17-MAR-2007
tried with JDK1.5, no error 


Submitted On 19-MAR-2007
prajzv1
same for me, netbeans 5.5, jdk1.6.0, WinVista


Submitted On 20-MAR-2007
Same here, fixed it. 
Had a JFrame in my package without  showing it.

Original:
    public static void main(String[] args) {
        // TODO code application logic here
    }

Fixed:
    public static void main(String[] args) {
        // TODO code application logic here
        frameMain fm = new frameMain();
        fm.setVisible(true);
    }


Submitted On 23-MAR-2007
my workaround...

Original:    
public static void main(String[] args) {
        System.out.println("test");
}

Workaround:
    public static void main(String[] args) {
        System.out.println("test");
        System.exit(0);
    }


Submitted On 04-APR-2007
andig2
Still present in 1.6.0_01 U1


Submitted On 07-APR-2007
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 11-APR-2007
Getting this on my Maven projects in Eclipse using Java 6u1, which is preventing my company to adapt Java 6. Same error message as above.


Submitted On 15-APR-2007
me too
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 04-MAY-2007
Me too.
I'm trying to programme with Berkley DB,then it occurred.


Submitted On 04-MAY-2007
When will this bug be fixed?
Since last year SEP


Submitted On 04-MAY-2007
Me too.
I'm trying to programme with Berkley DB,then it occurred.


Submitted On 11-MAY-2007
eating
Yeah, I met with the same problem in eclipse 3.2.2 win32
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 31-MAY-2007
cigxw
same error; latest java 1.6.0_01-b06; win xp sp2


Submitted On 01-JUN-2007
belgampaul
it happens sometimes while debugging a project. Some projects are debugged with no problems, in others it is quite random. Sometimes debugging works, sometimes not.



jdk 1.6
netbeans 6.0(M9)


Submitted On 01-JUN-2007
belgampaul
Thanks for the workarounds. None of them don't work with Netbeans 6.0(M9), jdk 1.6.

I was able more less to find the workaround in Netbeans though. I just refactor the class the doesn't submit the first breakpoint.

I've already encountered some weird stuff with the netbeans refactoring but this one is just too weird.


Submitted On 27-JUN-2007
DJnZ
got it too.. 
Eclipse SDK
Version: 3.2.2
Build id: M20070212-1330
java.runtime.version=1.6.0_01-b06


Submitted On 10-JUL-2007
The same error:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]

I'm using Eclipse 3.2.1 running on JDK 1.6.0_02 and this error occures when I finishing debugging my app.


Submitted On 14-JUL-2007
Error AGENT_ERROR_NO_JNI_ENV solution
Workaroud (works for me):
I've make this workaround based in info in this.
Somebody said this could be a timing problem for short programs, so put somewhere in main(...) beginning this code:

    try
    {
      Thread.sleep(100);
    }
    catch(Exception e)
    {}


Submitted On 22-JUL-2007
try to remove all the breakpoints and then to add breakpoints if it's needed.
I had the same message and it doesn't appear anymore!


Submitted On 17-AUG-2007
Same is here 
jdk  1.6.0_02 
Eclipse 3.3 _Maven Plugin


Submitted On 28-AUG-2007
What happens if you use JDK instead of JRE? Is the message still shown?


Submitted On 10-SEP-2007
Got the same error..
Eclipse
jdk  1.6.0_02 


Submitted On 06-OCT-2007
Same here
jdk 1.6.0u2
eclipse 3.3.1


Submitted On 11-OCT-2007
Same issue here:

Product Version: NetBeans IDE 6.0 Beta 1 (Build 200709141330) 
Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105 
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb) 


Submitted On 22-OCT-2007
I just encountered this error, and its driving me crazy, i cant compile my project anymore! isnt there ANY workaround??

Eclipse Version: 3.3.0
Build id: M20070921-1145

JDK 1.6.0_03 


Submitted On 28-OCT-2007
As andig2 noted, adding "System.exit(0)" is a very good workaround.


Submitted On 12-NOV-2007
Has someone finally found any kind of workaround?


Submitted On 17-NOV-2007
facing the same issue


Submitted On 30-NOV-2007
Happened on jdk1.6.0_03 netbeans 6.1 rel.29-11-07 in search for icon by image chooser in debugging jswing. 30 nov 07
shahrokh


Submitted On 06-DEC-2007
DiGiTaL_FuRy
I am using java 1.6.0_02 on XP Pro
I keep getting it and I don't know why.  I took out all my break points and it still happens.  

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 01-JAN-2008
I got this problem, too. But the run function can not work anymore.
Environment: Eclipse 3.2.2  + JRE 1.6

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 01-JAN-2008
I got this problem,too. Eclipse 3.2.2 + JRE 1.6


Submitted On 05-JAN-2008
I got this problem, too. But the run function can not work anymore.
Environment: Eclipse 3.2.2  + JRE 1.6

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 28-JAN-2008
Exekutor
Exact same problem here

EasyEclipse Server Java
Version: 1.2.2.2
Based on Eclipse build id: M20070212-1330

java version "1.6.0_03"

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 12-JUN-2008
Debashis.Prusty
Me too getting the same error following this. So I am not able to upgrade to JDK6
Exception in thread "main" java.lang.UnsatisfiedLinkError: XXX: The system cannot find the file specified at java.lang.ClassLoader$NativeLibrary.load(Native Method)


Submitted On 10-JUL-2008
hsyn
System.exit(0);

at the end of main will help


Submitted On 13-JUL-2008
One more here


Submitted On 13-JUL-2008
Adam.Wozniak
I have the same issue.

OS: Windows XP, Polish version

Java:
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

IDE:
Eclipse 3.4

I run my application in Debug mode using Eclipse.

Error message:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 29-JUL-2008
Trivelato
I had the same problem using Eclipse Europe.

In the Eclipse was configured Apache TomCat 5.5 and 6.0 and JRE's 1.5 and 1.6.

I solved the problem removing all settings of Apache and JRE in Eclipse and then set back the Apache TomCat JRE 1.5 and 5.5 only within the Eclipse.


[ ]'s,


Trivelato


Submitted On 22-JAN-2009
Still happening... I got it in Eclipse after a shutdown - restart after a point update.  Seems in this case to be related to having reconfigured packages through eclipse.  Committed the changes to SVN, deleted the project, and then checked it out and the problem went away.


Submitted On 28-JAN-2009
objectid
I confirm that this bug is still present. I'm using 
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

It happens in Eclipse 3.4 when trying to debug a Java application. This application is a TCP test client build using Grizzly 1.9.3. The same JVM is used by Eclipse and lauching the Java application. 


Submitted On 31-MAR-2009
inzanity
This debugging error is STILL unresolved. 


Submitted On 22-APR-2009
Eirik
Got the same error when I stopped my tomcat-deployed webapp. I can't believe this has been around for so long without being resolved. How hard can it be? Just fix it.


Submitted On 06-MAY-2009
So, here it is 5/09 and still in circulation. Going for a record?


Submitted On 08-MAY-2009
Got the same error. Using jre6. This bug has been logged more than 2 + years back and still not been fixed.. 


Submitted On 24-JUN-2009
This happens every time I try running my program after commenting out a method call that starts up a thread and the rest of the program depends on that thread. I'm not supposed to be able to crash the JVM during runtime by running my code because that is a security vulnerability. 

Here is my program output:

Monitoring C:\Temp
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


running:

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)



Submitted On 10-AUG-2009
maurice_yudanaz
same here, in Eclipse  3.4.2. Thread-related. 


Submitted On 22-SEP-2009
i have same errors too...


Submitted On 09-OCT-2009
pagod
Hi everyone,

Anything new on this front? I'm having this problem with eclipse 3.3.1.1 jvm 1.6.0_14, and that's really annoying because i'm trying to debug code that should be executed *after* the problem occurs. 

Basically, I've set a shutdown hook which should execute some code to properly close some files. the shutdown hook is bound to a small embedded class Finalizer that calls function terminate in another class. Upon shutting down, the run function of my Finalizer class is called, and the eclipse debugger is able to break at any breakpoint I set there. However, it won't go into the next function (terminate), and if I set a breakpoint inside the terminate function then apparently the debugger never reaches it, and the error is displayed. And since I'm trying to see what's happening in an external library, I can't even use println messages to trace the code... :-(

Any ideas? 

Cheers,

Pagod


Submitted On 13-OCT-2009
lenin2k
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 13-OCT-2009
lenin2k
Cool
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 02-DEC-2009
Cybex
I had this after executing bug-free code:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 02-DEC-2009
Cybex
Got this sometimes:
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Submitted On 15-JAN-2010
c1dillon
Same here after a fresh update to JDK 6u18 on Win XP



PLEASE NOTE: JDK6 is formerly known as Project Mustang