lunedì 16 novembre 2020

Java image rendering and Crystal report Error the definitive guide !

I've be working for a while into a Crystal report Java project.

The aim is to generate in background and email PDF files produced by Crystal report document, I built two projects on that one that generate over a http call the desired document and the second that runs every n minutes lookup the lines in a table and produce the related documents.

Everything works quite well in Eclipse but when you move in production on a linux machine there's come the rain.

The first error in the stack comes with these lines:

 javax.imageio.spi.ImageReaderSpi: Provider com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi could not be instantiated
        at java.util.ServiceLoader.fail(Unknown Source)
        at java.util.ServiceLoader.access$100(Unknown Source)
        at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
        at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
        at java.util.ServiceLoader$1.next(Unknown Source)
        at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknown Source)


So i'm started struggling to find if there's a missing library or not trying to repack the jar in different ways without success.

 After a day (or more) spent and a very big headache, I scrolled down the log... saying to myself in case there's some other interesting information....  and taac here's the trick, the root cause is java.lang.IllegalArgumentException: vendorName == null!

  Caused by: java.lang.IllegalArgumentException: vendorName == null!
 
       at javax.imageio.spi.IIOServiceProvider.<init>(Unknown Source)
        at javax.imageio.spi.ImageReaderWriterSpi.<init>(Unknown Source)
        at javax.imageio.spi.ImageReaderSpi.<init>(Unknown Source)
        at com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi.<init>(CLibJPEGImageReaderSpi.java:80)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        ... 99 more

This type of error handling is one of the thing that makes me hate java but on the other hand, i still love it, not easy language to learn but very powerfull and clean!


So, googling a bit I found some useful tips: https://stackoverflow.com/questions/7051603/jai-vendorname-null

https://thierrywasyl.wordpress.com/2009/07/24/jai-how-to-solve-vendorname-null-exception/

The solution is to add these lines in a manifest.mf file after the jar is produced, put that in the META-INF directory

Implementation-Vendor: Sun Microsystems, Inc
Implementation-Title: Java Runtime Environment
Implementation-Version: 1.6.0

 


mercoledì 29 luglio 2020

License needed for teams at today

Teams Connection error 4c7

recently I had a connection error on Teams for a user not yet migrated to 365.
user can't connect to portal.office.com nor to teams.

Root cause was that on premise the mailbox was shared since it was used both by a manager and a secretary.

when mailbox has been recovered to normal login to office immediately worked.

Desktop Teams application was still fiailing. Issue was the SSO, so modified that file :

%AppData%\Roaming\Microsoft\Teams\settings.json
"enableSso":true/false



mercoledì 1 luglio 2020

Regular expression to find digit in a string

>>> import re
>>> re.findall(r'\d+', 'hello 42 I\'m a 32 string 30')
['42', '32', '30']

If you only want numbers delimited by word boundaries (space, period, comma), you can use \b :
>>> re.findall(r'\b\d+\b', 'he33llo 42 I\'m a 32 string 30')
['42', '32', '30']
 

lunedì 22 giugno 2020

Words

The way she has it worded has me a little confused...

mercoledì 10 giugno 2020

mercoledì 27 maggio 2020

Creating a java app to render crystal report I encountered this excecption

 com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi
 could not be instantiated

The problem is caused by vendorName == null exception

To resolve the issue edit the manifest file produced by eclipse and add these lines: 
Manifest-Version: 1.0
Class-Path: .
Main-Class: com.pacorini.crystal.Starter
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Title: Java Runtime Environment
Implementation-Version: 1.8.0.191

martedì 5 maggio 2020

Come attivare git su un progetto eclipse esistente Git/Code commit

Non so chi ha scritto il codice dell'integrazione tra Eclipse e Git ma secondo me ha dimenticato di aggiungere qualche feature indispensabile.

Sarà capitato anche a voi di scrivere un progetto e poi decidere di salvarlo su git o quantomeno di gestire il versioning.
Fino a qui sembra semplice ma quando si attiva la sicronizzazione git vuole per forza creare un repository in una directory diversa da quella del progetto dove poi trasferisce il vostro codice.
E questa è una dei motivi per cui continuo a preferire SVN rispetto a Git. SVN sembra però essere un po' morto a differenza di Git.
Nel mio team pertanto abbiamo deciso di utilizzare un repository comune online (non github) sul quale scaricare il nostro codice.

Il punto è che ho un sacco di codice che vorrei caricare senza dover stravolgere i miei workspace.

Dopo svariati tentativi non sono riuscito a trovare una funzione in eclipse che mi permetta di collegare un progetto esistene a un repository remoto.
Mi ha salvato una serie di comandi da shell:
1. entrare nella folder del progetto che si desidera sincronizzare
2. abilitare la cartella a git con: git init
3. aggiungere il contenuto con: git add .
4. aggiungere un commento: git commit -m "Initial commit"
5. eseguire il commit del progetto con: git push -all

A questo punto aprire eclipse (se è aperto chiudere e riaprire il progetto) e sarà sincronizzato con il vostro code repository !!


Se qualcuno avesse le istruzioni visuali si senta libero di aggiungerle nei commenti. Se vi è stato utile lasciate un commento!