konik-io / konik

A library to create, read and validate ZUGFeRD compliant invoices. Available for Java and .NET
https://konik.io
Other
46 stars 18 forks source link

Not deployable due to validator dependencies / CDI #60

Closed djmj closed 5 years ago

djmj commented 5 years ago

Hello, i succesfully created a Zugferd compliant invoice with this library in a console app but could not deploy it to a glassfish 5 server.

The validator classes ValidatorInvoice and MonetarySummationValidator have direct dependencies on apache validation and google commons guava. Glassfish already comes with hibernate validator.

Furthermore ValidatorInvoice uses CDI annotations @Singleton and injections which lead to following exception:

2018-09-24T23:29:04.818+0000|Information: WELD-000119: Not generating any bean definitions from io.konik.PdfHandler because of underlying class loading error: Type io.konik.harness.AppendParameter not found.  If this is unexpected, enable DEBUG logging to see the full error.
2018-09-24T23:29:06.208+0000|Schwerwiegend: Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type MonetarySummationValidator with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject public io.konik.validation.InvoiceValidator(Validator, MonetarySummationValidator)
  at io.konik.validation.InvoiceValidator.<init>(InvoiceValidator.java:56)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:239)

@Singleton

The singleton pattern seems a little to forcing. Should this not be within the responsibility and scope of the implementing application?

We use hibernate ORM / validator and already have a singleton bean Validator in our application and validate Invoice like any other bean:

this.validator.validate(invoice, InvoiceValidator.resolveIntoValidationGroups(level));

The drawback is the lost MonetarySummation validation which relates to #61.

Vad1mo commented 5 years ago

@djmj did you check the Setup section in the docs?

https://konik.io/docs/index.html#setup

This deals with Java EE. However if it isn't working it might need and update to comply with usecase for EE7/8

djmj commented 5 years ago

Yes i checked it and only konic and nv-18n jar are on build / deployment path.

I also tried to remove the class from CDI scanning using beans.xml exclude node but could not get it to work. I am not that familiar with CDI but this maybe looks similar to: https://github.com/google/guava/issues/1527

Maybe its a glassfish issue.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.