acciduck / jscep

Automatically exported from code.google.com/p/jscep
MIT License
0 stars 0 forks source link

NullPointerException hard to avoid if not redefining the LoggingUtil.java class. #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use JSCEP on a VM where the classloader returns null at getPackage(), 
invoked indirectly by Class.getPackage(). It happens on our ServiceDirector and 
the behaviour is legal, standing to the JavaDoc

What is the expected output?
CRL download (the one I tested) and other operations should work.

What do you see instead?
ExceptionInInitializerError, with root cause NullPointerException. Subsequent 
calls just give ClassNotFoundException or similar (can't remember)

What version of the product are you using? On what operating system?
JSCEP 1.3 on Linux Centos 6.0, JDK1.6.0_21

Please provide any additional information below.
The offending code is in org.jscep.util.LoggingUtil.getLogger(Class<?> type).
Replace:
    return getLogger(type.getPackage().getName());
With:
    final String canonicalName = type.getCanonicalName();
    return getLogger(canonicalName.substring(0, canonicalName.lastIndexOf(".")));
..or similar: I'm not sure whether you meant all the jscep code to be under a 
generic "org.jscep" Package or every class under its rightful, complete package 
name, but if it was the first, I suspect you would have used a constant.

Original issue reported on code.google.com by mda...@ubq.thrupoint.net on 29 May 2012 at 10:19

GoogleCodeExporter commented 8 years ago
Just to give you more feedback, the jscep classes are rebundled in our app and 
the META-INF/MANIFEST.MF file rewritten, but I was told that the MANIFEST only 
adds information to Package objects, which are created independently, so it 
might happen in some other containers.

Original comment by mda...@ubq.thrupoint.net on 29 May 2012 at 10:22

GoogleCodeExporter commented 8 years ago

Original comment by da...@grant.org.uk on 11 Jun 2012 at 12:10

GoogleCodeExporter commented 8 years ago

Original comment by da...@grant.org.uk on 21 Aug 2012 at 11:58