Blog do projektu Open Source JavaHotel

czwartek, 24 kwietnia 2014

Java Hotel, new version, printing and pdf generating

Introduction
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 com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.defineTransletClasses(TemplatesImpl.java:352) at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:366) at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:399) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:634) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:45) 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 com.google.gwt.thirdparty.guava.common.util.concurrent.ServiceManager(Set)] org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Set] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.gwt.thirdparty.guava.common.util.concurrent.ServiceManager(Set)] at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:403) at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:325) at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:177)
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="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"></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