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 PM
that 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.
Similar Messages
-
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. -
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 -
Error in PI mapping "nested exception is: java.lang.OutOfMemoryError "
Hi Experts ,
I encounter an error in the PI mapping while calling a Java Mapping (Mercator Map)
Error Message as ::-
java.lang.RuntimeException: RemoteException in setMercGeneral: Error occurred in server thread; nested exception is: java.lang.OutOfMemoryError at com.philips.xi.mercator.MercatorCall.execute(MercatorCall.java:90) at
Could anyone suggest , how we can overcome this error message
I have also tried to restart the RMI Server , but that was not not helpful.
Regards,
ShwetaSweta,
Is this a java mapping or Graphical, If Java, you should not run into this issue as you dont load the nested XSD`s.
Also the error message indicates outofMemory in mercator side when posting your Large message.
java.lang.OutOfMemoryError at com.philips.xi.mercator.MercatorCall.execute(MercatorCall.java:90) at
Regards
Ravi Raman
Edited by: Ravi Raman on Jun 30, 2010 4:26 PM -
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Hello everyone ... sorry for my English but I am an Italian boy with a problem that is not answered.
I had to create a web application-service (created in Java with NetBeans 6.7) which is connected to a database postgresql (8.3.5) and for connection to the server using tomcat (3.2.4) through SOAP messages (2_2).
OPERATING SYSTEM: WINXP
I have created classes ... I created the database ... completed the project in NetBeans without any errors ... implemented the necessary libraries in the project (also ).... 8.3.604.jar jdbc tomcat configured and soap ... .. and set the environment variables (soap, mail, send in xerces )...... run the application on the NetBeans appears the login screen of my web service .....
enter username and password (exactly!) and the NetBeans gives me an Exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Intro.loginActionPerformed(Intro.java:522)
at Intro.access$100(Intro.java:21)
at Intro$2.actionPerformed(Intro.java:111)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
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)
Java Result: 1
BUILD SUCCESSFUL (total time: 31 seconds) The line 522 Intro class is as follows:
private void loginActionPerformed(java.awt.event.ActionEvent evt) {
try {
URL address= new URL("http://"+ip+":8080/soap/servlet/rpcrouter");
//Costruzione della chiamata
Call chiamata = new Call();
chiamata.setTargetObjectURI("urn:server");
chiamata.setMethodName("controllaAgenzia");
chiamata.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
//creazione parametri che dovro' passare al soap
Vector<Parameter> params = new Vector<Parameter>();
String u = user.getText();
String p = String.valueOf(password.getPassword());
params.addElement(new Parameter("user", String.class, u, null));
params.addElement(new Parameter("password", String.class, p, null));
chiamata.setParams(params);//parametri passati al soap
try {
//Invocazione RPC
Response respons = chiamata.invoke(address, "");
//qui ho la risposta inviata dal server
*Parameter par = respons.getReturnValue();*
Object value = par.getValue();
String REP = String.valueOf(value);
System.out.println(REP);
if (REP.equals("ACK_agenzia")) {
new MainAgenzia(ip);
this.dispose();
} else if (REP.equals("NACK_agenzia")) {
JOptionPane.showMessageDialog(null, "I dati inseriti non sono corretti", "Errore", JOptionPane.ERROR_MESSAGE);
password.setText("");
user.setText("");
} The strange thing is that this web service was running just finished the project.
After 4-5 days of its operation has stopped, creandomi this problem.
I think the answer is, the server that is not the case.
I thought all I thought was jdbc, but I can connect to the database, so I do not know what to do and how to proceed.
thanks to all, and thanks to my translator. :PParameter par = respons.getReturnValue();There is only one possible reason, "respons" is null.
-
Exception JComboox :Exception in thread "AWT-EventQueue-0" java.lang.NullPo
Hi, I mapped a vector object to the JComboBox. I'm using the observer pattern to update the ComboBox box whenever there is an message receives.If an update is received I just add the data to the vector and to refresh the ComboBox bu calling the UpdateUI() method. When more updates received same time i'm getting the following exception.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1059)
at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:850)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Please assist me in fixing this issue if anyone came across this issue.
Thanks.I just add the data to the vector and to refresh the ComboBox bu calling the UpdateUI() methodYou should NOT be updating the vector.
That is NOT what the updateUI() method is used for.
The proper way to update a component is to udate the MODEL The model will then notify the VIEW so it can repaint itself. Also, make sure the code is executed on the EDT. Read the section from the Swing tutorial on Concurrency. -
Why Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException?
Hello,
In my netbeans generated swing code I get the following stacktrace:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.text.PlainView.updateMetrics(PlainView.java:188)
at javax.swing.text.PlainView.lineToRect(PlainView.java:589)
at javax.swing.text.PlainView.modelToView(PlainView.java:327)
at javax.swing.text.FieldView.modelToView(FieldView.java:248)
at javax.swing.plaf.basic.BasicTextUI$RootView.modelToView(BasicTextUI.java:1498)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1036)
at javax.swing.text.DefaultCaret.repaintNewCaret(DefaultCaret.java:1291)
at javax.swing.text.DefaultCaret$1.run(DefaultCaret.java:1270)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)The code is @ http://code.google.com/p/memorizeasy/source/browse/trunk/MemorizEasy/src/com/mysimpatico/memorizeasy/engine/executables/Input.javaSo the problem is given by these two lines, of the Swing-X library:
AutoCompleteDecorator.decorate(expField, exps, false);
AutoCompleteDecorator.decorate(defField, exps, false);
However, the functionality intended from them is given. The problem now seems to do with expField.setText() and expField.selectAll(). I've inline initialized expField, and now it works.
* To change this template, choose Tools | Templates
* and open the template in the editor.
* Input1.java
* Created on Feb 21, 2010, 11:56:00 AM
import java.util.ArrayList;
import javax.swing.*;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
public class Input1 extends javax.swing.JFrame {
private static final long serialVersionUID = 2819528413930929081L;
private static final ArrayList<String> exps = new ArrayList<String>();//Database.getAllExps();
private static final Input1 instance = new Input1();
/* private void defFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_defFieldFocusGained
defField.selectAll();
}//GEN-LAST:event_defFieldFocusGained
private void expFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_expFieldActionPerformed
final String exp = expField.getText();
/* if (defField.isVisible() && exp != null && exps.contains(exp)){
status.setText("to change the spelling select Spelling from the Edit Menu.");
else if (!defField.isVisible()){ //in spelling mode
Database.editExpression(exSpell, exp);
status.setText("spelling for " + exSpell + " changed to " + exp);
defField.setVisible(true);
spellingMenuItem.setEnabled(false);
}//GEN-LAST:event_expFieldActionPerformed
private void initComponents() {
contentPanel = new javax.swing.JPanel();
expField = new javax.swing.JTextField();
expField.setText("expression");
/* expField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
expFieldActionPerformed(evt);
expField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
expFieldFocusGained(evt);
defField.setText("definition");
defField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
defFieldActionPerformed(evt);
defField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
defFieldFocusGained(evt);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
contentPanel.add(expField);
expField.setVisible(true);
this.setContentPane(contentPanel);
pack();
}// </editor-fold>
/** Creates new form Input1 */
private Input1() {
initComponents();
AutoCompleteDecorator.decorate(expField, exps, false);
private void expFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_expFieldFocusGained
expField.selectAll();
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
instance.setVisible(true);
// Variables declaration - do not modify
private javax.swing.JPanel contentPanel;
private javax.swing.JTextField expField;
// End of variables declaration
}Edited by: simpatico_gabriele on Mar 11, 2010 8:09 PM -
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError:
hi,
i have to build similar sql query analizer. i am using jdbc and swing.
my frame contains jtable and jtree. jtree contains schemas and tables.
Jtables show mysql table data, when user choose table in Jtree.
its run first click and second.... But after a few click its doesnt run and i get this Exception:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.Buffer.getBytes(Buffer.java:198)
at com.mysql.jdbc.Buffer.readLenByteArray(Buffer.java:318)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1345)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2330)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:427)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2035)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1421)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1772)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2430)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2359)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1227)
at Database.getQueryRs(Database.java:50)
at Database.getColumnNames(Database.java:30)
at NewJFrame.tableDegis(NewJFrame.java:221)
at NewJFrame.jTree1ValueChanged(NewJFrame.java:196)
at NewJFrame.access$000(NewJFrame.java:21)
at NewJFrame$1.valueChanged(NewJFrame.java:93)
at javax.swing.JTree.fireValueChanged(JTree.java:2825)
at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3196)
at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
at javax.swing.JTree.setSelectionPath(JTree.java:1600)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2410)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3619)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3558)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
at java.awt.Component.processMouseEvent(Component.java:6035)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {
try{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
jTree1.getLastSelectedPathComponent();
if (node == null) return;
if (node.isLeaf()) {
if(node.getLevel() > 1){
System.out.println(node.getParent());
tableDegis(node.getParent().toString(),node.toString());
} else {
}catch(Exception e){
private void tableDegis(String schema,String table){
DefaultTableModel tablemodel = new DefaultTableModel();
tablemodel.setDataVector(db.getData(schema,table),db.getColumnNames(schema,table));
jTable1.setModel(tablemodel);
System.out.println(db.getColumnNames(schema,table));
System.gc();
public Vector getColumnNames(String schemaName,String tableName){
Vector<String> columnNames = new Vector<String>();
try{
ResultSet rs = getQueryRs(schemaName,tableName);
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement( md.getColumnName(i) );
}catch(Exception e){}
System.gc();
return columnNames;
public ResultSet getQueryRs(String schemaName,String tableName){
ResultSet rs = null;
try{
String sql = "Select * from "+tableName;
connection.setCatalog(schemaName);
Statement stmt3 = connection.createStatement();
rs = stmt3.executeQuery( sql );
}catch(Exception e){
System.gc();
return rs;
public Vector getData(String schemaName,String tableName){
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
try{
ResultSet rs = getQueryRs(schemaName,tableName);
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
while (rs.next()){
Vector<Object> row = new Vector<Object>(columns);
for (int i = 1; i <= columns; i++){
row.addElement( rs.getObject(i) );
data.addElement( row );
}catch(Exception e){}
System.gc();
return data;
}lokesh_Kumar_Singh
Welcome to the forum. Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
I'm locking this thread now. It's more than 1½ years old.
db -
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:
Could anyone please explain me what is this error about
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.Integer
at timetablegen.MainFrame.jButton17ActionPerformed(MainFrame.java:1816)
at timetablegen.MainFrame.access$2100(MainFrame.java:16)
at timetablegen.MainFrame$23.actionPerformed(MainFrame.java:1136)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I am taking an object from jComboBox as a String and then converting it to integer & adding to the database.
It is not getting added in database to & throwing above exception.Hello,
First parse the string taken from combo box using Integer.parseInt(str), not directly cast it to Integer.
Regards -
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 -
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
Hi gurus,
I am using mouse event in oracle forms 10g.I am getting following error in java console when loading java applet.I am using java plugin 1.6.0_29-b02.Oracle forms version is 10.1.2.0.Kindly give me solution to overcome this.
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
Loaded image: jar:http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/frmall.jar!/oracle/forms/icons/oracle_logo.gif
Loaded image: http://trl1th6m8k34j.trafford.ford.com:8889/forms/yes
proxyHost=null
proxyPort=0
connectMode=HTTP, native.
Forms Applet version is : 10.1.2.0
Loaded image: jar:http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/frmall.jar!/oracle/forms/icons/frame.gif
Trace level set to 5: all ... completed.
network: Cache entry not found [url: http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.class, version: null]
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.class with proxy=DIRECT
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/ with proxy=DIRECT
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.class with cookie "AFRSOComplete2011=1; WSL-credential=TZGxuU2SPlkBAPIABHVzZXJpZD1tdmlub2QAaXBhZGRyPTE5LjE1MS4xNTQuODQAYWNpZ3JvdXA9Tk9OT1ZWTQBkZXB0PTUwMDFGODlENTQAb3JnY29kZT0/AGVtcGNvZGU9RgBtcnJvbGU9TgBvcmc9QVBBAGNvbXBhbnk9Rk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAGRpdmFiYnI9QVBBAHNpdGVjb2RlPTc1MjQAY2l0eT1DSEVOTkFJAHN0YXRlPT8AY291bnRyeT1JTkQAc3ViamVjdGlkPW12aW5vZEBmb3JkLmNvbQAAAENOPXdzbHY0LWludGVybmFsAKgKrgQwd9XHGJmWswb3374C3ITXa8zKKOrGTmAp81O3ud1qjAsiquyL112PSA7FPHknAfBpgpkpCWa5AA3+3Gy906j/qh6cna01esWGot27Tf6TXQEJvxKiY81H/Hhx8xGzApYE6iEFR1g6eUjvRP1QZJhgaJw6dPfFlrxJmF6q; Ford-WSL-MIG=TZGxuU2SPllwcm9mc3B3MkB3ZWJmYXJtLmRlYXJib3JuLmZvcmQuY29tAG12aW5vZAAxOS4xNTEuMTU0Ljg0AE5PTk9WVk0ANTAwMUY4OUQ1NAA/AEYATgBBUEEARk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAEFQQQA3NTI0AENIRU5OQUkAPwBJTkQATlVMTC5jZW50b2tzAACvVWxUpXzzdrT6KgM5tvDc1l3mGobUxj+eOvcIt2JL3LQOyr0rnYQV1oFVkPFd7GOBoUzqgqr0Zd4Ta7KXVLIj"
network: Cache entry not found [url: http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.properties, version: null]
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.properties with proxy=DIRECT
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/java/oracle/ewt/alert/resource/AlertBundle_en_GB.properties with cookie "AFRSOComplete2011=1; WSL-credential=TZGxuU2SPlkBAPIABHVzZXJpZD1tdmlub2QAaXBhZGRyPTE5LjE1MS4xNTQuODQAYWNpZ3JvdXA9Tk9OT1ZWTQBkZXB0PTUwMDFGODlENTQAb3JnY29kZT0/AGVtcGNvZGU9RgBtcnJvbGU9TgBvcmc9QVBBAGNvbXBhbnk9Rk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAGRpdmFiYnI9QVBBAHNpdGVjb2RlPTc1MjQAY2l0eT1DSEVOTkFJAHN0YXRlPT8AY291bnRyeT1JTkQAc3ViamVjdGlkPW12aW5vZEBmb3JkLmNvbQAAAENOPXdzbHY0LWludGVybmFsAKgKrgQwd9XHGJmWswb3374C3ITXa8zKKOrGTmAp81O3ud1qjAsiquyL112PSA7FPHknAfBpgpkpCWa5AA3+3Gy906j/qh6cna01esWGot27Tf6TXQEJvxKiY81H/Hhx8xGzApYE6iEFR1g6eUjvRP1QZJhgaJw6dPfFlrxJmF6q; Ford-WSL-MIG=TZGxuU2SPllwcm9mc3B3MkB3ZWJmYXJtLmRlYXJib3JuLmZvcmQuY29tAG12aW5vZAAxOS4xNTEuMTU0Ljg0AE5PTk9WVk0ANTAwMUY4OUQ1NAA/AEYATgBBUEEARk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAEFQQQA3NTI0AENIRU5OQUkAPwBJTkQATlVMTC5jZW50b2tzAACvVWxUpXzzdrT6KgM5tvDc1l3mGobUxj+eOvcIt2JL3LQOyr0rnYQV1oFVkPFd7GOBoUzqgqr0Zd4Ta7KXVLIj"
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/lservlet;jsessionid=13979a5422b982f5c03763394a95824eb74a032e698e with proxy=DIRECT
network: Connecting http://trl1th6m8k34j.trafford.ford.com:8889/forms/lservlet;jsessionid=13979a5422b982f5c03763394a95824eb74a032e698e with cookie "AFRSOComplete2011=1; WSL-credential=TZGxuU2SPlkBAPIABHVzZXJpZD1tdmlub2QAaXBhZGRyPTE5LjE1MS4xNTQuODQAYWNpZ3JvdXA9Tk9OT1ZWTQBkZXB0PTUwMDFGODlENTQAb3JnY29kZT0/AGVtcGNvZGU9RgBtcnJvbGU9TgBvcmc9QVBBAGNvbXBhbnk9Rk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAGRpdmFiYnI9QVBBAHNpdGVjb2RlPTc1MjQAY2l0eT1DSEVOTkFJAHN0YXRlPT8AY291bnRyeT1JTkQAc3ViamVjdGlkPW12aW5vZEBmb3JkLmNvbQAAAENOPXdzbHY0LWludGVybmFsAKgKrgQwd9XHGJmWswb3374C3ITXa8zKKOrGTmAp81O3ud1qjAsiquyL112PSA7FPHknAfBpgpkpCWa5AA3+3Gy906j/qh6cna01esWGot27Tf6TXQEJvxKiY81H/Hhx8xGzApYE6iEFR1g6eUjvRP1QZJhgaJw6dPfFlrxJmF6q; Ford-WSL-MIG=TZGxuU2SPllwcm9mc3B3MkB3ZWJmYXJtLmRlYXJib3JuLmZvcmQuY29tAG12aW5vZAAxOS4xNTEuMTU0Ljg0AE5PTk9WVk0ANTAwMUY4OUQ1NAA/AEYATgBBUEEARk9SRC5CVVNJTkVTUy5TRVJWSUNFUy4tLklORElBAEFQQQA3NTI0AENIRU5OQUkAPwBJTkQATlVMTC5jZW50b2tzAACvVWxUpXzzdrT6KgM5tvDc1l3mGobUxj+eOvcIt2JL3LQOyr0rnYQV1oFVkPFd7GOBoUzqgqr0Zd4Ta7KXVLIj"
basic: Applet started
basic: Told clients applet is started
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at oracle.forms.fd.HandleMouseEvent2.handleComponent(HandleMouseEvent2.java:312)
at oracle.forms.fd.HandleMouseEvent2.access$6000171(HandleMouseEvent2.java:39)
at oracle.forms.fd.HandleMouseEvent2$2.mouseEntered(HandleMouseEvent2.java:139)
at java.awt.AWTEventMulticaster.mouseEntered(Unknown Source)
at java.awt.AWTEventMulticaster.mouseEntered(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider.processMouseGrabs(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._redispatchEvent(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._checkTarget(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._checkTarget(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp.mouseEntered(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEventImpl(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Proxy.processEventImpl(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at oracle.forms.fd.HandleMouseEvent2.handleComponent(HandleMouseEvent2.java:312)
at oracle.forms.fd.HandleMouseEvent2.access$6000171(HandleMouseEvent2.java:39)
at oracle.forms.fd.HandleMouseEvent2$2.mouseExited(HandleMouseEvent2.java:135)
at java.awt.AWTEventMulticaster.mouseExited(Unknown Source)
at java.awt.AWTEventMulticaster.mouseExited(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider.processMouseGrabs(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._redispatchEvent(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._redispatchEvent(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._checkTarget(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp._checkTarget(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Disp.mouseExited(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEventImpl(Unknown Source)
at oracle.ewt.event.tracking.GlassMouseGrabProvider$Proxy.processEventImpl(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)You need to initialize your array:
double [][] expLevels = new double[10][10]; // whatever size.For an array of 'double', all values will be initialized to 0.
It appears that the size of your array can't be known until runtime. You could maybe use an ArrayList of ArrayList of Double objects. Or, if you do know the size (if array_string will have a fixed format), you could use that size. -
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 -
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,
asjfwhat'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 -
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 -
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
Maybe you are looking for
-
Error -3254 when trying to download a video
I am on ITunes 8 and in the Itunes Store. I purchase a Movie. It appears in the Download directory under Store. When I try to download I get the error message "unknown error -3254" "please check that connection is active". My internet connection is f
-
ITunes can't sync my iPhone 4 because the Apple Mobile Device Service is not started.
I tried syncing my iPhone 4 today and it brought up this message saying: This iPhone cannot be used because the Apple Mobile Device Service is not started,,,,,,Have no clue what this means or what to do,,,,,Have had this phone since March and the las
-
Can I copy a spreadsheet from Numbers into the body of an email message?
I created a basic calendar originally in Excel and have moved to Numbers. When I copy the Numbers spreadsheet calendar to the body of an email message, it loses all borders and formats and looks like a word salad. I need to paste it into the email me
-
How do we create a vendor using portal?
how do we create a vendor using portal. creation process needs to trigger workflow. Sonali
-
TES v6.1 Job.Insert using name or alias
hello, The following XML work fine when I use job id 166. I tested it on http://localhost:8080/api/tes-6.0/postscreen . <?xml version="1.0" encoding="UTF-8"?> <entry xmlns="http://purl.org/atom/ns#"> <id>12</id> <tes:Job.insert xmlns:tes="http://www.