No status exception

24 views
Skip to first unread message

Diogo Pinheiro

unread,
Nov 10, 2014, 6:30:07 AM11/10/14
to jfreesan...@googlegroups.com
Hello,

I'm having problems when i scan more than 1 document. My code is this:

public void pressScanButton() {
       
try {
           
List<String> images = new ArrayList<String>();
           
int pageCount = 0;

           
while (true) {
               
try {
                   
BufferedImage acquireImage = selectedScanner.acquireImage();

                   
String path = "/home/" + MainInterface.tempFilesFolder + "/" + "tempImage" + pageCount++ + ".jpg";
                   
File outputfile = new File(path);
                   
ImageIO.write(acquireImage, "jpg", outputfile);

                    images
.add(path);
                   
               
} catch (SaneException e) {
                   
if (e.getStatus() == SaneStatus.STATUS_NO_DOCS) {
                       
new ImageWorker(images).start();
                       
break;
                   
} else {
                       
throw e;
                   
}
               
}            
           
}
       
} catch (Exception e) {
            e
.printStackTrace();
       
}
   
}

When i call this method for the first time everything works fine. But when i call it for the second time in the same runtime it always give me this exception:

jfreesanelib.SaneException: no status
    at jfreesanelib.SaneOption$ControlOptionResult.fromSession(SaneOption.java:711)
    at jfreesanelib.SaneOption$ControlOptionResult.access$0(SaneOption.java:705)
    (...)

Could anybody explain me what's happening?

Thank you :)

James Ring

unread,
Nov 10, 2014, 11:27:54 AM11/10/14
to Diogo Pinheiro, jfreesane-discuss
Hey Diogo,

Can you try checking out JFreeSane with the improved_error_logging branch, which will bring in the following patch: https://github.com/sjamesr/jfreesane/commit/5ab2a1b49582e44a41f529c1ea4bc61608648b93

This should improve the logging slightly so we have a better chance of knowing what's going on.

Thanks,
James

--
You received this message because you are subscribed to the Google Groups "jfreesane-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfreesane-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Diogo Pinheiro

unread,
Nov 10, 2014, 11:49:48 AM11/10/14
to jfreesan...@googlegroups.com, dfcpi...@gmail.com
Thank you for your answer.
Here is the result with the new improvements.

jfreesanelib.SaneException: unknown status (35222)
    at jfreesanelib.SaneException.fromStatusWord(SaneException.java:30)
    at jfreesanelib.SaneOption$ControlOptionResult.fromSession(SaneOption.java:711)
    at jfreesanelib.SaneOption$ControlOptionResult.access$0(SaneOption.java:704)
    at jfreesanelib.SaneOption.handleWriteResponse(SaneOption.java:662)
    at jfreesanelib.SaneOption.writeOption(SaneOption.java:621)
    at jfreesanelib.SaneOption.setStringValue(SaneOption.java:522)
    at main.gui.ScannerController.setParameters(ScannerController.java:235)
    at main.gui.MainInterface.setScannerParameters(MainInterface.java:150)
    at main.gui.MainInterface.access$2(MainInterface.java:149)
    at main.gui.MainInterface$2.mouseClicked(MainInterface.java:176)
    at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    at java.awt.Component.processMouseEvent(Component.java:6519)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3311)
    at java.awt.Component.processEvent(Component.java:6281)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4872)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
jfreesanelib.SaneException: no status
    at jfreesanelib.SaneSession.acquireImage(SaneSession.java:134)
    at jfreesanelib.SaneDevice.acquireImage(SaneDevice.java:91)
    at main.gui.ScannerController.scanDocument(ScannerController.java:189)
    at main.gui.MainInterface$2.mouseClicked(MainInterface.java:177)
    at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    at java.awt.Component.processMouseEvent(Component.java:6519)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3311)
    at java.awt.Component.processEvent(Component.java:6281)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4872)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

James Ring

unread,
Nov 10, 2014, 11:57:27 AM11/10/14
to dfcpi...@gmail.com, jfreesane-discuss
Hm, can you also send me the code?

Diogo Pinheiro

unread,
Nov 10, 2014, 12:48:28 PM11/10/14
to jfreesan...@googlegroups.com, dfcpi...@gmail.com
The code is basically this one:

public void pressScanButton() {
       
try {

           
int pageCount = 0;

           
while (true) {
               
try {
                   
BufferedImage acquireImage = selectedScanner.acquireImage();

                   
String path = "/home/" + MainInterface.tempFilesFolder + "/" + "tempImage" + pageCount++ + ".jpg";
                   
File outputfile = new File(path);
                   
ImageIO.write(acquireImage, "jpg", outputfile);

                   
               
} catch (SaneException e) {
                   
if (e.getStatus() == SaneStatus.STATUS_NO_DOCS) {

                       
break;
                   
} else {
                       
throw e;
                   
}
               
}            
           
}
       
} catch (Exception e) {
            e
.printStackTrace();
       
}
   
}

This method is called everytime i press the button "SCAN" in my application. The first time it works perfectly but the seconds it shows that exception
I open the session normally like this:

saneSession = SaneSession.withRemoteSane(InetAddress.getLocalHost());

And that's it. Do you need to know more specifications?

James Ring

unread,
Nov 10, 2014, 1:21:11 PM11/10/14
to Diogo Pinheiro
bcc: jfreesane-discuss so we don't spam the list

