ERROR: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.

702 views
Skip to first unread message

Tiago Ferreira Ceridorio

unread,
Mar 1, 2017, 10:45:02 AM3/1/17
to iDempiere
Hi,
I have problems on my plugin because it uses org.adempiere.report.jasper and org.apache.commons.logging but the jar fop-transcoder-allinone-1.1.jar exposes the package org.apache.commons.logging.
Se error above.

GRAVE: java.lang.ExceptionInInitializerError
org
.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
        at org
.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
        at org
.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
        at org
.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
        at org
.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
        at net
.sf.jasperreports.engine.util.JRLoader.<clinit>(JRLoader.java:81)
        at net
.sf.jasperreports.engine.JRPropertiesUtil.loadProperties(JRPropertiesUtil.java:102)
        at net
.sf.jasperreports.engine.DefaultJasperReportsContext.initProperties(DefaultJasperReportsContext.java:99)
        at net
.sf.jasperreports.engine.DefaultJasperReportsContext.<init>(DefaultJasperReportsContext.java:76)
        at net
.sf.jasperreports.engine.DefaultJasperReportsContext.<clinit>(DefaultJasperReportsContext.java:59)
        at net
.sf.jasperreports.engine.data.JRXmlDataSource.<init>(JRXmlDataSource.java:361)
        at net
.sf.jasperreports.engine.data.JRXmlDataSource.<init>(JRXmlDataSource.java:357)
        at org
.myapp.sped.nfe.util.NFeUtil.genDANFe(NFeUtil.java:590)
        at org
.myapp.sped.nfe.util.NFeEmail.sendMail(NFeEmail.java:125)
        at org
.myapp.sped.nfe.model.MNFe.authorizeNFe(MNFe.java:2515)
        at org
.myapp.sped.nfe.model.MNFeLot.consultaNFe(MNFeLot.java:360)
        at org
.myapp.sped.nfe.process.ProcLotReturn.doIt(ProcLotReturn.java:94)
        at org
.compiere.process.SvrProcess.process(SvrProcess.java:198)
        at org
.compiere.process.SvrProcess.startProcess(SvrProcess.java:144)
        at org
.adempiere.util.ProcessUtil.startJavaProcess(ProcessUtil.java:172)
        at org
.compiere.apps.AbstractProcessCtl.startProcess(AbstractProcessCtl.java:466)
        at org
.compiere.apps.AbstractProcessCtl.run(AbstractProcessCtl.java:234)
        at org
.adempiere.webui.apps.WProcessCtl.process(WProcessCtl.java:197)
        at org
.adempiere.webui.apps.AbstractProcessDialog$ProcessDialogRunnable.doRun(AbstractProcessDialog.java:1061)
        at org
.adempiere.util.ContextRunnable.run(ContextRunnable.java:38)
        at org
.adempiere.webui.apps.DesktopRunnable.run(DesktopRunnable.java:40)
        at java
.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java
.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java
.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java
.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java
.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)
        at org
.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
        at org
.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
       
... 31 more
Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
        at org
.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:385)
       
... 32 more



Tiago Ferreira Ceridorio

unread,
Apr 5, 2017, 3:32:40 PM4/5/17
to iDempiere
Hi, 
Any Idea?

Eduardo JM

unread,
Jan 18, 2019, 6:44:32 AM1/18/19
to iDempiere
Hi Thiago.
To solve this problem, before you call your method, change the classload from current thread, like this:


ClassLoader cl1 = Thread.currentThread().getContextClassLoader();
        ClassLoader cl2 = JasperReport.class.getClassLoader();

        try {

            if (!cl1.equals(cl2)) {
                Thread.currentThread().setContextClassLoader(cl2);
            }

            
            return MNFeLot.consultaNFe....

        } catch (Exception e) {

            LOGGER.debug("Falha ao gerar o DANFE da Nota Fiscal. Erro: " + e.getMessage());
            LOGGER.error(e);

            throw e;

        } finally {

            if (!cl1.equals(Thread.currentThread().getContextClassLoader())) {
                Thread.currentThread().setContextClassLoader(cl1);
            }

        }


Reply all
Reply to author
Forward
0 new messages