[ 
https://issues.apache.org/jira/browse/PDFBOX-5242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17385641#comment-17385641
 ] 

Clifford Dann commented on PDFBOX-5242:
---------------------------------------

It's not, they just  have  not set it set up correctly, this will always cause 
a java.util.ServiceConfigurationError error  and is related to JEE and will 
only happen if you have more than one war file deployed.

To get around this problem in the end, as my comments above are incorrect, as 
it depends if tomcat is already  running or not, and gave some misleading 
results

 

The actual problem is that {color:#1d1c1d}java.util.ServiceLoader{color} just 
dose not work with JEE as where it gets the classes from dose not take into 
account that there are multiple class paths and each are associated with a war 
file, and what it dose is returns LoggerBridge from the original class loader 
and returns JDKLoggerBridge from the current class loader so when ServiceLoader 
dose if (service.isAssignableFrom(clazz)) { too check if it is ok, it fails as 
they come from separate class loaders.

 

To get around this problem I had to download the source and change the code and 
removed the use of {color:#1d1c1d}java.util.ServiceLoader{color} and got the 
class directly. so in my copy LoggerFactory getLogger dose return new 
JDKLogger(java.util.logging.Logger.getLogger(cls.getName()));

 

and once that started to work it fell over on CacheFactory for the same reason 
so I made  cacheBridge = new SoftReferenceCacheBridge();

 

I do not know too much about {color:#1d1c1d}java.util.ServiceLoader, but from 
google I get the impression it just dose not work with JEE containers.{color}

> LoggerBridge loading under the wrong class loader
> -------------------------------------------------
>
>                 Key: PDFBOX-5242
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5242
>             Project: PDFBox
>          Issue Type: Bug
>          Components: JBIG2
>    Affects Versions: 3.0.0 JBIG2, 3.0.1 JBIG2, 3.0.2 JBIG2, 3.0.3 JBIG2
>         Environment: Java 16
>            Reporter: Clifford Dann
>            Priority: Major
>
> When used in a Tomcat servelet LoggerBridge has a different class loader to 
> JDKLoggerBridge  so when it dose {color:#1d1c1d}if 
> (service.isAssignableFrom(clazz)) {{color} in java.util.ServiceLoader it 
> fails.
> took the source to 3.0.3 and replaced all.
> private static final Logger log
> with
> private final Logger log
> and also added , Thread.currentThread().getContextClassLoader() as a 
> parameter to LoggerFactory.getLogger .
>  
> This fixed the problem for me, not too sure if 
> Thread.currentThread().getContextClassLoader() is over kill as I think it is 
> the static that is causing the problem.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to