Morena 6 support resources
Please, try to find out, if there is an answer for your question in the FAQ below before you will contact our technical support.
If you need a help with our product, please send a message to twain@gnome.sk .
If you need a help with TWAIN source manager or driver, please use TWAIN mailing list archive .
If you prefer conventional communication, you can also call or send a fax to +421-2-65427825.
 
 
Frequently asked questions
I'm trying to deploy an app that uses Morena. I can get the app to start, but I am getting the following error when I try to scan: java.security.AccessControlException: access denied
The typical reason of this error is, that you forgot to sign your jar files .
Is it possible to get images from a remote network device with its IP address?
Twain is not designed for network communication. To scan images with Twain, you have to have your application + Twain Data Source Manager (DSM) + Twain driver at the client computer. It is true for network scanner too. In case of network scanner, it's Twain driver located at the client computer is just a "proxy" which receives communication from the DSM and forward it to some network ip address. So, if we suppose, that client computer has DSM as well as Twain driver installed, than Morena will work correctly with network scanners. In fact, Morena will not know, if the source is connected directly or it is at network. We have in the office Lexmark X544 network scanner. It has Twain driver and it is connected to the ethernet network, not to the computer's usb. It works without problems.
Sane is another world. It is designed from the beginning as a network API. You can acquire images from the scanner connected to the computer at network. The only requirements are that the computer where the scanner is connected supports Sane and Sane's network daemon. Again, you can test it with our online MorenaStudio applet.
When I use the Morena´s library happen this error: java.lang.NoClassDefFoundError: Could not initialize class.
The reason of this error is often in the license. E.g. expired trial license.
Unexpected "java.lang.NoSuchMethodError: SK.gnome.twain.TwainManager.selectSource..." exception?
Typically there is some version mishmash. Cleaning is a good first step to solve this problem.
I am trying to figure out how to scan using a duplex scanner. Does Morena support this?
To find out if duplex scanning is supported by the Twain driver, call twainSource.getDuplex() method. If duplex scanning is supported, to find out if duplex scanning is enabled, call twainSource.getDuplexEnabled() method. To turn a duplex scanning on, call twainSource.setDuplexEnabled(true);
How to get images of both sides?
You can use standard ADF technique:
        do
        {
        Your scanning activity.
        }
        while (source.hasMoreImages());
How to detect a paper jam?
Twain driver should report paper jam to the condition code status. In case of paper jam it should return TWCC_PAPERJAM=20. Many drivers do not support this feature. You can experiment with getConditionCode, getResultCode methods in case of your concrete hardware.
ImageConsumer constants are useful to detect, that some problem occurred. (You do not have possibility to detect, that particularly paper jam occurred.) There are three possible status values:
        IMAGEABORTED = The image creation process was deliberately aborted.
        IMAGEERROR = An error was encountered while producing the image.
        STATICIMAGEDONE = The image is complete and there are no
        more pixels or frames to be delivered.
You can receive these values also from getStatus method of the MorenaImage class.
The scanning or GUI loading is extremely slow.
According to our information, there are some scanners (CanoScan LiDE 20/30/50/60, Canon CR-180, DR-1210C, HP Scanjet 7800, Kodak i1220) which scan correctly from the Java applications and WebStart applications, but scanning via applets takes too long time. Morena is used with hundreds of scanners. We do not have the similar reports related to other scanners.
According to our tests, applet scanning speed does not depend on the operating system version, USB type. It looks, that it could be a correlation between the amount of the computer memory and scanning speed. We have tested also applets developed by the other developers - with the same speed behaviour. The problem is independent on Morena Framework. We suspect, that the problem will be somewhere here: Java JRE can manage how many stack and heap space it requires. But it can not influence the same requirements in case of native jni library. The triple Morena jni library + Internet browser + Twain driver do not have enough heap or stack space.
Is it possible to use Morena with Citrix?
We do not have our own experiences with Citrix, but one of our customer wrote us: "I have tested against Citrix Presentation Server version 4.5 and 5.0, it works fine (with Citrix XenApp Client version 11.0.0.5357)." This customer agreed to contact him in case of interest.
We use File transfer mode. The scan goes okay without any errors or java exceptions however the file we try to create 'myimage.jpeg' fails to appear. Instead we get another file TWAIN.TMP in its place. Could you please help us with this?
File transfer mode is completely managed by the Twain driver. Developer can not influence it. But here are some of our ideas:
        1) Maybe your Twain.tmp file is a correct jpg file, but for some reason Twain driver was not able to rename it.
        Try to change Twain.TMP to myimage.jpeg or myimage.bmp.
        2) Check, write
        permissions. Check access rights at the directory, where Twain driver tries to save an image. 
