Non-static version of java.lang.Thread.dumpstack?
hi,
it would be useful sometimes to have a graphical debug panel on an application I'm working on which shows the active threads and allows further information to be shown if wanted - the problem is that I can't find an API call to get the current stack dump of an arbitrary thread - does anyone know if this is possbile somehow without a full debug environment?
java.lang.Thread.dumpstack would be ideal if only it were an instance method..
thanks,
asjf
what's the probelm? you call this in the threads class
and each thread (object) executes this statement and
therefore prints its stacktrace ...ok - here is some mocked up (and plain wrong in terms of the tree model's consistency over sequential method calls) code that shows what I'd like to achieveimport java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import javax.swing.event.*;
public class JThreadExp extends JPanel {
JTree tree;
JTextArea jta;
public JThreadExp(TreeModel model) {
super(new GridLayout(1,2,4,4));
tree = new JTree(model);
jta = new JTextArea();
add(tree);
add(jta);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
PrintStream stderr = System.err;
String msg=null;
try {
TreePath tp = e.getPath();
System.out.println(tp.getLastPathComponent());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(new BufferedOutputStream(baos, 1024*1024));
System.setErr(ps);
Thread t = (Thread) tp.getLastPathComponent();
try {
t.dumpStack();
} catch(Throwable ee) {}
ps.close();
jta.setText(baos.toString()); //newXML.toString());
} catch(Exception e2) {
msg = e2.getMessage();
System.setErr(stderr);
if(msg!=null)
System.out.println(msg);
public static void main(String[]arg) throws Exception {
JFrame frame = new JFrame("JThreadExp");
JThreadExp jte;
final ThreadModel tm = new ThreadModel();
frame.getContentPane().add(jte = new JThreadExp(tm));
frame.pack();
frame.setVisible(true);
final JTree tree = jte.tree;
new Thread(new Runnable() {
public void run() {
try {
while(true) {
TreeModelEvent tme = new TreeModelEvent(this, new Object [] {tm.getRoot()});
for(Iterator i = tm.listeners.iterator(); i.hasNext(); )
((TreeModelListener) i.next()).treeStructureChanged(tme);
Thread.sleep(5000);
new Thread(new Runnable() {
public void run() {
try { Thread.sleep(50000); } catch(Exception e) {e.printStackTrace();}
} ).start();
} catch(Exception e) {
e.printStackTrace();
} ).start();
class ThreadModel implements TreeModel {
public boolean isLeaf(Object node) { return (node instanceof Thread); }
public Object getRoot() {
ThreadGroup uppermost = Thread.currentThread().getThreadGroup();
while(uppermost.getParent()!=null)
uppermost = uppermost.getParent();
return uppermost;
public Object getChild(Object p, int i) {
Object result = "<unavailable>";
if(p instanceof ThreadGroup) {
ThreadGroup parent = (ThreadGroup) p;
ThreadGroup[] tg = new ThreadGroup[parent.activeGroupCount()];
Thread[] t = new Thread[parent.activeCount()];
parent.enumerate(tg, false);
parent.enumerate(t, false);
if(i<tg.length)
result = tg;
else if(i<tg.length+t.length)
result = t[i-tg.length];
return result;
public int getChildCount(Object node) {
int result = 0;
if(node instanceof ThreadGroup) {
ThreadGroup parent = (ThreadGroup) node;
ThreadGroup[] tg = new ThreadGroup[parent.activeGroupCount()];
Thread[] t = new Thread[parent.activeCount()];
result += parent.enumerate(tg, false);
result += parent.enumerate(t, false);
return result;
public int getIndexOfChild(Object parent, Object child) {
for(int i=0; i<getChildCount(parent); i++) {
if(getChild(parent,i).equals(child))
return i;
return -1;
Set listeners = new HashSet();
public void addTreeModelListener(TreeModelListener l) {
listeners.add(l);
public void removeTreeModelListener(TreeModelListener l) {
listeners.remove(l);
public void valueForPathChanged(TreePath path, Object newValue) { // this shouldn't be called - Tree is not editable
System.out.println("valueForPathChanged");
} The problem is that I'd like to obtain a reference to a Thread object (which I haven't written the code for) and get a (vaguely accurate if not exact) stack dump from it.
I'll have a look over JDB in the meantime thanks :)
thanks,
asjf
Similar Messages
-
Hi
I am using JDev12c. I have an isolated taskflow that is consuming three more taskflow as a region.
This is the scenario: I have a viewObject showing UserDetails. So I have make a taskflow to show the user details in a form. Now, the userDetalsVO has a ViewLink with itself (Managers having employees under their supervision).
LoggedInUser (userVO)
- Employees (userVO)
I have created the list of employee using the Employees Iterator. However, every time I select an employee the console throw the following error:
<The row key or row index of a UIXCollection component is being changed outside of the components context. Changing the key or index of a collection when the collection is not currently being visited, invoked on, broadcasting an event or processing a lifecycle method, is not valid. Data corruption and errors may result from this call. Turn on fine level logging for a stack trace of this call. Component ID: {0}>
java.lang.Exception: Stack trace:
at java.lang.Thread.dumpStack(Thread.java:1342)
at org.apache.myfaces.trinidad.component.UIXCollection._verifyComponentInContext(UIXCollection.java:2212)
at org.apache.myfaces.trinidad.component.UIXCollection.setRowKey(UIXCollection.java:524)
at oracle.adf.view.rich.component.rich.data.RichListView.visitChildren(RichListView.java:112)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at oracle.adf.view.rich.component.fragment.UIXRegion.visitChildren(UIXRegion.java:952)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at oracle.adf.view.rich.component.fragment.UIXRegion.visitChildren(UIXRegion.java:952)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXShowOne.visitTree(UIXShowOne.java:135)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:445)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:423)
at org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:703)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:566)
at org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:362)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._deliverPostRestoreStateEvents(LifecycleImpl.java:852)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._restoreView(LifecycleImpl.java:791)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:397)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:225)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:192)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:303)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:208)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:225)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
The front end behaves fine though but that error in the console is bugging me.
Any Ideas??
RegardsWell, have you run the app with logging set to fine as the message suggested?
Turn on fine level logging for a stack trace of this call. Component ID: {0}
Then a test case and a detailed description on how to reproduce the error, built on the hr schema, can help.
Timo -
Cannot find class java/lang/Thread
I'm getting this error trying to compile a program that I'm writing in java. Its a very simple program just to get me back to basics. Any ideas as to how I can fix this problem??
Extracted from Sun's website,
* Error Message: "Exception in thread NULL" or
"Unable to initialize threads: cannot find class java/lang/Thread"
If you are getting one of these fatal error messages when running java,
javac, or appetviewer, you should check your CLASSPATH environment variable.
It may list "c:\java" or the "classes" directory from an older release. You can either unset the CLASSPATH variable, or set it to
include only the latest version of the Java platform class library. For example:
C:\> set CLASSPATH=.;C:\jdk1.1.8\lib\classes.zip
This will make sure that you are using the correct classes for this release.
-- Sudha -
Java.lang.thread exception while using Xalan 2.0 in WLS 6.0
Hi, I'm trying to use Xalan 2.0 in a servlet hosted by WLS. Ive
modified Xalan's SimpleTransform sample to be a servlet. I
create a Transformer with the .xsl, then call tranform() to
print the tranformed xml to the response stream. The xml is
tranformed correctly, but it throws a java.lang.thread
exception. The standalone Xalan sample doesn't do this. Anyone
else seen this problem?
Here's the code of interestest, I apologize if its not formatted very well:
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
PrintWriter out = res.getWriter();
res.setContentType("text/html");
out.println("<html><head><title>XalanTest<title></head>");
out.println("<body><h1>XalanTest</h1>");
try{
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource ss = new StreamSource("file:\\\\My-path\\birds.xsl");
Transformer transformer = tFactory.newTransformer(ss);
StreamResult SR = new StreamResult(out);
transformer.transform(new StreamSource("file:\\\\My-path\\birds.xml"), SR );
catch(Exception e){
out.println("<p>" + e.toString() + "</p>");
e.printStackTrace(out);
out.println("<p>Exception</p>");
out.println("</body></html>");It also looks like the workaround suggested does not work.
I put the following code as workaround:
response.setContentType("text/html");
response.setHeader ("Pragma", "no-cache");
Transformer transformer;
TransformerFactory factory = TransformerFactory.newInstance();
String stylesheet = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xsl";
String sourceId = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xml";
String outputFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.html";
String outputDirectFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2_Direct.html";
try
PrintWriter fout = new PrintWriter (new FileOutputStream (outputFile));
OutputStream os = new ByteArrayOutputStream();
transformer = factory.newTransformer(new StreamSource(stylesheet));
transformer.transform(new StreamSource(sourceId), new StreamResult(outputDirectFile));
transformer.transform(new StreamSource(sourceId), new StreamResult(os));
os.flush ();
os.close();
out.print(os.toString());
fout.print (os.toString ());
fout.flush ();
fout.close ();
catch (Exception e)
// Error Handler
e.printStackTrace();
The two .html files produced look exactly the same, which is good.
However, the screen output to my html browser (Internet Explorer 5.50 sp1) produces
different output.
That is strange, but that shows that this bug does not have a known workaround
"Rabinowitz" <[email protected]> wrote:
>
I have the same problem with java sun xml parser (jaxp 1-1)
It is interesting to know that all this perfectly works under weblogic
5.1, so
I cannot migrate my application to 6.0
So, the functionality of weblogic 6.0 degraded since 5.1.
I cannot buy the explanation that that is not bea's fault, because it
perfectly
worked with the same version of xml parser.
Now, their customer support is saying they have not decided whether this
is a
bug or a feature.
Interesting to know that degradation of functionality could be a feature!
It is now June 21, 3 months since this bug was reported, sp2 was shipped
since
that time, and this bug is still there.
"Chuck H. Zhao" <[email protected]> wrote:
I am having the exact same problem you are having. If we analyze the
stack
trace:
javax.xml.transform.TransformerException: java.lang.Thread
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1212)
at
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
at java.lang.Thread.run(Thread.java:484)
java.lang.ClassCastException: java.lang.Thread
at
weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
:273)
at
weblogic.servlet.internal.ServletResponseImpl.setDateHeader(ServletResponseI
mpl.java:449)
at
weblogic.servlet.internal.ServletResponseImpl.writeHeaders(ServletResponseIm
pl.java:637)
at
weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamI
mpl.java:124)
at
weblogic.servlet.internal.WLOutputStreamWriter.flush(WLOutputStreamWriter.ja
va:124)
at java.io.PrintWriter.flush(PrintWriter.java:120)
at
org.apache.xalan.serialize.SerializerToXML.flushWriter(SerializerToXML.java:
1431)
at
org.apache.xalan.serialize.SerializerToXML.endDocument(SerializerToXML.java:
629)
at
org.apache.xalan.transformer.ResultTreeHandler.endDocument(ResultTreeHandler
..java:180)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1194)
at
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
at java.lang.Thread.run(Thread.java:484)
What happened is: to support incremental output, Xalan-Java performs
the
transformation in a second thread while building the source tree inthe
main
thread. So Transformer.transform() creates a new thread to run the
transformer.run() method, which will write to weblogic's internal
ServletOutputStreamImpl, and in the end calls flush() on it.
ServletOutputStreamImpl determines that the headers haven't been written
yet, and the headers need to be written before any servlet output, so
it
calls ServletResponseImpl.writeHeaders(), which eventually calls
ResponseHeaders.setDateHeader(). The last method assumes the thread
is
weblogic's internal ExecuteThread and tries to cast the thread as such,
maybe to get the date from it. But the thread is a plain java.lang.Thread
created by xalan, thus we get the java.lang.ClassCastException:
java.lang.Thread
This suggests a second workaround: call ServletResponse.flushBuffer()
before any xalan stuff, which will force the headers to be written in
weblogic's ExecuteThread. The shortcoming of this is that this will
cause
the response to be commited, and if the xalan stuff throws exception
you can
not forward to another page.
Another thing is that xalan should not directly call flush() on
ServletOutputStreamImpl at all. I will report it to xalan and see if
they
consider that a bug. If they fix that then we have a third workaround:
set
the buffer size of ServletResponse big enough to accomodate everything
including the xslt outputs, so the ServletOutput does not need to be
flushed
during xalan code.
I do not consider this problem a weblogic bug, since the servlet container
has to right to expect any thread inside it to be its own. Serlvet2.2
spec
says:
1.2 What is a Servlet Container?
A Servlet Container may place security restrictions on the environment
that
a servlet executes in. In
a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise
Edition 1.2 (J2EE)
environment, these restrictions should be placed using the permission
architecture defined by Java 2
Platform. For example, high end application servers may limit certain
action, such as the creation of
a Thread object, to insure that other components of the container are
not
negatively impacted.
Weblogic should explicitly warn the developers that creating threads
inside
the servlet container may have adverse effects, the same kind of problem
we
are having. (or maybe they already did somewhere in their documentation?)
On the xalan side, I would suggest them to either give the option to
switch
the two threads, or to give the option to buffer the output and write
it out
in the main thread, which is exactly what you did in your first workaround.
Any comments or thoughts on the subject are welcome.
-- Chuck Zhao
"MK Parini" <[email protected]> wrote in message
news:[email protected]...
I found, what I think to be a bug, and a work-around for it.
When doing an XSLT Transformation, you must specify a StreamResult
to which to write the output. I was doing my transformation in
a
servlet so I was writing my output to the HttpResponse
(The variable res is a javax.servlet.http.HttpServletResponse
object)
StreamResult htmlTarget = new StreamResult(res.getWriter());
If I use this, when I perform the transformation using the TRAX
APIs,
InputStream xslFile = context.getResourceAsStream(fileName);
TransformerFactory tFactory = TransformerFactory.newInstance();
Templates xslTemplates = tFactory.newTemplates(new StreamSource(xslFile));
transformer = xslTemplates.newTransformer();
transformer.transform(xmlSource, htmlTarget);
I receive the ClassCastException from the class
weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
:273),
as seen in my previous posting.
I discovered, if I write my output to a StringBuffer, and then
I write
the StringBuffer to the HttpResponse, I do not get the ClassCastException.
For example,
StringWriter myWriter = new StringWriter(2400);
StreamResult htmlTarget = new StreamResult(myWriter);
<Same transformation code as above>
myWriter.close();
PrintWriter out = res.getWriter();
out.print(myWriter.toString());
Is this a bug in the weblogic internal servlet class or am I just
missing something?
Also, one concern that I have with the workaround is that it might
hurt performance.
Any comments or thoughts on the subject are welcome. -
Question on java.lang.Thread "starting problems"
hi everybody
i've just little trouble running a tiny program which uses Threads.
maybe there's a misunderstanding from my side:
About my code:
01 public class MyThread extends Thread {
02
03 String any_string = null;
04
05 public MyThread(String param) {
06 any_string = param;
07 this.start();
08 }
09
10 public void run() {
11 while(!isInterrupted()) {
12 System.out.println(" > This Thread is running!");
13 // any other operation...
14 try {
15 sleep(1000);
16 }
17 catch(Exception e) {}
18 }
19 }This is a Thread's code similar to those you can find it in the java.lang.Thread Documentation or in the java Tutorial.
In my example I got a IllegalThreadStateException in codeline 07 which means (compare to java.lang.Thread Documentation) that the code tries to start the Thread while the Thread is still running.
I always thought a Thread will not start itself.
I thought (and that's the way, i red it in the documentation) that the constructor of a Thread only allocates the new Thead-Object.
But by constructing MyThread I got the descripted exception (i'm beginning to repeat myself...). The "funny" thing on this exception is that the Thread at least IS running but there could be no Object allocated
01 ...
02 /**
03 * construction of a new Object of the class MyThread.
04 * test will be auto-started by the MyThread constructor
05 */
06 MyThread test = new MyThread("any-string");
07 ...
08 test.anyMethodOfClassMyThread();This little code generates a java.lang.NullPointerException in line 08 (when trying to access the object of class MyThread). Even after the application exits (in case of this exception), the run()-Method of MyThread generates its Text-Output " > This Thread is running!". argh
Does anyone see my mistake / misunderstanding??
It's really frustrating if you are sitting in front of your pc and can't get the reason why your prog is generating that "bullshit" (ok... i know - it's only generatting the bullshit I told it to generate :( )
Any suggestions or ideas
thanks,
ThofWell now, I don't get a NullPointerException, when I try to call a method of MyThread. Here's your code, with slight modifications by me:
public class MyThread extends Thread {
String any_string = null;
public MyThread(String param) {
any_string = param;
this.start();
public String getAnyString(){
return any_string;
public void run() {
while(!isInterrupted()) {
System.out.println(" > This Thread is running!");
try {
sleep(1000);
catch(Exception e) {}
}To test the app I wrote this class:
public class TestMyThread {
public static void main(String[] args) {
MyThread temp = new MyThread("Hello World");
System.out.println(temp.getAnyString());
}Now it does print out the correct "Hello World".
Your other problem of the thread not shutting down is because it is not a daemon thread. To solve this you will need to add this Thread to a ThreadGroup and set the ThreadGroup as a Daemon group. (see ThreadGroup::setDaemon() )
Or you can put a little boolean in your while loop and break out when you change the value of the boolean. Then when you want to shut down you simply change the boolean
Hope this helps
-Philip -
Thread unserialized exception: NotSerializableException: java.lang.Thread
hello experts,
i have this exception coming; seems to be coming from some thread but i removed all the threads from my code, i thought its because of some object which is still unserialized, i am not sure whether this is because of one unserialized object or its because of more reasons, please have a look:
Exception in client main: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
at BallServerImpl_Stub.getAllBallProxies(Unknown Source)
at CopyOfManyMovingBalls.<init>(CopyOfManyMovingBalls.java:80)
at CopyOfManyMovingBalls$2.run(CopyOfManyMovingBalls.java:294)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
... 11 more
this is coming when i m accessing this method:
class BallServerImpl extends UnicastRemoteObject
implements BallServer
* @return an enumeration of all Balls as proxy objects
public Ball[] getAllBallProxies() throws java.rmi.RemoteException
Ball[] locations1 = new Ball[hash.size()];
java.util.Enumeration iter = hash.elements();
int idx = 0;
while (iter.hasMoreElements())
BallImpl impl = (BallImpl)iter.nextElement();
locations1[idx++] = new BallProxy(impl);
return locations1;
why this function is running fine when i m calling this from client unlike getAllBallProxies() nevertheless both are returning the same thing:
* @return an enumeration of all Balls as remote references
public Ball[] getAllBalls()
Ball[] locations = new Ball[hash.size()];
java.util.Enumeration iter = hash.elements();
int idx = 0;
while (iter.hasMoreElements())
locations[idx++] = (Ball)iter.nextElement();
return locations;
the proxy Class:
* The Proxybouncing ball.
public class BallProxy implements Serializable,Ball {
* The Real bouncing ball.
public class BallImpl extends UnicastRemoteObject implements IBallRemote,Serializable
*load of thanks as this is "SHOW STOPPER",
jibbylala*
Edited by: 805185 on Oct 25, 2010 8:33 PM
Edited by: 805185 on Oct 25, 2010 8:39 PM
Edited by: 805185 on Oct 25, 2010 9:21 PM
Edited by: 805185 on Oct 25, 2010 9:25 PM
Edited by: 805185 on Oct 25, 2010 9:27 PM
Edited by: 805185 on Oct 25, 2010 9:46 PMthat there was some thread there in BallProxy but i removed all from them and now testingIf you don't post the code people ask to see, you may never get a useful answer here.
P.S i didn't know that threads are not SerializedThe Thread class is not Serializable. Precision please.
Now i m updating the code, i needed the confirmationConfirmation of what?
and now trying to avoid them.Them?
But what if i need them.Them?
Please make the effort to express yourself clearly. You've already been told you're not making much sense and you haven't done anything about it.
how can we make serialized?The concept of serializing a Thread makes no sense whatsoever. You don't want to do it. You don't need to do it. You can't do it. It wouldn't work if you could do it.
Somewhere or other you have a class member that is a reference to a Thread. Remove it or make it transient. If you post the code somebody may help you. If you don't, nobody can possibly do that. -
Deprecated methods in java.lang.thread
Hi,
I am getting the followng warning message when i run my code:
The method void stop() in class java.lang.Thread has been deprecated,
can anyone suggest an alternative method to the deprectaed stop method, i can't seem to find one.
Thanks in advanceThe stop() method in thread has been deprecated because it is inherently dangerous. The suggested action now is to simply modify a variable inside the thread to tell it to stop running, and the thread should periodically check the variable to see when it should stop. There's good description of why stop() and a few other methods in Thread have been deprecated at..
http://java.sun.com/j2se/1.4/docs/guide/misc/threadPrimitiveDeprecation.html -
URGENT- PLEASE HELP: java.lang.threads and BC4J
Hi,
according to my issue "no def found for view" in the same titled thread I'm wondering how you would implement asynchronous calls of methods that use BC4J to update a couple of data.
To be more precise:
A requirement of our software is to start an update database job, which can take a couple of minutes/hours, from the web browser. Before it will be executed the logged-in user receives a notification that this batch job has been started.
I dont't want to use JMS overhead and MD Beans for this simple requirement, therefore I implemented a class that extends java.lang.Thread and put all the update codings within the run method. After having called the start-method of the thread I get a JBO-25022(No XML file found) error when I try to set a new value for an attribute of the row. The row consists of attributes which belong to four entity objects that mus be updated.
When calling the run method directly, everything works fine.
My questions:
* do you know any workaround how to make the xml files
reachable?
* how would you implement anschronous calls of long time-
consuming jobs?
* is this a bug of BC4J?
Any help, tip, hint is really appreciated.
StefanArno,
many thanks for your reply:
Here is an excerpt of the source code of my thread "Aenderungsdienst":
public class Aenderungsdienst extends java.lang.Thread
private SviAdministrationModuleImpl mSviModul;
// Application module that contains view object
// IKViewImpl
public Aenderungsdienst(SviAdministrationModuleImpl aSviModul)
mSviModul = aSviModul;
public void run()
ausfuehrenAenderungsdienst(mAenderungsdienstNr); <--error within this methode
private int ausfuehrenAenderungsdienst(String aAenderungsdienstNr)
int rAnzahlSaetze = 0;
try
IkViewImpl aenderungen = mSviModul.getIkView();
aenderungen.suchenAenderungssaetze(aAenderungsdienstNr); <-- method within View Object Impl that executes a query with customized where-clauses
if ((rAnzahlSaetze = aenderungen.getRowCount()) > 0)
IkViewRowImpl ik = null;
while (aenderungen.hasNext())
ik = (IkViewRowImpl) aenderungen.next();
ik.setBestandsstatus("B"); <-- error occurs here when setting the status of a current row in my rowset to "B"
mSviModul.getTransaction().postChanges();
mSviModul.getTransaction().commit();
catch (Exception e)
e.printStackTrace();
mSviModul.getTransaction().rollback();
//todo: Verarbeitungsprotokoll erstellen
return rAnzahlSaetze;
This thread will be called by the application module "sviAdministrationModuleImpl":
public void ausfuehrenAenderungsdienst(String
aAenderungsdienstNr)
Aenderungsdienst aenderungsdienst = new
Aenderungsdienst(this);
aenderungsdienst.setAenderungsdienstNr
(aAenderungsdienstNr);
aenderungsdienst.start();
Using the start() method of the thread causes this exception:
[653] No xml file: /hvbg/svi/model/businessobjects/businessobjects.xml, metaobj = hvbg.svi.model.businessobjects.businessobjects
[654] Cannot Load parent Package : hvbg.svi.model.businessobjects.businessobjects
[655] Business Object Browsing may be unavailable
[656] No xml file: /hvbg/svi/model/businessobjects/IK_Inlandsbankverb.xml, metaobj = hvbg.svi.model.businessobjects.IK_Inlandsbankverb
09.03.2004 10:27:41 hvbg.common.businessobjects.HvbgEntityImpl setAttributeInternal
SCHWERWIEGEND: Fehler beim Setzen des Attributs 1 im Entity Objekt: JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
09.03.2004 10:27:42 hvbg.svi.model.dienste.Aenderungsdienst ausfuehrenAenderungsdienst
SCHWERWIEGEND: Beim Ausführen des Aenderungsdienstes 618 trat während der DB-Aktualisierung ein schwerer Fehler auf:
JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
oracle.jbo.NoDefException: JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
at oracle.jbo.mom.DefinitionManager.findDefinitionObject(DefinitionManager.java:328)
at oracle.jbo.mom.DefinitionManager.findDefinitionObject(DefinitionManager.java:268)
at oracle.jbo.server.MetaObjectManager.findMetaObject(MetaObjectManager.java:649)
at oracle.jbo.server.EntityAssociation.findEntityAssociation(EntityAssociation.java:98)
at oracle.jbo.server.AssociationDefImpl.resolveEntityAssociation(AssociationDefImpl.java:725)
at oracle.jbo.server.AssociationDefImpl.getEntityAssociation(AssociationDefImpl.java:135)
at oracle.jbo.server.AssociationDefImpl.hasContainer(AssociationDefImpl.java:546)
at oracle.jbo.server.AssociationDefImpl.getContainer(AssociationDefImpl.java:468)
at oracle.jbo.server.EntityImpl.getContainer(EntityImpl.java:1573)
at oracle.jbo.server.EntityImpl.setValidated(EntityImpl.java:1649)
at oracle.jbo.server.EntityImpl.setAttributeValueInternal(EntityImpl.java:2081)
at oracle.jbo.server.EntityImpl.setAttributeValue(EntityImpl.java:1985)
at oracle.jbo.server.AttributeDefImpl.set(AttributeDefImpl.java:1700)
at oracle.jbo.server.EntityImpl.setAttributeInternal(EntityImpl.java:946)
at hvbg.common.businessobjects.HvbgEntityImpl.setAttributeInternal(HvbgEntityImpl.java:56)
at hvbg.svi.model.businessobjects.IKImpl.setBestandsstatus(IKImpl.java:174)
at hvbg.svi.model.businessobjects.IKImpl.setAttrInvokeAccessor(IKImpl.java:770)
at oracle.jbo.server.EntityImpl.setAttribute(EntityImpl.java:859)
at oracle.jbo.server.ViewRowStorage.setAttributeValue(ViewRowStorage.java:1108)
at oracle.jbo.server.ViewRowStorage.setAttributeInternal(ViewRowStorage.java:1019)
at oracle.jbo.server.ViewRowImpl.setAttributeInternal(ViewRowImpl.java:1047)
at hvbg.svi.model.dataviews.IkViewRowImpl.setBestandsstatus(IkViewRowImpl.java:264)
at hvbg.svi.model.dienste.Aenderungsdienst.ausfuehrenAenderungsdienst(Aenderungsdienst.java:337)
at hvbg.svi.model.dienste.Aenderungsdienst.run(Aenderungsdienst.java:290)
Using run(), everything works perfectly.
The view object IKView consists of four entity objects which are linked by associations. There exists an association between the entity objects ik and inlandbankverb. The xml-file for the association object is named "ik_inlandsbankverb.xml". It seems so that this definition could not be found when calling my thread in asynchronous (via start()-method call) mode.
Is this a bug of JDeveloper?
Thanks in advance,
Stefan -
Exception in non-transactional EJB invoke:java.lang.NoSuchMethodError
Hello,
Iam facing with the following exception while deploying EJB's in Weblogic 5.1. The TX Datasource is setup properly and the application is running fine, when I have modified an existing EJB and while re-deploying, getting the following error:
Fri Jun 30 22:30:53 EST 2006:<I> <EJB JAR deployment ./lib/deployablePAM_EJB.jar> Exception in non-transactional EJB invoke:
java.lang.NoSuchMethodError
at com.bp.downstream.retail.au.pam.dsaf.ejb.site.SiteBeanHomeImpl.preFinderInvoke(SiteBeanHomeImpl.java:906)
at com.bp.downstream.retail.au.pam.dsaf.ejb.site.SiteBeanHomeImpl.findByGroupIdAgentFlag(SiteBeanHomeImpl.java:217)
at com.bp.downstream.retail.au.pam.dsaf.ejb.site.SiteBeanHomeImpl_ServiceStub.findByGroupIdAgentFlag(SiteBeanHomeImpl_Servi)
at com.bp.downstream.retail.au.pam.dsaf.dso.site.SiteDSOEjbImpl.getSitesByGroupIDAgentFlagWithMarkers(SiteDSOEjbImpl.java:9)
at com.bp.downstream.retail.au.pam.services.ejb.price.PriceBean.getGroupPrices(PriceBean.java:1366)
at com.bp.downstream.retail.au.pam.services.ejb.price.PriceBeanEOImpl.getGroupPrices(PriceBeanEOImpl.java:366)
at com.bp.downstream.retail.au.pam.services.serviceobject.GetGroupPrices.callService(GetGroupPrices.java:74)
at au.com.oakton.ecore.services.ServiceManager.callService(ServiceManager.java:47)
at au.com.oakton.ecore.request.RequestHandler.processRequest(RequestHandler.java:173)
at com.bp.downstream.retail.au.pam.serviceaccess.ServiceBean.invoke(ServiceBean.java:66)
at com.bp.downstream.retail.au.pam.control.PriceGroupAction.perform(PriceGroupAction.java:94)
at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1786)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1585)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:158)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1758)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:158)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1758)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:158)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1758)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:158)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1758)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
Please help me in understanding when we get such an exception.Hello All,
I am getting the 'Exception in non-transactional EJB invoke:java.lang.NoSuchMethodError', even if I have not made any modifications in the code. As and when I am re-deploying the deployablePAM_EJB.jar, and exception is raised. I am I missing out something here ?.
Please let me know. -
I've extended java.lang.Thread. How do I get WebLogic to use my version?
I want to add a String attribute to the thread class to save some extra info I need. I extended the Thread class with a private String with getter/setter methods.
Since WebLogic instantiates the threads and not my own code, how do I get WebLogic to use my version of Thread instead of the one from java.lang?
-BillI don't think it's possible to have WLS use your own thread implementation for WLS internals. However, for your own custom work, it's pretty straight-forward to use the CommonJ Work Manager API and add your own implementation details for a thread pool.
See documentation: http://download.oracle.com/docs/cd/E12839_01/web.1111/e13701/self_tuned.htm#i1069944
WorkManager Javadocs: http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e13941/index.html?commonj/work/WorkManager.html
Specifically providing your own Work interface implementation should hopefully allow you to meet your need.
Edited by: james.bayer on Feb 15, 2010 6:40 AM -
Hi Folks
I am trying to add MBean to show CPU consumption of various threads in my application.
The threads created during the course of the application execution are maintained in a vector list.
In my instrumentation code, I use this list of threads and
a) iterate over each Thread instance and get its thread id ( thread.getId() )
b) Using this long value, I determine the CPU consumption of this thread as :
ThreadMXBeanInstance. getThreadCpuTime(threadId)
However this does not seem to be giving me the correct value.
On debugging using a generic program, where I print the thread ID , name, CPU consumption of all the threads in the JVM, as :
ThreadMXBeanInstance.getAllThreadIds()
for( each ThreadInfo...)
//print attributes using ThreadInfo.getThreadName(..)..getThreadId(..)...etc..
the thread ID printed by ThreadInfo.getThreadId() seems to be always +1 + the threadID got as in (a))+.
Please let me know if you can throw some light on the above subject?
ps : I am using Java 6, u10 on a WINXP, SP2 + 2CPU Intel Core processor with 2 GHz & 2GB memory.
Great Thanks in advance.Hi,
Are you sure you haven't made a mistake somewhere?
Here is a small program that iterates over the threads and print their name and thread id has obtained from Thread and ThreadInfo. I've run it on JDK 6u10 and as you can see the information match. What do you get if you run it on your install? (hint: run it with -Dcom.sun.management.jmxremote to get the same results than I).
Here the program:
package threadid;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
* @author dfuchs
public class Main {
* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
final ThreadMXBean tmb = ManagementFactory.getThreadMXBean();
final Thread[] ts = new Thread[tmb.getThreadCount()];
ThreadGroup tg = Thread.currentThread().getThreadGroup();
while (tg.getParent()!=null) {
tg = tg.getParent();
tg.enumerate(ts,true);
for (Thread t : ts) {
if (t==null) continue;
final ThreadInfo ti = tmb.getThreadInfo(t.getId());
System.out.println(t.getName()+"[id="+t.getId()+"]: name=" +
ti.getThreadName()+", id="+ti.getThreadId());
}Here is the output:
Reference Handler[id=2]: name=Reference Handler, id=2
Finalizer[id=3]: name=Finalizer, id=3
Signal Dispatcher[id=4]: name=Signal Dispatcher, id=4
RMI TCP Accept-0[id=9]: name=RMI TCP Accept-0, id=9
main[id=1]: name=main, id=1Hope this helps,
-- daniel
[http://blogs.sun.com/jmxetc|http://blogs.sun.com/jmxetc] -
Java.lang.Thread.eetop
who knows what this field in Thread class for?
Whoops, spoke too soon...
In 1.4 it is used in the vm\memory\javaClass.cpp file.
The following comment explains it but doesn't seem to make it very clear in my mind.
// Note: JDK1.1 and before had a privateInfo_offset field which was used for the
// platform thread structure, and a eetop offset which was used for thread
// local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
// merged, so in the HotSpot VM we just use the eetop field for the thread
// instead of the privateInfo_offset.
.Guessing I would say that the real memory foot print for a Java Thread instance has the implementation specific thread data at a specific point. And that is the offset to that specific point.
For more information you would need to chase down the "JavaThread" item that is referred to in java_lang_Thread::thread(oop java_thread). -
Mandrake 7.2 Cannot find java/lang/Thread (8.1.5)
I have read all the old messages relating to this problem but I still cannot install 8.1.5
I have also read some of the pages written by jmsalvo and fortwayne all to no avail...
I downloaded glibc jre116v5 and jre117v3
Created symbolic link as per instructions
[ln -s /usr/jre116v5 /usr/local/jre]
I have tried setting CLASSPATH=/usr/local/jre/lib/rt.jar
and unsetting it..
I have even downloaded the JDK 116v5 and tried that as well with a 'rt.jat' symbolic link to the classes.zip
I have taken care to remove any other paths to exisiting java runtimes etc.. but still it wont play.. I am tering my hair out. I understand that versions 8.1.6 and 8.1.7 are less painful but my link is not fast enough to download them.
I am also running runIns.sh as oppossed to runInstaller.. but I keep getting the same error messages. Does anyone out there have any iedas.. I would be most grateful for any help
Thanks
lawrence
nullI have managed to get it working.. it needed JRE118v3..
thanks
lawrence (minus a few hairs) -
Does hp jvm support's java/lang/Threads
i need some info on this
yes it does.
For information on hp's jvm
http://www.zdnet.com/eweek/news/0316/19mhpjav.html
http://www.microsoft.com/unix/ie/techinfo/jvm/javahp.asp
http://www.javaworld.com/javaworld/jw-04-1998/jw-04-hp-jvm.html -
Could anyone tell me what usage of the Thread.dumpStack(); method?
I am looking the java api , and found one method in the Thread.
The method is public static void dumpStack().
and the api description is "Prints a stack trace of the current thread. This method is used only for debugging. " .
is there anyone to tell me exactly on what situation the method is used.
it's better that there is a sample to show that.
i have write a sample program. as following , but i still don't exactly understand the usage of this method.
code:
public class ThreadDumpStack {
public ThreadDumpStack() {
public static void main(String[] args) {
ThreadDumpStack threadDumpStack1 = new ThreadDumpStack();
System.out.println(threadDumpStack1.hello());
Thread.currentThread().dumpStack();
System.out.println(threadDumpStack1.string());
public int hello () {
int i = 10;
int j =10;
return i+j;
public String string() {
String a = "hello";
String b ="world";
return a + " " + b;
result:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1071)
at api.ThreadDumpStack.main(ThreadDumpStack.java:21)
20
hello worldIt is for when you have got a large complex application, which is not working (as in running, but returning the wrong value, or getting into an ever lasting loop). You can then use this to work out what your application is doing.
Maybe you are looking for
-
I tried to use iCloud to restore but she never set up iCloud. I tried to wipe it with find my iPhone but she never set that up. I put the iPod into recovery mode and connected it to an iTunes account on a different computer but it does not pick up th
-
Installing spam assassin on solaris 9
I'm getting "optional module missing" message while installing the spam assassin. And I had so much trouble installing any module perl module on solaris. Maybe someone here knows an easy way to install spam assassin on solaris.
-
I have just purchased Adobe Acrobat XI Pro down loaded id and followed the intstall instructiions but when I go to use it I get the following message "Serial Number you provided is valid but a qualifying product could not be found on this computer"
-
can my phones contacts, messages etc be linked with another phone if our apple ids are different??
-
Class Action Lawsuit Against CreativeLabs and X-FI - mayb
I have been thinking about buying a sound card that is certified for windows vista. However after seeing so many unsatisfied and angry people, no way I'm buying anything for now. So many people complain about issues with drivers and windows vista; I