Blog do projektu Open Source JavaHotel

czwartek, 24 kwietnia 2014

Java Hotel, new version, printing and pdf generating

I deployed new version of JavaHotel application to Google App Engine infrastructure. The version is available here and source code for all application is available here (U/P user/user). This version contains PDF generating for bill issued and receipt printing (from PDF). It is also possible to save PDF created and reprint it later.
PDF generating
After issuing a bill there is a "print" button in the bill list. After clicking the button a html preview of the receipt is presented (it is very rough now, requires more elaboration for real use).
The user can download the PDF (after clicking the receipt.pdf link) and print and save PDF with description for later reuse
The PDF is generated from the HTML view.

If PDF is saved then it is available for later reuse. More the one PDF can be saved for a single bill (for instance in case of correcting) to keep all documents given to the customer.

The user can download and print again the PDF and edit the description.
How it is done
The receipt (as HTML) is generated through XSLT transformation. An example used here is available here. It is very convenient and allows to align receipt form without modifying the application. It is also possible (will be implemented later) to use more then one receipt format for different customers and services.
PDF is generated from HTML by means of iText software.
XSLT and Google App Engine
After deploying the application to Google App Engine I spent some time fighting with (in Development Mode worked correctly):
transformer = tFactory.newTransformer(StreamSource(iS.openStream())) at at at at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: Translet class loaded, but unable to create translet instance.
After applying the solution described here (deploy all jars related to xalan) the problem was resolved.
Glassfish 4.0 and GWT 2.6
I spent also some time working with problem related to Glassfish 4.0 (the same for WildFly-JBoss) and GWT 2.6
Severe: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [Set] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject] org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Set] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject] at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems( at org.jboss.weld.bootstrap.Validator.validateInjectionPoint( at org.jboss.weld.bootstrap.Validator.validateGeneralBean(
The problem is related to Guava rather but because the Guava seems to be included in gwt-servlet.jar so the problem was inherited accordingly. I'm using also Guava but before 2.6 I utilized Guava embedded in Glassfish.
The hot discussion around this issue is available here.
The problem disappeared after applying the solution described there.

  1. Prepare beans.xml file:
  2. <beans bean-discovery-mode="none" xmlns:xsi="" xmlns=""></beans>
  3. Unpack standard gwt-servlet.jar 
  4. Put this file into META-INF directory 
  5. Pack gwt-servler.jar and use it instead of original one.

Brak komentarzy:

Prześlij komentarz