Hello friends,
I have problem in my java application and rxtx library .
my application recives some events in observer mechanism and for each event sends event description to printer on parallel port(LPT1 in win) by rxtxcomm.
my application works fine on linux but on windows, after receiving some events and prints them , the crash happend .
after reciving events in each second or less ,the crash happend with this error:public class PrinterPortCommunication { static PrinterPortCommunication instance = null; public final String[] PORT_TYPE = {"Serial Port", "Parallel Port"}; private String parallelPortName = null; private OutputStream outputStream = null; private ParallelPort parallelPort = null; private CommPortIdentifier port = null; static int lineCountLimit = 0; static byte[] headerByte = null; static int lineCounter = 0; private static Logger logger = Logger.getLogger(PrinterPortCommunication.class); public static PrinterPortCommunication getInstance() { if (instance == null) { instance = new PrinterPortCommunication(); } return instance; } public void init(String parallelPortName, String headerText, int lineCountLimit) throws OnlinePrintException { try { this.parallelPortName = parallelPortName; PrinterPortCommunication.lineCountLimit = lineCountLimit; headerText = headerText + " \n"; headerByte = headerText.getBytes("UTF8"); port = CommPortIdentifier.getPortIdentifier(parallelPortName); parallelPort = (ParallelPort) port.open("EventRecorder", 50); outputStream = parallelPort.getOutputStream(); logger.info("\nport.portType = " + port.getPortType()); logger.info("port type = " + PORT_TYPE[port.getPortType() - 1]); logger.info("port.name = " + port.getName()); } catch (IOException ex) { throw new OnlinePrintException("No paper to print->" + "outputStream" + "\n"); } catch (Exception ex) { throw new OnlinePrintException("can not fine this port->" + parallelPortName + "\n"); } } public void print(String printerCodes) throws OnlinePrintException { try { printerCodes = printerCodes + " \n"; byte[] byteArray = printerCodes.getBytes("UTF8"); if (lineCounter == lineCountLimit) { outputStream.write(headerByte); outputStream.flush(); outputStream.close(); lineCounter = 0; } outputStream.write(byteArray); outputStream.flush(); outputStream.close(); lineCounter++; } catch (Exception ex) { throw new OnlinePrintException("Error in port's outputStream.first initiate the PrintPortCommunication class.\n"); } } } code to send print: PrinterPortCommunication.getInstance().init("LPT1", "", 5); public synchronized void update(Observer observer, final Object obj) { try { PrinterPortCommunication.getInstance().print("event description...."); } catch (Exception ex) { ex.getMessage(); ex.printStackTrace(); logger.warn("***Exception***" + ex.toString()); } }
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c92ae22, pid=3784, tid=3608
#
# JRE version: 6.0_16-b01
# Java VM: Java HotSpot(TM) Server VM (14.2-b01 mixed mode windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x2ae22]
#
# If you would like to submit a bug report, please visit:
# HotSpot Virtual Machine Error Reporting Page
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- T H R E A D ---------------
Current thread (0x0f274400): JavaThread "NioProcessor-1" [_thread_in_native, id=3608, stack(0x10c40000,0x10e40000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x45442f35
Registers:
EAX=0x33382d45, EBX=0x00000000, ECX=0x45442f35, EDX=0x0ffa0608
ESP=0x10e3f3fc, EBP=0x10e3f4b8, ESI=0x0ffa52c0, EDI=0x0ffa0000
EIP=0x7c92ae22, EFLAGS=0x00010217
Top of Stack: (sp=0x10e3f3fc)
0x10e3f3fc: 0ffa52e0 0ffa52e0 0f274510 00000000
0x10e3f40c: 00000008 090c36a0 10e3f498 10e3f434
0x10e3f41c: 6dc932fb 090c0070 0000001a 090c0ae8
0x10e3f42c: 000001a4 0e126b48 00000040 6dcd3415
0x10e3f43c: 00000000 45442f35 10e3f498 33382d45
0x10e3f44c: 0ffa52c0 00000000 00000000 00020978
0x10e3f45c: 7c80a6fe 00000000 0ffa52a8 00000000
0x10e3f46c: 0f274510 7c9106eb 000006f4 00000000
Instructions: (pc=0x7c92ae22)
0x7c92ae12: 75 cc 89 75 94 8b 06 89 45 90 8b 4e 04 89 4d 88
0x7c92ae22: 8b 11 3b 50 04 0f 85 93 d1 ff ff 3b d6 0f 85 8b
...
can any body help me please?!