Saturday, November 21, 2009

Lexmark 7170 and double side printing

If you have a Lexmark x7170 (or any 7100 Series Printer), then you should be able to do double side printing. This is a little bit tricky but not very difficult to achieve.

Benefits of duplex printing and method below:
1) Saves paper and saves trees and helps the environment.
2) Printing is faster if you intend to print double sided and were planning to do manual feed of 2nd side of paper.

Let us assume we have a print job of 9 pages.

So once you hit the "Print" command of your application, the Print menu should pop up. Then click the "Properties" button. This should open the "Lexmark 7100 Series" dialog window. On the left hand side, there is the "Print Layout" section. There click the "Two Sided" link. Now you get a change in the window content and you should see "Duplexing" on the right hand side. Now check the "Two Sided" check box. Uncheck the "Print Instruction Set" check box (remember, we don't want to waste paper). Click ok. (NOTE: You should have the "Print Last Page" checkbox checked).

You should have loaded up a bunch of paper into the tray for the printer to print. The printer will function smartly and print page 9, 7, 5, 3 and 1 on the papers. Then it will pop a window asking you to take the stack of printed pages and feed it back to the tray by rotating the orientation (do not reshuffle or change the pages). Once you have fed the paper to the tray, click the "Continue" button. Now the printer will gleefully print pages 2, 4, 6 and 8. Then it will just chuck the paper with page 9 on it. We are done.

Caveats/Warnings:
* If your current set of paper is precious like you are printing on expensive paper or letterheads etc, do not attempt automatic duplex as the printer spool may feed in 2 papers at one shot and mess up the printing order.
* Print one set at a time. More than one set can cause problems.

Wednesday, November 11, 2009

iPhone: Stuck Email Messages

Sometime, your iphone fails to send email messages. Then it tries to send the email messages repeatedly, until your battery gets drained.

One Workaround:
1) Go to settings.
* Enable "Airplane Mode".
* In Mail etc, disable the email accounts. Set to "Off".
2) Now go to the Email account where you are having outgoing messages issue.
3) In the OutBox for the email account, go through the stuck emails and delete them.
4) Go to settings and disable "airplane" mode and re-enable the email accounts.

This should work.

Thursday, July 30, 2009

Exclusive versus Inclusive Canonicalization

http://www.oxygenxml.com/doc/ug-oxygen/digital-signature.html

The original data is not actually signed; instead, the signature is applied to the output of a chain of canonicalization and transformation algorithms, which are applied to the data in a designated sequence. This system provides the flexibility to accommodate whatever "normalization" or desired preprocessing of the data that might be required or desired before subjecting it to being signed.

To canonicalize something means to put it in a standard format that everyone generally uses. Because the signature is dependent on the content it is signing, a signature produced from a not canonicalized document could possibly be different from one produced from a canonicalized document. The canonical form of an XML document is physical representation of the document produced by the method described in this specification. The term canonical XML refers to XML that is in canonical form. The XML canonicalization method is the algorithm defined by this specification that generates the canonical form of a given XML document or document subset. The term XML canonicalization refers to the process of applying the XML canonicalization method to an XML document or document subset. XML canonicalization is designed to be useful to applications that require the ability to test whether the information content of a document or document subset has been changed. This is done by comparing the canonical form of the original document before application processing with the canonical form of the document result of the application processing.

A digital signature over the canonical form of an XML document or document subset would allows the signature digest calculations to be oblivious to changes in the original document's physical representation. During signature generation, the digest is computed over the canonical form of the document. The document is then transferred to the relying party, which validates the signature by reading the document and computing a digest of the canonical form of the received document. The equivalence of the digests computed by the signing and relying parties (and hence the equivalence of the canonical forms over which they were computed) ensures that the information content of the document has not been altered since it was signed.

The following canonicalization algorithms are used in : Canonical XML (or Inclusive XML Canonicalization)(XMLC14N) and Exclusive XML Canonicalization(EXCC14N). The first is used for XML where the context doesn't change while the second was designed for canonicalization where the context might change.

Inclusive Canonicalization copies all the declarations, even if they are defined outside of the scope of the signature. In this way all the declarations you might use will be unambiguously specified. A problem appears when the signed XML is moved into another XML document which has other declarations because the Inclusive Canonicalization will copy then and the signature will be invalid.

Exclusive Canonicalization finds out what namespaces you are actually using (the ones that are a part of the XML syntax) and just copies those. It does not look into attribute values or element content, so the namespace declarations required to process these are not copied.

This type of canonicalization is useful when you have a signed XML document that you wish to insert into other XML documents and it will insure the signature verifies correctly every time, so it is required when you need self-signed structures that support placement within different XML contexts.