Morena uses native library. Because of this, if you use it in an applet, you need to sign that applet so that Internet browser delegates to it the sufficient access rights (to run a native, not Java code). You sign applet (jar files) with the certificate. You can sign your jar files with certification generated by the Java jarsigner and keytool. But more serious access is, that you will use certificates generated by some certification authority. Here is an example, how to sign examples.jar using your own certificate:
        rem We suppose, that the working directory is examples.

        rem Change the below path to your Java JDK
        path=%path%;"C:\Program Files\Java\jdk1.6.0_07\bin"

        rem Creates bin directory in order to compiles java file into it.
        mkdir bin
        javac -cp ../lib/morena.jar -d bin src/*.java
        jar cf examples.jar -C bin ..
        
        rem Password is 123456
        keytool -genkey -alias yourcompany -keypass 123456
        jarsigner examples.jar yourcompany
        pause
      
See e.g. the following link for more information.
Can I capture images from multiple sources, e.g. two cameras, simultaneously?
No, because Twain nor Sane technologies do not allow it.
Is it possible to redirect the debug log to a file instead of console?
Debug output is written to the standard error output stream. You can redirect it in two ways:
1) Directly in Java using System.setErr(PrintStream err) method.
2) With the help of the shell script of the operating system. E.g. in Microsoft Windows you can do:
java ..... -Dmorena.debug=true MorenaStudio 2>log.txt
How do I detect a blank page?
To detect a blank page document, developer can use setJobControl(int value) method with these values of TwainConstants class:
        TWJC_NONE No job control.
        TWJC_JSIC Detect and include job separator and continue scanning.
        TWJC_JSIS Detect and include job separator and stop scanning.
        TWJC_JSXC Detect and exclude job separator and continue scanning.
        TWJC_JSXS Detect and exclude job separator and stop scanning.

        TwainSource.endOfJob() is the right method to test the end of job.
Unfortunately there is no guarantee that the method is supported by the Twain driver. You can create YourOwn class with ImageConsumer interface. You receive a image data to YourOwn class and store there to some data structure. E.g. an array. You can then parse that array. It is a good solution to detect a blank pages, if Twain driver will not support that capability.
I have successfully deployed Morena in my Java web start application to Windows machines. Now I would like to make it possible for Mac OS X users to do scanning. Do I just add the morena_osx.jar file as a resource in my JNLP file, in addition to the existing morena_windows.jar?
It's simple. Just add morena_osx.jar to the existing jnlp file at the same place, where is morena_windows.jar.
The trial downloads only include MS Windows and MAC OS X. How can we get the Linux libraries?
To use Morena Framework in Linux, you can download arbitrary type of our distribution packages - MS Windows or MAC OS X. The reason, why we distribute Morena Framework in two distribution packages is due the Twain interface. Linux supports Sane interface and it is included in both packages.
    To start using Morena at Linux, we recommend you the following scenario:
    1) Check if you are able to scan images with Sane interface using some native sane application, e.g. scanimage.
    2) If 1) is OK, repeat 1), but using Sane network daemon. 
       See http://penguin-breeder.org/sane/saned/ for more information how to configure it.
    3) If 2) is OK, run our MorenaStudio and select Sane button.
    
Even when I use setVisible(false) to disable the prompt that the user can specify the scanning properties in, the dialog with the option to "cancel" the scan still appears during the scan. I really need to get rid of this. Is there a way to hide this dialog as well?
setIndicators(false) method of TwainSource class is intended for this purpose.
Is it possible to call Morena from Javascript?
To design web scanning via JavaScript is possible, but really not trivial. Our advice is to use just pure applet, without javascript. You will have much simpler developer life. You have MorenaStudio source code ready for your inspiration. If it is necessary to use javascript, be aware of this threads problem:
Because of Twain specification, you need to manage a complete scanning in one thread. According to our experiences, some of Internet browsers use a special thread for java applet and another thread for javascript communication. You need to design such a solution, in which a complete communication with Morena will be in one thread.
How can I customize the scanning area size programmatically so the users don't have to see the scanner interface?
You can call setFrame(double left, double top, double right, double bottom) of the TwainSource class. It uses the units set by the setUnits(int unit) method (Some Twain drivers ignore unit set by setUnits capability and use their own default one.). E.g. to acquire A4 size of paper, call
        twainSource().setUnits(TwainConstants.TWUN_CENTIMETERS);
        twainSource().setFrame(0,0,20.99, 29.70);
      
You can try SupportedSizes capability. SupportedSizes is a capability intended for Twain sources, which support fixed sized scanning areas. You need to choose only one value during negotiation with the Twain source. You can ask for supported sizes:
        twainSource.getSupportedSupportedSizes()
    
or set one:
        twainSource.setSupportedSizes(TwainConstants.TWSS_A4)
    
Some Twain drivers do not support this capability.
You can also try to experiment with the following capabilities:
        twainSource.setUndefinedImageSize(true);
        twainSource.setAutomaticBorderDetection(true);
    
We sometimes see the TWAIN UI being opened behind the browser window in certain environments (or perhaps with certain TWAIN drivers, not 100% sure). Is this a known issue and is there any resolution you recommend?
Yes, we receive occasionally the emails describing the behavior you are writing about. TWAIN UI windows are opened by the Twain Data Source Manager (DSM) and Morena Framework can not influence it.
We have a solution for "Select source" dialog window. TwainManager has two types of selectSource methods:
selectSource(TwainSource defaultSource) = this method asks DSM to pop up select source dialog window. From time to time it happened that it is behind the application window. selectSource(java.awt.Component parent, TwainSource defaultSource) = Our own implemented Java dialog box. It is always on top.
You can use our pure Java User Interface dialog window. See our MorenaCapabilities example. It is always on top.
For the main Twain UI window one of our customer sent us this workaround: There are setFront() and setBack() methods in the Java. (I think in the Frame or Window class.) Just before acquiring the image call setBack() method of your Frame and after acquiring the image call setFront().
Is there a way to make the program to select the source without user intervention?
You can use TwainManager.getDefaultSource() to use the last used source or TwainManager.listSources() to obtain an array of sources. Application can call toString() method of the source to parse a source name.
I received the OutOfMemoryError exception.
The quick solution is to increase JRE heap size by the -Xms and -Xmx system properties. E.g. -Xms512M -Xmx512M. In case of applet you need to setup these system properties at the side of computer, which runs the applet. (E.g. Control Panel/Java/Java Applet Runtime Settings/Java RuntimeParameters/ -Xms512M -Xmx512M) Beginning the Java version 1.6.0_10 Sun introduced the new JRE plugin for Internet browsers. It allows to set the applet properties via jnlp at the server side.
One scanned image (A4, 300 DPI, RGB) could have more than 79 MB. So it is a good idea not to have all scanned images in the memory.
How can I find out, which capabilities supports my Twain driver? Which options supports my Sane backend?
In case of Twain, you can run our TwainAutomatedTest.java (test.bat, test.sh located at the examples directory). It will write all supported capabilities to the twainAutomatedTest.txt file.
In both interfaces, Twain as well as Sane, you can run our MorenaCapabilities example:
1) First select your Twain or Sane source.
2) Click to the "Custom dialog window"/"Select capabilities". The dialog window will pop up all supported capabilities/options.
Is Morena capable of capturing video?
Morena is a Java wrapper to the Twain and Sane interfaces. Twain as well as Sane specifications allows to acquire the static images only.
I use applet with Morena on two different pages and when I run applet from first page, all work fine but if I close first page and run applet from second page, I have exception java.lang.UnsatisfiedLinkError: SK.gnome.twain.TwainManager.initialize(I[B[BZ)V.
First check, if you use the same Morena's jar files in both pages.
We think, that the reason of this problem rises from this: "The virtual machine does not allow a given JNI native library to be loaded by more than one class loader. Attempting to load the same native library by multiple class loaders causes an UnsatisfiedLinkError to be thrown. (http://java.sun.com/docs/books/jni/html/design.html#8148) We did not find the information, if it is possible to unload jni library (or applet's classloader) without closing the Internet browser.
You can add to your applets a test debug output: getClass().getClassLoader().hashCode(). We guess, what you receive will be a different output.
Summary: It is not possible to load jni native library by two different applet classloaders. We were successful to run two applets with Morena only in that situation, when both applets were loaded from the same web page.
Can I save the scanned image as a pdf? I know my scanner has options to generate pdf documents.
Saving to pdf file format is not a part of Twain or Sane specifications. If your scanner supports it, it is some add in of the driver developers beyond the Twain specification. Morena communicates with scanner via Twain (or Sane) interfaces only.
Morena Framework delivers scanned data via standard Java ImageProducer interface. So the task is: "How to save acquired data to the PDF file format, if the they are produced via ImageProducer interface?" It is the same task as if you produce image data from the image file. According the PDF file format, we have a feedback from our customers, that they have good experiences with iText, a free library for generating PDF files.
Here is a snapshot demonstrating how to save to pdf file using iText library:
        TwainSource source = TwainManager.selectSource(null);
        MorenaImage morenaImage = new MorenaImage(source);
        Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);

        com.lowagie.text.Image iTextImage=com.lowagie.text.Image.getInstance(image, null);
        iTextImage.setAbsolutePosition(0, 0);
        Document document=new Document(iTextImage);
        PdfWriter
        writer=PdfWriter.getInstance(document, tmp);
        document.open();
        PdfContentByte cb=writer.getDirectContent();
        cb.addImage(iTextImage);
        document.close();
      
But, you can use your preferable PDF libraries.
How to save the scanned image?
Morena Framework produces acquired data via ImageProducer interface. So the task is, how to save an image, if image data are produced via ImageProducer interface.
        Since Java version 1.2 = there is a com.sun.image.codec.jpeg in the standard Sun's Java distribution.
        Since Java version 1.4.1 = there is a javax.imageio in the standard Java distribution.
        It offers writing to PNG and JPEG formats.
        Since Java version 1.5 = writing to a BMP format was added to the javax.imageio package.
        imageio package offers saving to TIFF with I/O Tools.
        Java Advanced Imaging (JAI) offers writing to many formats, TIFF too.
      
Here is an example how to save an image using ImageIO:
        TwainSource source = TwainManager.selectSource(null);
        MorenaImage morenaImage = new MorenaImage(source);
        Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);
        BufferedImage bimg=new BufferedImage(image.getWidth(null), 
                                 image.getHeight(null), BufferedImage.TYPE_INT_RGB);
        bimg.createGraphics().drawImage(image, 0, 0, null);
        ImageIO.write(bimg,"jpg",new File("test.jpg"));
      
Here is an example how to save an image using com.sun.image.codec.jpeg.*:
        TwainSource source = TwainManager.selectSource(null);
        MorenaImage morenaImage = new MorenaImage(source);
        Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);
        File f=new File("SaveTest.jpg");
        BufferedImage bimg=new BufferedImage(image.getWidth(null), 
                                  image.getHeight(null), BufferedImage.TYPE_INT_RGB);
        bimg.createGraphics().drawImage(image, 0, 0, null);
        FileOutputStream out=new FileOutputStream(f);
        JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(out);
        JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam(bimg);
        param.setQuality(1.0f, false);
        encoder.setJPEGEncodeParam(param);
        encoder.encode(bimg);
        out.close();
      
If you use Twain interface, you can use file tranfer mode to save acquired image directly by the Twain driver.
What is MorenaImage class intended for?
MorenaImage class serves as a simple memory buffer for acquired image. Each invocation of startProduction() on Morena sources ImageProducer interface means new acquisition on your imaging device. You have to cache a image if you want to use it for repetitive drawing, saving to file or other manipulation. Either MorenaImage or BufferedImage can be used.
Morena produces scanned images via ImageProducer interface. You can design your own class with ImageConsumer interface to manage acquired data directly. To receive standard Image class, you can use the following code design:
        SaneConnection sc = SaneConnection.connect("localhost");
        SaneSource source=sc.selectSource(null,null);
        or
        TwainSource source = TwainManager.selectSource(this,null);

        Image image=Toolkit.getDefaultToolkit().createImage(source);
        MediaTracker tracker=new MediaTracker(this);
        tracker.addImage(image, 0);
        try
        { tracker.waitForAll();
        }
        catch (InterruptedException e)
        {
        e.printStackTrace();
        }
        tracker.removeImage(image);
      
I have serious problems getting a BufferedImage image from MorenaImage.
You can use the following code design to create BufferedImage:
        MorenaImage morenaImage = new MorenaImage(source);
        Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);
        BufferedImage bimg=new
        BufferedImage(image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_INT_RGB);
        bimg.createGraphics().drawImage(image, 0, 0, null);
      
(You can omit MorenaImage class if you prefer.)
Is Morena MAC OS X Snow Leopard compatible?
Morena is ready for Snow Leopard. There is one requirement: You need to run it in 32 bits mode. Java is set up in Snow Leopard by default as 64 bits. You need to set up it in order to run itself as 32 bits. (Applications/Utilities/Java Preferences). Notice, that there are separated settings for Java applications and for Java applets. Further, in case of applet, you need to use Internet browsers in 32 bits mode. Safari in Snow Leopard runs by default as 64 bits. In case of Safari all you need to do is highlight Safari in Finder, ctrl-click on it and select Get Info, and enable the "Open in 32-bit mode" checkbox under the General section. FireFox (at minimum the one we have tested) runs in 32 bits version by default.
Runs Morena in 64 bits mode of MS Windows? Runs Morena in 64 bits mode of Java?
Morena runs with 32bits environment only. The whole chain Java JRE - Morena's native library - Twain DSM - Twain driver have to be in 32 bits mode only. You can use 64-bits processors, but install at them 32-bits mode of MS Windows system and 32-bits mode of Java.
My application crashed JVM 1.6 with EXCEPTION_FLT_STACK_CHECK error
There is a known bug in Java version 1.6. To workaround, use Morena version 6.3.2.4 or higher, or use -Xcheck:jni in your Java command line (there will be plenty of warnings from the Java interpreter), or use Java 1.5 or lower.
Is there any difference between MS Windows and Mac OS release?
From the Java developer point of view there is no difference. API is same for all environments. Mac OS X has different security constraints as MS Windows.
What is the difference between a trial version and the full version?
The trial version and the full version have the same features. They differ in a license statement displayed to the Java console.
Could you send me some information about the licenses, the shipping and the payment methods?
Our license policy: You need as many licenses, as many developers work on project where Morena Framework is included. You can include Morena Framework to the unlimited number of your applications (applets too) and distribute it to the unlimited number of customers. Your customers have to be "end users", i.e. you are not allowed to offer your applications with the Morena Framework to other developers. You are not allowed to sell stand alone Morena Framework. In this case of source code license, one license is enough for the whole organization.
Shipping: You can download a full product including evaluation license from try & buy page . After purchasing a commercial or obtaining a educational license you will receive morena_license.jar file as an email attachment. Then just replace the evaluation morena_license.jar file contained within product package with the new one.
Payment methods: You can buy a commercial license on-line from try & buy page . If you prefer, you can pay directly to our bank account as a money order as we send you an invoice.
Where can I find more information about Twain specification?
You can find it at www.twain.org .
Is Morena pure Java(tm) code?
No, it is not. Because of Twain specification design, it is not possible to implement TWAIN client to be platform independent. So far it is ported to Windows and MacOS X only. Sane interface is implemented as pure Java.
Why my scanner does not accept my settings?
Not every scanner/camera driver implements full Twain/Sane specification. E.g. some of them allow hiding user interface, some of them do not.
My scanner supports 12/16 bit scanning. How can I set it from Morena?
12/16 bit scanning is not defined by the Twain specification and thus it is not supported by Morena.
What is TwainProxy application?
On MacOS X platform it is not possible to use shared library with the own user interface from JNI code. That's the reason Morena delegates this to standalone application controlled through IPC.
What is behaviour mask?
Because of some bugs in TWAIN drivers for some popular scanners, Morena implicitly works in a workaround mode. To turn off the workaround mode use setBehaviorMask(0) on TwainSource instance. The image acquisition can be much more efficient in this case, but on the other hand, if your scanner's driver has the mentioned bug, this will crash your application.
What to do with "Current thread is not owner" error?
Morena is not thread safe, because underlying technology (TWAIN and SANE) is not thread safe. But, in general: Open, negotiate with the DSM and the source, and close Morena from the same thread. An example, how to design a thread safe application is our MorenaStudio.java located at the examples/src directory of the distribution package.
What to do with "The license purchased on ... is not valid for this build!" error?
Your license may be still valid for older versions of Morena but not for this one. You need to buy an update to receive valid license for this version of Morena.
What to do with "The license expired on ...!" error?
Trial licenses and some non-commercial licenses have limited life time. You need to obtain a new license file.
What to do with "No valid license found" error?
Morena license files are stored in morena_license.jar by default. There are property files and their digital signatures inside. Make sure that this archive is listed in your class path and is loaded by the same class loader as Morena classes.
How to find out what's wrong?
Turn the Morena's debug mode on (-Dmorena.debug=true system property) and see to the generated log. You can send the log together with your error report to the twain@gnome.sk.
One common good step to solve the problem is cleaning:
a) Delete (backup first if needed) all morena.jar, morena_windows.jar, morena_osx.jar, morena_license.jar from 
   the WHOLE disk. (If you used version prior 2005, delete also javatwain.jar, javatwain_license.jar,
   javatwain.dll, javatwain_debug.dll.) Delete .morena directory from the user's home directory. Take a special
   attention to the JRE/lib/ext directories.
b) Test our MorenaStudio applet.