Exception... (Unknown Source)
Greetings,
I would like to know why is that when I got an exception, in the trace description output, sometimes it outputs the Unknown Source text where it should appears the java source class and line number!? But the strange here, is that it only happens in my own classes. So, what I must do to my code could also be traced?
For example, the code below, my classes are the ones inside the package PT:
java.lang.NullPointerException
at PT.ptinovacao.locawa.servlet.LocationFinder.convertSOAPBodyToDOM(Unknown Source)
at PT.ptinovacao.locawa.servlet.LocationFinder.onMessage(Unknown Source)
at javax.xml.messaging.JAXMServlet.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...thanks,
Pedro Salazar.
Compile with the debug flag on. -g for javac. For ant
add the attribute debug="true" to the javac task.Yes, I did that. Also, I put the debuglevel to "source". And it stills not printing the source class and line number!
For more information, I'm using remote debug (jdb) which I attach to a tomcat server.
BTW, I'm wondering about that command "use", shouldn't I use it to specify my sources? I tried but it didn't worked... (don't know if I use it well).
thanks,
Pedro Salazar.
Similar Messages
-
Java exception - unknown source - why???
Hi all,
I am running a web application on oc4j and I am getting a servlet exception.
In the classes I wrote, in the stack trace it says "unknown source" where the line number is supposed to be. But for classes that I did not write (servlet container's, and third party api's), the line numbers are there.
Can anyone help?
Is there a compilation option to disable or enable reporting of line numbers?
Or might it be something to do with oc4j?Hi all,
I am running a web application on oc4j and I am
getting a servlet exception.
In the classes I wrote, in the stack trace it says
"unknown source" where the line number is supposed to
be. But for classes that I did not write (servlet
container's, and third party api's), the line numbers
are there.
Can anyone help?
Is there a compilation option to disable or enable
reporting of line numbers?Yes.
javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info -
Exception with (Unknown Source), possible to specify source file?
Hi, I'm getting exceptions of the kind
java.lang.NullPointerException
at blockworld.EnvView.paintComponent(Unknown Source)The class EnvView is loaded from a .jar at runtime (it's a plugin-like construction). Is it possible to tell the VM where my source files are so that it shows at what file/line nr this exception occurred? Or do I need to compile the .jar in a special way to include such information?
Thanks!I have the same question. However, I think the problem is not related to the IDE. I am having the same output with a webapp.
Tomcat console does not show me the source line number of the exception. Is the re any way to link the WAR file to the actual source code?
2006-06-19 17:40:11,640 [http8080-Processor25] ERROR mx.org.ifai.persona.proxy.BusinessProxy - updateTransmisionVigencia: Exception!!
java.lang.NullPointerException
at mx.org.ifai.persona.helper.transmisiones.HelperTransmision.sendEmailToDestinatario(Unknown Source)
at mx.org.ifai.persona.proxy.BusinessProxy.updateTransmisionVigencia(Unknown Source)
at mx.org.ifai.persona.action.transmisiones.DispatchTransmisionMgr.terminarPorSistema(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Any help will be appreciated. -
Compiling with ant--getting 'Unknown Source' in my exceptions
I am compiling using this ant stanza:
<property name="src" value="src"/>
<property name="resources" value="src/resources"/>
<property name="target" value="target"/>
<target name="compile">
<javac sourcepath="" srcdir="${src}"
destdir="${target}" compiler="javac1.5" debuglevel="lines,source">
<include name="**/*.java"/>
</javac>
<copy todir="${target}/resources">
<fileset dir="${resources}"/>
</copy>
</target> Note the debuglevel="lines,source" specification. But I'm still getting 'Unknown Source' in exceptions in this code. Yes, I've done a clean compile. Yes, I checked, and it's recreating the files and the jars. I'm reasonably sure there aren't any other build.xml files I could be running.
I don't see why this wouldn't work.I have the same problem. Even If I have something like this.
<javac debug="on" debuglevel="lines,vars,source" ... /> -
Getting Unknown Source Error While Deploying the Planning Application
Hi,
Getting following error while trying to Deploy Planning Application from BPMA
Started Time : Tuesday, January 08, 2008 5:43:40 PM
Submitted Time : Tuesday, January 08, 2008 5:43:40 PM
Last Updated Time : Tuesday, January 08, 2008 5:44:32 PM
User Name : hpadmin
Process Name :
Thread : 0
Server : DimServer
Detail : App Creation failed with Exceptionjava.lang.RuntimeException: Exception occurred while creating the application. Check log for details at com.hyperion.planning.appdeploy.HspAppDefinition.deployAppFromXML(Unknown Source) at com.hyperion.planning.appdeploy.HspAppDefinition.access$000(Unknown Source) at com.hyperion.planning.appdeploy.HspAppDefinition$1.run(Unknown Source)Hi,
I am getting the same error:-
Started Time : Tuesday, February 26, 2008 4:14:31 PM
Submitted Time : Tuesday, February 26, 2008 4:14:31 PM
Last Updated Time : Tuesday, February 26, 2008 4:15:39 PM
User Name : hpadmin
Process Name :
Thread : 0
Server : DimServer
Detail : App Creation failed with Exceptionjava.lang.RuntimeException: Exception occurred while creating the application. Check log for details at com.hyperion.planning.appdeploy.HspAppDefinition.deployAppFromXML(Unknown Source) at com.hyperion.planning.appdeploy.HspAppDefinition.access$000(Unknown Source) at com.hyperion.planning.appdeploy.HspAppDefinition$1.run(Unknown Source)
1---Have created new user for new App as well datasource
2-Bounced the EPMA as well planning server but no avail.
how I can I get detail log ? or if is it possible to tell me which directory to look into
thanks in advance
Sanjay -
RMI: Unknown source problem with connection & security
When I try to run the RMI server code, after I have granted all permissions in my policy, after compiling through RMIC generating my stub and skeleton classes, and finally after running the RMI registry, I receive an error. The error that I have been getting is pasted below. I have searched through several java forums trying to find an answer and have not found one. If you recognized this error, please let me know if you have suggestions. Thanks.
TestRmiServer exception: access denied (java.net.SocketPermission 192.168.0.152:
1099 connect,resolve) //note: I'm using the default RMI port
java.security.AccessControlException: access denied (java.net.SocketPermission 1
92.168.0.152:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at irad.nmi.services.util.testRmi.TestRmiServer.main(TestRmiServer.java:
64)
Anyway, a response would be welcome. Thanks.look at thread :
http://forum.java.sun.com/thread.jspa?threadID=597299&tstart=0
most likely you did not specify the -Djava.security.policy property properly. -
Replace Unknown Source in EcmaError (JSR223) with actual file name
Hopefully someone here knows how to do this:
In my code, all of the scripts are contained in .js files. Whenever one of the scripts contains an error, I get this:
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "nonexistant" is not defined. (<Unknown source>#5) in <Unknown source> at line number 5
What bugs me is the <Unknown Source>. Multiple files are in one ScriptContext, and it can be hard to track down an error. It also looks horrible.
Is there a way to replace <Unknown Source> with the actual file name? None of the methods I see support passing a File object, so I'm really confused here.
Cross posted (and unanswered) at:
http://stackoverflow.com/questions/2885120/replace-unknown-source-in-java-rhino-jsr223-with-actual-file-name
http://www.javaprogrammingforums.com/exceptions/4465-replace-unknown-source-ecmaerror-jsr223-actual-file-name.html
http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino
http://mozilla-xp.com/mozilla.dev.tech.js-engine.rhino/Replace-Unknown-Source-with-Script-file-nameYou may need to set compile debug option set to true.
I am not sure if my tip is useful for you, anyway good luck. -
Sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
Hi Avi,
Refer the earlier message below::
Now I have OC4J version 9.0.2.
The JDK version is Java(TM) 2 SDK, Standard Edition Version 1.3.1
OS : Solaris
I am trying to deploy the "How-To" example from the otn sample examples for JSP. It's a implementation of simple iterator tag. When I try to access the JSp page which has the taglib, it gives me the following error.
Can u tell me what this error is ????
500 Internal Server Error
OracleJSP:
JSP Error:
Request URI:/iterate/iterateSample.jsp
Exception:
java.lang.NullPointerException
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at oracle.jsp.parse.JspUtils.loadClassJDK(JspUtils.java:219)
at oracle.jsp.parse.JspUtils.loadClass(JspUtils.java:209)
at oracle.jsp.parse.JspRTTag.(JspRTTag.java:102)
at oracle.jsp.parse.JspParseState.createTagParser(JspParseState.java:410)
at oracle.jsp.parse.JspParseTag.parseNextTag(JspParseTag.java:538)
at oracle.jsp.parse.JspParseTagFile.parse(JspParseTagFile.java:160)
at oracle.jsp.parse.OracleJsp2Java.transform(OracleJsp2Java.java:40)
at oracle.jsp.runtimev2.JspPageCompiler.attemptCompilePage(JspPageCompiler.java:295)
at oracle.jsp.runtimev2.JspPageCompiler.compilePage(JspPageCompiler.java:181)
at oracle.jsp.runtimev2.JspPageInfo.compileAndLoad(JspPageInfo.java:338)
at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:481)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:255)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:407)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:696)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:281)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:735)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
Hi,
I developed a component using struts framework and deployed it in TOMCAT. It works fine. Now I am trying to deploy it in OC4J. I get the following error when I try to access the JSP. Can anybody tell me what this error is and how to resolve it?
java.lang.NullPointerException
at java.lang.String.startsWith(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.TagLibraryStorage.getTagLibContext(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpServer.getTagLibContext(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpApplication.getTagLibContext(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.JSPPageCompilation.addTagLibTag(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.JSPPageCompilation.compile(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.JSPPage.compile(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpApplication.getJSP(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpApplication.serviceJSP(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.JSPServlet.service(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpRequestHandler.processRequest(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpRequestHandler.run(Compiled Code)
at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].util.ThreadPoolThread.run(Compiled Code)
With Regards
Amit Kapoor
Title : re:OC4J Null Pointer Exception O/S : Solaris POST: REPLY (W/QUOTE)
Author : Amit Kapoor Type : Statement
Date : Jul 25, 2002 03:26 PT
The version of the OC4J is 1.0.2.2.1
Title : re:OC4J Null Pointer Exception O/S : Solaris POST: REPLY (W/QUOTE)
Author : Avi Abrami Type : Question
Date : Jul 25, 2002 03:31 PT
Hi Amit,
For starters, you are using an old version (1.0.2.2.1) of OC4J.
You can download newer versions from this web page:
http://technet.oracle.com/tech/java/oc4j/content.html
That page also has links to documentation, "how-to" documents and
sample code. Note that you also need to use compatible versions
of java.
Personally, I am using OC4J version 9.0.2.0.0 on SUN Solaris 7
with JDK 1.3.1 (also from SUN).
Also, (and if you don't already know about them) the following web
sites may also be useful to you:
http://www.orionserver.com
http://www.orionsupport.com
http://www.atlassian.com
http://www.elephantwalker.com
Good Luck,
Avi.Sorry Amit,
I have absolutely no idea. However, have you tried these other two
forums:
Technologies > Java > Java Server Pages (JSP)
http://forums.oracle.com/forums/forum.jsp?id=399160
Technologies > Other > Sample Code
http://forums.oracle.com/forums/forum.jsp?id=428078
Hope it helps.
Good Luck,
Avi. -
When I tried this servlet example apache-tomcat-5.5.17 using java version "1.5.0_07"
javax.servlet.ServletException: Servlet execution threw an exception
root cause
javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
XML2HTMLServlet.openFile(XML2HTMLServlet.java:31)
XML2HTMLServlet.doGet(XML2HTMLServlet.java:19)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
// XML2HTMLServlet.java
//http://forum.java.sun.com/thread.jspa?forumID=34&threadID=260273
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class XML2HTMLServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
try {
openFile("file:/apps/tomcat/apache-tomcat-5.5.17/webapps/xml/financials.xml", "file:/apps/tomcat/apache-tomcat-5.5.17/webapps/xml/financials.xsl", writer);
} catch (Exception e) {
e.printStackTrace(writer);
private void openFile(String xmlPath, String xslPath, PrintWriter writer)
throws IOException, ParserConfigurationException, SAXException,
TransformerConfigurationException, TransformerException {
File xmlFile = new File(xmlPath);
File xslFile = new File(xslPath);
TransformerFactory tFact = TransformerFactory.newInstance();
DocumentBuilderFactory dbFact = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbFact.newDocumentBuilder();
Document xmlDoc = builder.parse(xmlFile);
Document xslDoc = builder.parse(xslFile);
Node xmlDocNode = (Node)xmlDoc;
Node xslDocNode = (Node)xslDoc;
DOMSource xmlSrc = new DOMSource(xmlDocNode);
DOMSource xslSrc = new DOMSource(xslDocNode);
DOMResult htmlResult = new DOMResult();
Transformer transformer = tFact.newTransformer(xslSrc); // the exception occurs here!
}Setting the proerty work now , I get no display, just a
When I tried this servlet example
apache-tomcat-5.5.17 using java version "1.5.0_07"
javax.servlet.ServletException: Servlet execution
threw an exception
root cause
javax.xml.transform.TransformerFactoryConfigurationErr
or: Provider
org.apache.xalan.processor.TransformerFactoryImpl not
found
javax.xml.transform.TransformerFactory.newInstance(Un
known Source)
XML2HTMLServlet.openFile(XML2HTMLServlet.java:31)
XML2HTMLServlet.doGet(XML2HTMLServlet.java:19)
javax.servlet.http.HttpServlet.service(HttpServlet.ja
va:689)
javax.servlet.http.HttpServlet.service(HttpServlet.ja
va:802)
// XML2HTMLServlet.java
//http://forum.java.sun.com/thread.jspa?forumID=34&thr
eadID=260273
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class XML2HTMLServlet extends HttpServlet {
System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
try {
penFile("file:/apps/tomcat/apache-tomcat-5.5.17/webapp
s/xml/financials.xml",
"file:/apps/tomcat/apache-tomcat-5.5.17/webapps/xml/fi
nancials.xsl", writer);
} catch (Exception e) {
e.printStackTrace(writer);
private void openFile(String xmlPath, String
xslPath, PrintWriter writer)
throws IOException,
ParserConfigurationException, SAXException,
TransformerConfigurationException,
TransformerException {
File xmlFile = new File(xmlPath);
File xslFile = new File(xslPath);
TransformerFactory tFact =
TransformerFactory.newInstance();
DocumentBuilderFactory dbFact =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder =
dbFact.newDocumentBuilder();
Document xmlDoc =
builder.parse(xmlFile);
Document xslDoc =
builder.parse(xslFile);
Node xmlDocNode = (Node)xmlDoc;
Node xslDocNode = (Node)xslDoc;
DOMSource xmlSrc = new
DOMSource(xmlDocNode);
DOMSource xslSrc = new
DOMSource(xslDocNode);
DOMResult htmlResult = new
DOMResult();
Transformer transformer =
tFact.newTransformer(xslSrc); // the exception
occurs here! -
I've deployed my app onto iWS 6.0, when an Exception is thrown, the stack trace is displayed but it doesnt supply the line numbers where the exception occurred. Instead it says Unknown Source. how can I fix this, or get round this problem?
Check if your IDE is adding -g:none to the javac command line. If so, tell it to stop.
-
Hi,
I have a swing application, in which I am using two threads. One thread, is the "main", and the other, takes care of every update to the UI. My program works fine for a few seconds, but then I get a weird error which breaks my UI update thread. The error itself is:
Exception in thread "Thread-2" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
at java.util.HashMap$ValueIterator.next(Unknown Source)
at DrawFrame$allthread.run(DrawFrame.java:400)
at java.lang.Thread.run(Unknown Source)
Which leads me to believe that the two threads are messing each other up. Lets take a look at some code.
This is the class which is created about 3 times a second, based upon when the user wants it to be.
class shooting { // this class is inside of the "allthread" class which implements Runnable
private Point p;
private Dimension size;
private int deltaY;
private int wtr;
private boolean destroy = false;
Rectangle recs = new Rectangle(); // This may have a factor
private shooting(Point p, Dimension size, Color color, int deltaY) {
this.wtr = 0 - size.height;
this.p = p;
this.size = size;
this.deltaY = deltaY;
recs.x = p.x;
recs.y = p.y;
recs.width = size.width;
recs.height = size.height;
rectangles.put(shotnumber, recs); // This may have a big factor as well (this goes into a hashmap)
shotnumber++;
public void paint(Graphics g) { // this part has a factor I believe
if (g.getColor() != Color.red){
g.setColor(Color.red);
g.fillRect(recs.x, recs.y, recs.width, recs.height);
So how I display this class on the UI, is like this:
public void painters(Graphics g){
for (allthread.shooting shot : shots) {
shot.paint(g);
}The painters method is called from my "public void paintComponent(Graphics g) {}", which I think updates when the computer thinks it needs to.
So I'm not exactly sure why its breaking, perhaps someone can tell from the error which I have listed at the top. I think one thread is trying to do something, which another thread is trying to do something at the same time to the same part of the code. That might not be it, but thats the best I have come up with in a week of confused droning about over this crazy madness.
Thanks for reading,
Nate
P.S. Thanks for the help, all questions will be answered in under 3 minutes - I'm right here watching this post until it is answered. Please ask any questions that you might have in order for me to provide you with information that I may have left out.[Check this out.|http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map)]
I don't know if you'd consider throwing an exception as breaking... but check this out too. -
When i try to put in the lines that you posted on the forum, i manage to compile but when i actually read from the serial port, error occurs....The error is
java.lang.NullPointerException
at java.io.ByteArrayOutputStream.writeto(Unknown source)
at Read.serialEvent(Read.java:99)
import javax.comm.*;
import java.io.*;
import java.util.*;
public class Read implements Runnable, SerialPortEventListener {
// Attributes for Serial Communication
static Enumeration portList;
static CommPortIdentifier portId;
SerialPort serialPort;
static OutputStream outputStream;
InputStream inputStream;
Thread readThread;
ByteArrayOutputStream buffer;
public static void main(String s[])
portList=CommPortIdentifier.getPortIdentifiers();
while(portList.hasMoreElements())
portId=(CommPortIdentifier)portList.nextElement();
if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL)
if(portId.getName().equals("COM1"))
System.out.println( portId.getName());
Read ss=new Read();
} // end of while
} // end of main
public Read() {
try{
serialPort=(SerialPort)portId.open("Read", 2000);
catch(PortInUseException e) {}
try{
inputStream=serialPort.getInputStream();
System.out.println(inputStream);
catch(IOException e) {}
try{
serialPort.addEventListener(this);
catch(Exception e) {}
serialPort.notifyOnDataAvailable(true);
try{
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}catch(UnsupportedCommOperationException e) {}
readThread=new Thread(this);
readThread.start();
}//end of constructor
public void run()
try {
Thread.sleep(200);
}catch(InterruptedException e) {}
public void serialEvent(SerialPortEvent event)
{buffer=new ByteArrayOutputStream();
int i;
switch(event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[]readBuffer=new byte[8];
try{
while((i=inputStream.available())>0)
inputStream.read(readBuffer, 0, i);
buffer.write(readBuffer, 0, i);
buffer.writeTo(outputStream);
buffer.reset();
}catch(IOException e) {}
break;
} // end of switch
try {
inputStream.close();
}catch(Exception e5) {}
} // end of serialEventHey I_ws,
glad I could be some help!
Other poster is right, you need some particular outputstream to output to, say you're outputting to a text file, (I can't remember your original post, but other outputs are similar)
you'd do something like:
DataOutputStream out;
//initialise with constructor...
try{
out = new DataOutputStream(
new FileOutputStream("log.txt"));
}catch (FileNotFoundException e) {}
// creating a new data output stream to
//write data to the specified underlying FileOutputStream...
//output part:
inputStream.read(readBuffer, 0, i);
buffer.write(readBuffer, 0, i);
buffer.writeTo(out);
buffer.reset();
[\code]
hope that helps (and hope it runs!) I'm reading over my pathetic resume to counteract the ego boost of seeing my handle as a thread subject!
take care :) -
I am trying jms example but i have problen while in lookup ,i could not find the resource running in the sun app server.
the below is the code
import javax.jms.*;
import javax.naming.*;
import java.util.*;
public class SimpleTopicPublisher {
* Main method.
* @param args the topic used by the example and,
* optionally, the number of messages to send
public static void main(String[] args) {
String topicName = null;
Context jndiContext = null;
TopicConnectionFactory topicConnectionFactory = null;
TopicConnection topicConnection = null;
TopicSession topicSession = null;
Topic topic = null;
TopicPublisher topicPublisher = null;
TextMessage message = null;
final int NUM_MSGS;
if ( (args.length < 1) || (args.length > 2) ) {
System.out.println("Usage: java " +
"SimpleTopicPublisher <topic-name> " +
"[<number-of-messages>]");
System.exit(1);
topicName = new String(args[0]);
System.out.println("Topic name is " + topicName);
if (args.length == 2){
NUM_MSGS = (new Integer(args[1])).intValue();
} else {
NUM_MSGS = 1;
* Create a JNDI API InitialContext object if none exists
* yet.
try {
// String url = "mq://INBANN0L3CT171.ap01.lucent.com:7676/";
// Properties p = new Properties();
//p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory");
// p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
//p.put(Context.PROVIDER_URL, url);
//ctx = new InitialContext(p);
jndiContext = new InitialContext();
} catch (NamingException e) {
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
e.printStackTrace();
System.exit(1);
* Look up connection factory and topic. If either does
* not exist, exit.
try {
topicConnectionFactory = (TopicConnectionFactory)
jndiContext.lookup("jms/myjms");
topic = (Topic) jndiContext.lookup(topicName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " +
e.toString());
e.printStackTrace();
System.exit(1);
* Create connection.
* Create session from connection; false means session is
* not transacted.
* Create publisher and text message.
* Send messages, varying text slightly.
* Finally, close connection.
try {
topicConnection =
topicConnectionFactory.createTopicConnection();
topicSession =
topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
topicPublisher = topicSession.createPublisher(topic);
message = topicSession.createTextMessage();
for (int i = 0; i < NUM_MSGS; i++) {
message.setText("This is message " + (i + 1));
System.out.println("Publishing message: " +
message.getText());
topicPublisher.publish(message);
} catch (JMSException e) {
System.out.println("Exception occurred: " +
e.toString());
} finally {
if (topicConnection != null) {
try {
topicConnection.close();
} catch (JMSException e) {}
and below is the error while running
D:\>java SimpleTopicPublisher mytopic 3
Topic name is mytopic
Apr 23, 2012 5:03:48 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceIm
l findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be availab
e by default.
JNDI API lookup failed: javax.naming.NamingException: Lookup failed for 'java:c
mp/env/jms/myjms' in SerialContext[myEnv={java.naming.factory.initial=com.sun.e
terprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com
sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presenta
ion.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException:
nvocation exception: Got null ComponentInvocation ]
javax.naming.NamingException: Lookup failed for 'java:comp/env/jms/myjms' in Se
ialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.Se
ialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming,
ava.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactor
Impl} [Root exception is javax.naming.NamingException: Invocation exception: Go
null ComponentInvocation ]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: javax.naming.NamingException: Invocation exception: Got null Compone
tInvocation
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getCompone
tId(GlassfishNamingManagerImpl.java:873)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(Gla
sfishNamingManagerImpl.java:742)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.
ava:169)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:498)
... 3 more
D:\>javac SimpleTopicPublisher.java
D:\>java SimpleTopicPublisher mytopic 3
Topic name is mytopic
Apr 23, 2012 5:09:28 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceIm
l findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be availab
e by default.
java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:262)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNam
Service(SerialContext.java:1244)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(Seria
Context.java:410)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:346)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.e
terprise.naming.impl.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:254)
... 8 more
JNDI API lookup failed: javax.naming.NamingException: Lookup failed for 'jms/my
ms' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.nami
g.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterpris
.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIS
ateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acqu
re SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=c
m.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.
kgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.
resentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.ClassCastExc
ption]]
javax.naming.NamingException: Lookup failed for 'jms/myjms' in SerialContext[my
nv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContex
Factory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.fa
tory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root e
ception is javax.naming.NamingException: Unable to acquire SerialContextProvide
for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming
impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.
aming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDISta
eFactoryImpl} [Root exception is java.lang.ClassCastException]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvide
for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming
impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.
aming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDISta
eFactoryImpl} [Root exception is java.lang.ClassCastException]
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:351)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:504)
... 3 more
Caused by: java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:262)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNam
Service(SerialContext.java:1244)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(Seria
Context.java:410)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:346)
... 4 more
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.e
terprise.naming.impl.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:254)
... 8 more
plese help me in resolving...I am trying jms example but i have problen while in lookup ,i could not find the resource running in the sun app server.
the below is the code
import javax.jms.*;
import javax.naming.*;
import java.util.*;
public class SimpleTopicPublisher {
* Main method.
* @param args the topic used by the example and,
* optionally, the number of messages to send
public static void main(String[] args) {
String topicName = null;
Context jndiContext = null;
TopicConnectionFactory topicConnectionFactory = null;
TopicConnection topicConnection = null;
TopicSession topicSession = null;
Topic topic = null;
TopicPublisher topicPublisher = null;
TextMessage message = null;
final int NUM_MSGS;
if ( (args.length < 1) || (args.length > 2) ) {
System.out.println("Usage: java " +
"SimpleTopicPublisher <topic-name> " +
"[<number-of-messages>]");
System.exit(1);
topicName = new String(args[0]);
System.out.println("Topic name is " + topicName);
if (args.length == 2){
NUM_MSGS = (new Integer(args[1])).intValue();
} else {
NUM_MSGS = 1;
* Create a JNDI API InitialContext object if none exists
* yet.
try {
// String url = "mq://INBANN0L3CT171.ap01.lucent.com:7676/";
// Properties p = new Properties();
//p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory");
// p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
//p.put(Context.PROVIDER_URL, url);
//ctx = new InitialContext(p);
jndiContext = new InitialContext();
} catch (NamingException e) {
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
e.printStackTrace();
System.exit(1);
* Look up connection factory and topic. If either does
* not exist, exit.
try {
topicConnectionFactory = (TopicConnectionFactory)
jndiContext.lookup("jms/myjms");
topic = (Topic) jndiContext.lookup(topicName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " +
e.toString());
e.printStackTrace();
System.exit(1);
* Create connection.
* Create session from connection; false means session is
* not transacted.
* Create publisher and text message.
* Send messages, varying text slightly.
* Finally, close connection.
try {
topicConnection =
topicConnectionFactory.createTopicConnection();
topicSession =
topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
topicPublisher = topicSession.createPublisher(topic);
message = topicSession.createTextMessage();
for (int i = 0; i < NUM_MSGS; i++) {
message.setText("This is message " + (i + 1));
System.out.println("Publishing message: " +
message.getText());
topicPublisher.publish(message);
} catch (JMSException e) {
System.out.println("Exception occurred: " +
e.toString());
} finally {
if (topicConnection != null) {
try {
topicConnection.close();
} catch (JMSException e) {}
and below is the error while running
D:\>java SimpleTopicPublisher mytopic 3
Topic name is mytopic
Apr 23, 2012 5:03:48 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceIm
l findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be availab
e by default.
JNDI API lookup failed: javax.naming.NamingException: Lookup failed for 'java:c
mp/env/jms/myjms' in SerialContext[myEnv={java.naming.factory.initial=com.sun.e
terprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com
sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presenta
ion.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException:
nvocation exception: Got null ComponentInvocation ]
javax.naming.NamingException: Lookup failed for 'java:comp/env/jms/myjms' in Se
ialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.Se
ialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming,
ava.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactor
Impl} [Root exception is javax.naming.NamingException: Invocation exception: Go
null ComponentInvocation ]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: javax.naming.NamingException: Invocation exception: Got null Compone
tInvocation
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getCompone
tId(GlassfishNamingManagerImpl.java:873)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(Gla
sfishNamingManagerImpl.java:742)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.
ava:169)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:498)
... 3 more
D:\>javac SimpleTopicPublisher.java
D:\>java SimpleTopicPublisher mytopic 3
Topic name is mytopic
Apr 23, 2012 5:09:28 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceIm
l findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be availab
e by default.
java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:262)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNam
Service(SerialContext.java:1244)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(Seria
Context.java:410)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:346)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.e
terprise.naming.impl.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:254)
... 8 more
JNDI API lookup failed: javax.naming.NamingException: Lookup failed for 'jms/my
ms' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.nami
g.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterpris
.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIS
ateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acqu
re SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=c
m.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.
kgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.
resentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.ClassCastExc
ption]]
javax.naming.NamingException: Lookup failed for 'jms/myjms' in SerialContext[my
nv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContex
Factory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.fa
tory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root e
ception is javax.naming.NamingException: Unable to acquire SerialContextProvide
for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming
impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.
aming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDISta
eFactoryImpl} [Root exception is java.lang.ClassCastException]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at SimpleTopicPublisher.main(SimpleTopicPublisher.java:112)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvide
for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming
impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.
aming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDISta
eFactoryImpl} [Root exception is java.lang.ClassCastException]
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:351)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.ja
a:504)
... 3 more
Caused by: java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:262)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNam
Service(SerialContext.java:1244)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(Seria
Context.java:410)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialConte
t.java:346)
... 4 more
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.e
terprise.naming.impl.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(Portable
emoteObject.java:254)
... 8 more
plese help me in resolving... -
The application behind this code is generating a bunch of "Unknown Source" errors at runtime:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Polygon#MouseHandler.mousePressed(Polygons.java:95)
at java.awt.Component.processMouseEvent(Unknown Source), and so on...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;
public class Polygons extends JPanel {
protected static boolean shiftIsDown;
public static void main(String[] args) {
JFrame window = new JFrame("Polygons");
Polygons content = new Polygons();
content.addKeyListener( new KeyAdapter() {
public void KeyPressed(KeyEvent evt) {
int key = evt.getKeyCode();
if(key == KeyEvent.VK_SHIFT)
shiftIsDown = true;
window.setContentPane(content);
window.pack();
window.setLocation(100, 100);
window.setResizable(false);
window.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
window.setVisible(true);
} // End main()
private static class PolygonData {
int[] x;
int[] y;
public Polygons() {
// Constructor.
setBackground(Color.WHITE);
MouseHandler listener = new MouseHandler();
setPreferredSize(new Dimension(350, 350) );
addMouseListener(listener);
addMouseMotionListener(listener);
private class MouseHandler implements MouseListener,
MouseMotionListener {
PolygonData polygon;
private boolean dragging = false;
private int vertices;
private int x1, y1; // First vertex point.
private int x2, y2; // Second vertex point.
private boolean newPolygon = false; // Is the user drawing
// a new polygon?
public void mousePressed(MouseEvent evt) {
// If the user is within two pixels of the
// starting point, draw the polygon.
// Graphics g = getGraphics();
int tolerence = 2;
if(shiftIsDown);
x1 = evt.getX();
y1 = evt.getY();
vertices++;
if(newPolygon) {
polygon = new PolygonData();
x2 = x1;
y2 = y1;
polygon.x = new int[1024];
polygon.y = new int[1024];
if(vertices == 1){
polygon.x = new int[1024];
polygon.y = new int[1024];
polygon.x[vertices] = x1;
polygon.y[vertices] = y1;
g.setColor(Color.BLACK);
g.drawPolygon(polygon.x, polygon.y, vertices);
// Did the user click near the starting point?
if( (polygon.x[0] - x1 <= tolerence)
&& (polygon.y[0] - y1 <= tolerence) ) {
g.setColor(Color.RED);
g.fillPolygon(polygon.x, polygon.y, vertices); }
public void mouseMoved(MouseEvent evt) {
// Grab the graphics context.
Graphics g = getGraphics();
x2 = evt.getX();
y2 = evt.getY();
g.drawLine(x1, y1, x2, y2);
repaint();
// Required by the interfaces....
public void mouseReleased(MouseEvent evt) { }
public void mouseClicked(MouseEvent evt) { }
public void mouseEntered(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
public void mouseDragged(MouseEvent evt) { }
} // End nested class Mousehandler
} // End class PolygonsSame goes for mouseMoved().... What's the fix?flounder wrote:
if(newPolygon) {
polygon = new PolygonData();This is the probable cause. Since newPolygon is initially false, it will not execute the if statement and polygon will not be initialised. So later in your code when you attempt to use polygon it is null.That did it.
Thanks! -
Why am I getting (Unknown Source) instead of a line number?
In the past couple of weeks, using Tomcat with a Servlet/java bean app, I've started getting exceptions listing such as this:
Exception in: R( /webman + /servlet/CreateJobServlet + null) - java.lang.NullPointerException
at CreateJobServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
The thing that bothers me is the "(Unknown Source)" bit. I no longer get the line numbers where the error occured on any of my source files, whereas I'm sure I DID get line numbers a few weeks ago. I thought it might have to do with my changing to JDK1.4, but after changing back to 1.3, the problem persists. Why are the line numbers no longer available, and what can I do to fix it? I've always accepted the frustration of getting NullPointerExceptions in JSP pages, but I don't want to be forced to put lots of System.outs in to help me track down the problems in compiled files!!It could be one of the following:
- you have not specified -g on compile
(means debug info, check IDE or ANT task if you dont
use command line)
- you have specified -O on compile
(means optimize, which could hinder debug infos)
bottom line:
you should have debuginfos on and optimze off during
compile. Most IDEs have debug info default-on during
compile, when using ANT most people forget to define
the debug=on
<javac srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on"
/>
Hope this helps
Maybe you are looking for
-
was working fine. all i use if for is pod casts and not will not sync. have done a restore and return to origional setting. The on button is checked for pod cast on. Thank you, shelly
-
How to secure Oracle Applications?
i have implemented security mechanisms in the database,but i would like to know how to implement security in an application rather than doing so through the database? Thank you
-
Routines related to SAP SD module
Hi can anyone give me some links related to SAP SD module plz. I am new to routines, please help me out. Thanks in advance. I apprecieate ur help
-
Transferring inactive personnel numbers via IDOC (HRMD_A) - how?
Hello everyone, we are using IDOCs of type HRMD_A to transfer some infotypes (0,1,2,3 and a few others) of all employee numbers from the HR system to the FI system. The transfer is initiated using transaction PFAL with transfer type "Insert". So far,
-
Best Practice in defining variables
Hi All What is the best practice to use variables inside a method and any specific advantage .i.e. initializing variables starting of the method vs defining them where they are required. public String abc(){ int i = 0; String s = null; i = 10 + 50; s