Inclusive Canonicalization is useful when it is less likely that the signed data will be inserted in other XML document and it's the safer method from the security perspective because it requires no knowledge of the data that are to be secured in order to safely sign them.

The canonicalization method can specify whether or not comments should be included in the canonical form output by the XML canonicalization method. If a canonical form contains comments corresponding to the comment nodes in the input node-set, the result is called canonical XML with comments. In an uncommented canonical form comments are removed, including delimiter for comments outside document element.

Friday, July 10, 2009

Tomcat error:: Only a type can be imported. resolves to a package

If you see the following
Only a type can be imported. XYZ resolves to a package.

when you try to import a class into your JSP, the reason is the following:

the class is not available anywhere - either in the WEB-INF/lib or (or server/lib or lib of your tomcat instance).

Tuesday, June 23, 2009

James Gosling's Keynote at Jazoon

Ok, this morning, I sat through a keynote by James Gosling at Jazoon 2009. This was the first time I saw the father of Java in person. Maybe I should have gone to shake hands with him after the talk (but I decided to move on). JG seems like a cool geek.

Most of the presentation was decent. Java, Java , Java and all the fun projects he works on - real time Java etc.

But it was the shameless plug on JavaFX (nobody really cares), Netbeans (prefer Eclipse or IDEA) and Glassfish that was not very much fun. Maybe someone at Sun said if you do not plug these, your trip will not be expensed.

Now back at the hotel, I read this blog post from the OSGi Alliance refuting James's assertion that OSGi is fat. I am pretty sure Sun (soon to be Snorkel) has tremendous NIH (Not Invented Here) or NIBU (Not Invented By Us) syndrome.

Friday, June 05, 2009

JAXB2, XMLGregorianCalendar, JODA, JSR310

The variants of xs:date as defined in the XML Schema are mapped to XMLGregorianCalendar by JAXB2. XGC is not a very fun class to work with. JODA is an open source date time API implementation that is available in the open source world, which is the primary driver behind the JSR-310 specification.

Here is an email thread in JSR-310 that summarises the mapping of xs:date and JODA/JSR 310.

Email Link

Thursday, May 14, 2009

Revert a change in SVN commit

Suppose you have made an erroneous commit on a particular file, then you can employ the following strategy.


Assume the file we are looking at is SecurityDomainObjectFactory.

Step 1: Do a SVN log on that particular file.

anil@localhost:$ svn log SecurityDomainObjectFactory.java | head -n 25
------------------------------------------------------------------------
r88837 | anil | 2009-05-13 16:55:08 -0500 (Wed, 13 May 2009) | 1 line

JBAS-6857: merge in rev 88834 from trunk
------------------------------------------------------------------------
r85945 | dimitris | 2009-03-16 14:45:12 -0500 (Mon, 16 Mar 2009) | 1 line


Step 2: Determine the two revisions.
In this case, the most recent is 88837 (anil) and 85945(dimitris).


Step 3: Merge it back
$ svn merge -r88837:85945 SecurityDomainObjectFactory.java

Step 4: SVN diff to see the changes are reverted

Step 5: Check in the reverted file
$> svn ci -m "revert the unintentional change" SecurityDomainObjectFactory.java

==================================

Friday, March 20, 2009

JAXB: Pretty print xml in marshalling

Marshaller marshaller = .....
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );

That should do the trick.

Thursday, March 19, 2009

svn merge a particular revision

Assuming that you have committed a few changes to trunk and want to merge the same to a branch, you can use the "merge -c xyz" pattern as follows:

Let us say that the revision that I committed my changes on the trunk was "86077". I do a dry run to check what changes will get merged if I do the real thing.

============================
anil@localhost:~/Branch_5_x$ svn merge -c 86077 https://svn.jboss.org/repos/jbossas/trunk/ --dry-run
U component-matrix/pom.xml
U server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
U server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
U server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
A server/src/main/org/jboss/web/deployers/SecurityActions.java
U server/src/etc/deployers/security-deployer-jboss-beans.xml
A testsuite/src/resources/web/xacml/requestAttrib/WEB-INF/jbossxacml-config.xml
A testsuite/src/resources/security/authorization/xacml-ejb/META-INF/jbossxacml-config.xml
U testsuite/imports/sections/security.xml
U testsuite/imports/sections/web.xml
U security/.classpath
A security/src/main/org/jboss/security/deployers
A security/src/main/org/jboss/security/deployers/XacmlConfigParsingDeployer.java
A security/src/main/org/jboss/security/deployers/JAXBElementParsingDeployer.java
A security/src/main/org/jboss/security/deployers/AclConfigParsingDeployer.java
U security/pom.xml
===============================