Seeing where the device is opened and its source set would be good
too. Are you using jfreesane at that branch that I sent you
(improved_error_logging)?

Also, what's with the stack traces containing jfreesanelib? Are you
modifying them before you print them?

Regards,
James

Diogo Pinheiro

unread,
Nov 10, 2014, 1:45:38 PM11/10/14
to jfreesan...@googlegroups.com, dfcpi...@gmail.com
This attachment contains a similar code to what i'm doing in my project and happens the same exception.

Are you using jfreesane at that branch that I sent you
(improved_error_logging)?


Yes


Also, what's with the stack traces containing jfreesanelib? Are you
modifying them before you print them?


No, i'm not modifying then. You can see that in the code sample a sent you.

Thank you :)
Teste.java

James Ring

unread,
Nov 12, 2014, 11:07:24 AM11/12/14
to Diogo Pinheiro, jfreesane-discuss
(re-adding jfreesane-discuss to share the good news)

Glad to hear the patch worked!

The problem was that JFreeSane would, upon seeing a non-OK status when starting image acquisition, immediately throw an exception without reading the remainder of the response bytes from the SANE server. This would leave it in a bad state to begin processing subsequent requests. Please see https://github.com/sjamesr/jfreesane/commit/df13647167b9db055cc723cc1d4904d4b365bc28.

I'll make a new release of JFreeSane shortly.

Thanks for getting in touch, Diogo!

Regards,
James

On Tue, Nov 11, 2014 at 1:51 AM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
It works perfectly :)
Thank you so much!

2014-11-11 4:54 GMT+00:00 James Ring <s...@jdns.org>:
I think I reproduced the problem with the test backend. I checked in a fix, please check out the latest master branch and see if it works.


On Mon, Nov 10, 2014 at 2:15 PM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
I'm happy to know there are still good people that are concerned about helping the others.
I'm the one who needs to thank you :)

2014-11-10 22:10 GMT+00:00 James Ring <s...@jdns.org>:
Thanks Diogo, hopefully we can get this sorted out for you!

On Mon, Nov 10, 2014 at 2:10 PM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
Now i don't have a scanner to test :s
I'll try tomorrow and then i'll give you some feedback.

Thank you. 


2014-11-10 22:07 GMT+00:00 James Ring <s...@jdns.org>:
Can you try adding a call to saneDevice.cancel() when you get the STATUS_NO_DOCS exception?

On Mon, Nov 10, 2014 at 1:59 PM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
It only gives me the exception in this case:

1- Put a sheet in the scanner
2- Run the code
3- After the scan wait for the STATUS_NO_DOCS exception
4- Right after the exception put one more sheet in the scanner (be fast because the Thread.sleep is only 6 seconds)
5 - Normaly it makes the scan but throws the no status exception
6 - After this exception the scanner "freezes" and sometimes i have to restart it.
7 - If it works ok repeat one or two more times.

Thank you for your time :)

2014-11-10 20:02 GMT+00:00 James Ring <s...@jdns.org>:
I'll try it when I get home from work, I do have a unit test for this case though and AFAIK it still passes...

On Mon, Nov 10, 2014 at 11:08 AM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
by the log everything is ok:

Nov 10 19:05:55 diogo-Satellite-L650 colord: device removed: sysfs-04c5-114f
Nov 10 19:06:07 diogo-Satellite-L650 kernel: [35446.056665] usb 2-1.2: new high-speed USB device number 14 using ehci-pci
Nov 10 19:06:07 diogo-Satellite-L650 kernel: [35446.154658] usb 2-1.2: New USB device found, idVendor=04c5, idProduct=114f
Nov 10 19:06:07 diogo-Satellite-L650 kernel: [35446.154663] usb 2-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Nov 10 19:06:07 diogo-Satellite-L650 colord: Device added: sysfs-04c5-114f
Nov 10 19:06:36 diogo-Satellite-L650 saned[12365]: check_host: access by remote host: ::ffff:127.0.0.1
Nov 10 19:06:36 diogo-Satellite-L650 saned[12365]: init: access granted to diogo@::ffff:127.0.0.1

have you tried the code i sent you? don't you get the same exception?

2014-11-10 18:51 GMT+00:00 James Ring <s...@jdns.org>:
Usually sane daemon logs are in syslog, e.g. /var/log/syslog. Look for lines containing "saned".

On Mon, Nov 10, 2014 at 10:48 AM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
I've put your jfreesanelib files on a package to understand the code and to make changes more easilly.
How can i see the daemon logs?

2014-11-10 18:46 GMT+00:00 James Ring <s...@jdns.org>:
Ok, that's interesting. I've never seen jfreesanelib as a package name before, I don't know where that's coming from.

Can you send me the sane daemon logs as well?

On Mon, Nov 10, 2014 at 10:42 AM, Diogo Pinheiro <dfcpi...@gmail.com> wrote:
This attachment contains a similar code to what i'm doing in my project and happens the same exception.
Are you using jfreesane at that branch that I sent you
(improved_error_logging)?


Yes


Also, what's with the stack traces containing jfreesanelib? Are you
modifying them before you print them?


No, i'm not modifying then. You can see that in the code sample a sent you.

Thank you :)
Reply all
Reply to author
Forward
0 new messages