Ok. Those are the changes I want it into my branch. Now I do the real merge without the "--dry-run" option.

======================================
anil@localhost:~/Branch_5_x$ svn merge -c 86077 https://svn.jboss.org/repos/jbossas/trunk/
U component-matrix/pom.xml
U server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
U server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
U server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
A server/src/main/org/jboss/web/deployers/SecurityActions.java
U server/src/etc/deployers/security-deployer-jboss-beans.xml
A testsuite/src/resources/web/xacml/requestAttrib/WEB-INF/jbossxacml-config.xml
A testsuite/src/resources/security/authorization/xacml-ejb/META-INF/jbossxacml-config.xml
U testsuite/imports/sections/security.xml
U testsuite/imports/sections/web.xml
U security/.classpath
A security/src/main/org/jboss/security/deployers
A security/src/main/org/jboss/security/deployers/XacmlConfigParsingDeployer.java
A security/src/main/org/jboss/security/deployers/JAXBElementParsingDeployer.java
A security/src/main/org/jboss/security/deployers/AclConfigParsingDeployer.java
U security/pom.xml
anil@localhost:~/Branch_5_x$
=============================

Tuesday, March 17, 2009

JAXB Debugging Unmarshalling

When you need to debug JAXB2 unmarshalling issues, try the following:

1) Set the system property "jaxb.debug" to "true"
2) Set the event handler on the unmarshaller which will print out the errors to System.out as follows:
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());




Additional note
:

If you start seeing errors such as the sax parser not finding schema types, then look at the stack trace. If it shows com.sun.xerces (which is Sun JDK internal port of Xerces), then you will need to
either a) endorse the Xerces libraries or b) a system property
"-Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory"

http://marc.info/?l=xerces-j-user&m=117066282420361&q=raw

============================
On 26.09.2006, at 15:48, Michael Glavassevich wrote:

> Hi Simon,
>
> You weren't actually using Xerces when you ran your test. The
> com.sun.org.apache.xerces.internal.* packages originate from Sun's
> Java 5.
> Regardless of whether there are schema locations in the document or
> not it
> doesn't seem to call the LSResourceResolver. This is probably one
> of many
> bugs which we've fixed (in the last three years) or one that never
> existed
> since the Validator implementation in Xerces is significantly
> different
> than the one included in Java 5.
>
> There's one Java 5 bug [1] in particular which prevents the
> SchemaFactory's factory finder from finding the implementation on the
> classpath. If you had xercesImpl.jar in your classpath this would
> explain
> why you got the JDK default instead. To select Xerces'
> SchemaFactory you
> can set a system property -Djavax.xml.validation.SchemaFactory:
> http://www.w3.org/2001/
> XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory
> . Putting the xml-apis.jar which accompanies Xerces in your JDK's
> endorsed
> directory [2] works as well.
===============================

Tuesday, February 17, 2009

ServletContext.getResource fails

if either ServletContext.getResource or ServletContext.getResourceAsStream fails with a FileNotFoundException, ensure that the path to the resource starts with a /

Reference: https://jira.jboss.org/jira/browse/JBID-52

Thursday, January 15, 2009

Keytool CheatSheet

================================
-----Original Message-----
From: ext Mark Thomas
Sent: Friday, January 16, 2004 5:20 PM
To: 'Tomcat Users List'
Subject: RE: Using CA-issued certificates in Tomcat 5


Try this - don't delete the alias before importing the response.

What happens is:
> keytool -genkey -alias tomcat -keyalg RSA
Creates your private and public key
> keytool -certreq -keyalg RSA -alias tomcat -file certreq.csr
wraps a copy of your _public_ key in a certficate request
> ... got the certs...
CA uses their private key to sign your public key - this is essentially your
certificate
> keytool -delete -alias tomcat
This deletes your private key. This is bad.
> keytool -import -alias root -trustcacerts -file rootcert.cer
(root/intermediate/chain cert, as appropriate for the CA)
Adds the public key of your CA to your trusted certs.
> keytool -import -alias tomcat -trustcacerts -file testcert.cer
With your private key still in place, this replaces your unsigned public key
with a signed public key

You may find that the format the cert comes back in is not compatible with
keytool. I normally do the following:
1. In windows, change extension to .cer
2. Double click on .cer file.
3. On "Details" tab click "Copy to file..."
4. Select the .p7b output format and tick the box to include all certs in path.
5. Specify a file name.
6. Use key tool to import this file.

Sorry this is a windows solution but if you don't use windows as along as you
can get access to a windows box you should be able to do this.

Mark

================================