Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » No suitable Log constructor error
No suitable Log constructor error [message #91546] Thu, 05 July 2007 02:00 Go to next message
Marcos Pereira is currently offline Marcos PereiraFriend
Messages: 4
Registered: July 2009
Junior Member
Hi all.

I have been testing the JSP Examples Bundle found at:
http://www.eclipse.org/equinox/server/jsp_support.php

It works fine without changes, but when I try to add a dependency to
org.apache.log4j (either as Import-Package or Require-Bundle) the error
below throws out.

Any clue about how to fix this? I checked either on this group and on
Eclipse bugzilla but unfortunately I wasn't able to find a solution so far.

org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@ff2413 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@ff2413 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
at
org.apache.jasper.EmbeddedServletOptions.<init>(EmbeddedServletOptions.java:43)
at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:97 )
at org.eclipse.equinox.jsp.jasper.JspServlet.init(JspServlet.ja va:81)
at
org.eclipse.equinox.http.helper.ContextPathServletAdaptor.in it(ContextPathServletAdaptor.java:31)
at
org.eclipse.equinox.http.servlet.internal.ServletRegistratio n.init(ServletRegistration.java:64)
at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.regis terServlet(ProxyServlet.java:140)
at
org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.re gisterServlet(HttpServiceImpl.java:50)
at
org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracke r.addingService(Activator.java:48)
at
org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1064)
at
org.osgi.util.tracker.ServiceTracker$Tracked.trackInitialSer vices(ServiceTracker.java:926)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:330)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:274)
at org.eclipse.equinox.jsp.examples.Activator.start(Activator.j ava:26)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:999)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:993)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:974)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:350)
at
org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1118)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:634)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:508)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:282)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:468)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:195)
at
org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:297)
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable
Log constructor [Ljava.lang.Class;@ff2413 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
.... 29 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
.... 30 more
Re: No suitable Log constructor error [message #91592 is a reply to message #91546] Thu, 05 July 2007 16:59 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon KaegiFriend
Messages: 381
Registered: July 2009
Senior Member
Hi Marcos,

Please open a bug for this - this is going to be tough to deal with.
The problem here is that your use of log4j in your jsp is being leaked via
the context class loader into the jasper implementations use of commons
logging.
The commons logging discovery process will find log4j on the CCL but not in
it's own class hierarchy and will then run into problems.

I can think of two workarounds:
1) Remove your direct dependency on log4j from your jsp bundle and instead
move it to another bundle you can call from your jsp.
2) If you're in full control of your platform add a fragment to the
commons.logging bundle that imports log4j
3) Take a look at SLF4J and jcl-over-slf4j and create bundles to replace the
commons.logging bundle.

HTH
-Simon

"Marcos Pereira" <marcos-luiz@ig.com.br> wrote in message
news:f6hmf2$3dp$1@build.eclipse.org...
> Hi all.
>
> I have been testing the JSP Examples Bundle found at:
> http://www.eclipse.org/equinox/server/jsp_support.php
>
> It works fine without changes, but when I try to add a dependency to
> org.apache.log4j (either as Import-Package or Require-Bundle) the error
> below throws out.
>
> Any clue about how to fix this? I checked either on this group and on
> Eclipse bugzilla but unfortunately I wasn't able to find a solution so
> far.
>
> org.apache.commons.logging.LogConfigurationException:
> org.apache.commons.logging.LogConfigurationException: No suitable Log
> constructor [Ljava.lang.Class;@ff2413 for
> org.apache.commons.logging.impl.Log4JLogger (Caused by
> java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
> org.apache.commons.logging.LogConfigurationException: No suitable Log
> constructor [Ljava.lang.Class;@ff2413 for
> org.apache.commons.logging.impl.Log4JLogger (Caused by
> java.lang.NoClassDefFoundError: org/apache/log4j/Category))
> at
> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
> at
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
> at
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
> at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
> at
> org.apache.jasper.EmbeddedServletOptions.<init>(EmbeddedServletOptions.java:43)
> at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:97 )
> at org.eclipse.equinox.jsp.jasper.JspServlet.init(JspServlet.ja va:81)
> at
> org.eclipse.equinox.http.helper.ContextPathServletAdaptor.in it(ContextPathServletAdaptor.java:31)
> at
> org.eclipse.equinox.http.servlet.internal.ServletRegistratio n.init(ServletRegistration.java:64)
> at
> org.eclipse.equinox.http.servlet.internal.ProxyServlet.regis terServlet(ProxyServlet.java:140)
> at
> org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.re gisterServlet(HttpServiceImpl.java:50)
> at
> org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracke r.addingService(Activator.java:48)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1064)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.trackInitialSer vices(ServiceTracker.java:926)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:330)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:274)
> at org.eclipse.equinox.jsp.examples.Activator.start(Activator.j ava:26)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:999)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:993)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:974)
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:350)
> at
> org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1118)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:634)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:508)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:282)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:468)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:195)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:297)
> Caused by: org.apache.commons.logging.LogConfigurationException: No
> suitable Log constructor [Ljava.lang.Class;@ff2413 for
> org.apache.commons.logging.impl.Log4JLogger (Caused by
> java.lang.NoClassDefFoundError: org/apache/log4j/Category)
> at
> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
> at
> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
> ... 29 more
> Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.getConstructor(Unknown Source)
> at
> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
> ... 30 more
>
Re: No suitable Log constructor error [message #91721 is a reply to message #91592] Sun, 08 July 2007 14:05 Go to previous messageGo to next message
Marcos Pereira is currently offline Marcos PereiraFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Simon,

Thank you very much for the hints. I tried 2) and 3) (unfortunately I
couldn't drop log4j dependency, so 1) was not an option for me).

Bad news is that neither 2) and 3) worked too. However, looking into SLF4J
pattern I had the idea to build a log4j wrapper in same way as
jcl-over-slf4j and that finally worked. I added some code snippet below, but
I can provide the full solution for anyone interested.

Anyway, your hints pointed me to a solution. Thanks!

Marcos


package org.apache.log4j;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Logger {

private Log log;

private Logger(Class clazz) {
log = LogFactory.getLog(clazz);
}

private Logger(String name) {
log = LogFactory.getLog(name);
}

public static Logger getLogger(Class clazz) {
return new Logger(clazz);
}

public void debug(Object message) {
System.out.println("DEBUG: " + message);
log.debug(message);
}

public void debug(Object message, Throwable t) {
System.out.println("DEBUG: " + message);
log.debug(message, t);
}

....

}


"Simon Kaegi" <simon_kaegi@ca.ibm.com> escreveu na mensagem
news:f6j80l$p1q$1@build.eclipse.org...
> Hi Marcos,
>
> Please open a bug for this - this is going to be tough to deal with.
> The problem here is that your use of log4j in your jsp is being leaked via
> the context class loader into the jasper implementations use of commons
> logging.
> The commons logging discovery process will find log4j on the CCL but not
> in it's own class hierarchy and will then run into problems.
>
> I can think of two workarounds:
> 1) Remove your direct dependency on log4j from your jsp bundle and instead
> move it to another bundle you can call from your jsp.
> 2) If you're in full control of your platform add a fragment to the
> commons.logging bundle that imports log4j
> 3) Take a look at SLF4J and jcl-over-slf4j and create bundles to replace
> the commons.logging bundle.
>
> HTH
> -Simon
>
> "Marcos Pereira" <marcos-luiz@ig.com.br> wrote in message
> news:f6hmf2$3dp$1@build.eclipse.org...
>> Hi all.
>>
>> I have been testing the JSP Examples Bundle found at:
>> http://www.eclipse.org/equinox/server/jsp_support.php
>>
>> It works fine without changes, but when I try to add a dependency to
>> org.apache.log4j (either as Import-Package or Require-Bundle) the error
>> below throws out.
>>
>> Any clue about how to fix this? I checked either on this group and on
>> Eclipse bugzilla but unfortunately I wasn't able to find a solution so
>> far.
>>
>> org.apache.commons.logging.LogConfigurationException:
>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>> constructor [Ljava.lang.Class;@ff2413 for
>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>> java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>> constructor [Ljava.lang.Class;@ff2413 for
>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>> java.lang.NoClassDefFoundError: org/apache/log4j/Category))
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
>> at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
>> at
>> org.apache.jasper.EmbeddedServletOptions.<init>(EmbeddedServletOptions.java:43)
>> at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:97 )
>> at org.eclipse.equinox.jsp.jasper.JspServlet.init(JspServlet.ja va:81)
>> at
>> org.eclipse.equinox.http.helper.ContextPathServletAdaptor.in it(ContextPathServletAdaptor.java:31)
>> at
>> org.eclipse.equinox.http.servlet.internal.ServletRegistratio n.init(ServletRegistration.java:64)
>> at
>> org.eclipse.equinox.http.servlet.internal.ProxyServlet.regis terServlet(ProxyServlet.java:140)
>> at
>> org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.re gisterServlet(HttpServiceImpl.java:50)
>> at
>> org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracke r.addingService(Activator.java:48)
>> at
>> org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1064)
>> at
>> org.osgi.util.tracker.ServiceTracker$Tracked.trackInitialSer vices(ServiceTracker.java:926)
>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:330)
>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:274)
>> at org.eclipse.equinox.jsp.examples.Activator.start(Activator.j ava:26)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:999)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:993)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:974)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
>> at
>> org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:350)
>> at
>> org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1118)
>> at
>> org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:634)
>> at
>> org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:508)
>> at
>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:282)
>> at
>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:468)
>> at
>> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:195)
>> at
>> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:297)
>> Caused by: org.apache.commons.logging.LogConfigurationException: No
>> suitable Log constructor [Ljava.lang.Class;@ff2413 for
>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>> java.lang.NoClassDefFoundError: org/apache/log4j/Category)
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
>> ... 29 more
>> Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>> at java.lang.Class.getConstructor0(Unknown Source)
>> at java.lang.Class.getConstructor(Unknown Source)
>> at
>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
>> ... 30 more
>>
>
>
Re: No suitable Log constructor error [message #91734 is a reply to message #91721] Sun, 08 July 2007 14:46 Go to previous messageGo to next message
Marcos Pereira is currently offline Marcos PereiraFriend
Messages: 4
Registered: July 2009
Junior Member
The bug entry #195765 was added to Eclipse bugzilla, regarding this topic.
Link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=195765

Marcos


"Marcos Pereira" <marcos-luiz@ig.com.br> escreveu na mensagem
news:f6qr01$eoe$1@build.eclipse.org...
> Hi Simon,
>
> Thank you very much for the hints. I tried 2) and 3) (unfortunately I
> couldn't drop log4j dependency, so 1) was not an option for me).
>
> Bad news is that neither 2) and 3) worked too. However, looking into SLF4J
> pattern I had the idea to build a log4j wrapper in same way as
> jcl-over-slf4j and that finally worked. I added some code snippet below,
> but I can provide the full solution for anyone interested.
>
> Anyway, your hints pointed me to a solution. Thanks!
>
> Marcos
>
>
> package org.apache.log4j;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
>
> public class Logger {
>
> private Log log;
>
> private Logger(Class clazz) {
> log = LogFactory.getLog(clazz);
> }
>
> private Logger(String name) {
> log = LogFactory.getLog(name);
> }
>
> public static Logger getLogger(Class clazz) {
> return new Logger(clazz);
> }
>
> public void debug(Object message) {
> System.out.println("DEBUG: " + message);
> log.debug(message);
> }
>
> public void debug(Object message, Throwable t) {
> System.out.println("DEBUG: " + message);
> log.debug(message, t);
> }
>
> ...
>
> }
>
>
> "Simon Kaegi" <simon_kaegi@ca.ibm.com> escreveu na mensagem
> news:f6j80l$p1q$1@build.eclipse.org...
>> Hi Marcos,
>>
>> Please open a bug for this - this is going to be tough to deal with.
>> The problem here is that your use of log4j in your jsp is being leaked
>> via the context class loader into the jasper implementations use of
>> commons logging.
>> The commons logging discovery process will find log4j on the CCL but not
>> in it's own class hierarchy and will then run into problems.
>>
>> I can think of two workarounds:
>> 1) Remove your direct dependency on log4j from your jsp bundle and
>> instead move it to another bundle you can call from your jsp.
>> 2) If you're in full control of your platform add a fragment to the
>> commons.logging bundle that imports log4j
>> 3) Take a look at SLF4J and jcl-over-slf4j and create bundles to replace
>> the commons.logging bundle.
>>
>> HTH
>> -Simon
>>
>> "Marcos Pereira" <marcos-luiz@ig.com.br> wrote in message
>> news:f6hmf2$3dp$1@build.eclipse.org...
>>> Hi all.
>>>
>>> I have been testing the JSP Examples Bundle found at:
>>> http://www.eclipse.org/equinox/server/jsp_support.php
>>>
>>> It works fine without changes, but when I try to add a dependency to
>>> org.apache.log4j (either as Import-Package or Require-Bundle) the error
>>> below throws out.
>>>
>>> Any clue about how to fix this? I checked either on this group and on
>>> Eclipse bugzilla but unfortunately I wasn't able to find a solution so
>>> far.
>>>
>>> org.apache.commons.logging.LogConfigurationException:
>>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>>> constructor [Ljava.lang.Class;@ff2413 for
>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
>>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>>> constructor [Ljava.lang.Class;@ff2413 for
>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category))
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
>>> at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
>>> at
>>> org.apache.jasper.EmbeddedServletOptions.<init>(EmbeddedServletOptions.java:43)
>>> at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:97 )
>>> at org.eclipse.equinox.jsp.jasper.JspServlet.init(JspServlet.ja va:81)
>>> at
>>> org.eclipse.equinox.http.helper.ContextPathServletAdaptor.in it(ContextPathServletAdaptor.java:31)
>>> at
>>> org.eclipse.equinox.http.servlet.internal.ServletRegistratio n.init(ServletRegistration.java:64)
>>> at
>>> org.eclipse.equinox.http.servlet.internal.ProxyServlet.regis terServlet(ProxyServlet.java:140)
>>> at
>>> org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.re gisterServlet(HttpServiceImpl.java:50)
>>> at
>>> org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracke r.addingService(Activator.java:48)
>>> at
>>> org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1064)
>>> at
>>> org.osgi.util.tracker.ServiceTracker$Tracked.trackInitialSer vices(ServiceTracker.java:926)
>>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:330)
>>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:274)
>>> at org.eclipse.equinox.jsp.examples.Activator.start(Activator.j ava:26)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:999)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:993)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:974)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
>>> at
>>> org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:350)
>>> at
>>> org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1118)
>>> at
>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:634)
>>> at
>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:508)
>>> at
>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:282)
>>> at
>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:468)
>>> at
>>> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:195)
>>> at
>>> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:297)
>>> Caused by: org.apache.commons.logging.LogConfigurationException: No
>>> suitable Log constructor [Ljava.lang.Class;@ff2413 for
>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category)
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
>>> ... 29 more
>>> Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
>>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>>> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>>> at java.lang.Class.getConstructor0(Unknown Source)
>>> at java.lang.Class.getConstructor(Unknown Source)
>>> at
>>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
>>> ... 30 more
>>>
>>
>>
>
>
Re: No suitable Log constructor error [message #91749 is a reply to message #91734] Sun, 08 July 2007 14:49 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon KaegiFriend
Messages: 381
Registered: July 2009
Senior Member
Thanks Marcos.

I'm definitely interested in your approach if you want to add it as
attachment to the bug.

-Simon

"Marcos Pereira" <marcos-luiz@ig.com.br> wrote in message
news:f6qtc2$jbb$1@build.eclipse.org...
> The bug entry #195765 was added to Eclipse bugzilla, regarding this topic.
> Link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=195765
>
> Marcos
>
>
> "Marcos Pereira" <marcos-luiz@ig.com.br> escreveu na mensagem
> news:f6qr01$eoe$1@build.eclipse.org...
>> Hi Simon,
>>
>> Thank you very much for the hints. I tried 2) and 3) (unfortunately I
>> couldn't drop log4j dependency, so 1) was not an option for me).
>>
>> Bad news is that neither 2) and 3) worked too. However, looking into
>> SLF4J pattern I had the idea to build a log4j wrapper in same way as
>> jcl-over-slf4j and that finally worked. I added some code snippet below,
>> but I can provide the full solution for anyone interested.
>>
>> Anyway, your hints pointed me to a solution. Thanks!
>>
>> Marcos
>>
>>
>> package org.apache.log4j;
>>
>> import org.apache.commons.logging.Log;
>> import org.apache.commons.logging.LogFactory;
>>
>> public class Logger {
>>
>> private Log log;
>>
>> private Logger(Class clazz) {
>> log = LogFactory.getLog(clazz);
>> }
>>
>> private Logger(String name) {
>> log = LogFactory.getLog(name);
>> }
>>
>> public static Logger getLogger(Class clazz) {
>> return new Logger(clazz);
>> }
>>
>> public void debug(Object message) {
>> System.out.println("DEBUG: " + message);
>> log.debug(message);
>> }
>>
>> public void debug(Object message, Throwable t) {
>> System.out.println("DEBUG: " + message);
>> log.debug(message, t);
>> }
>>
>> ...
>>
>> }
>>
>>
>> "Simon Kaegi" <simon_kaegi@ca.ibm.com> escreveu na mensagem
>> news:f6j80l$p1q$1@build.eclipse.org...
>>> Hi Marcos,
>>>
>>> Please open a bug for this - this is going to be tough to deal with.
>>> The problem here is that your use of log4j in your jsp is being leaked
>>> via the context class loader into the jasper implementations use of
>>> commons logging.
>>> The commons logging discovery process will find log4j on the CCL but not
>>> in it's own class hierarchy and will then run into problems.
>>>
>>> I can think of two workarounds:
>>> 1) Remove your direct dependency on log4j from your jsp bundle and
>>> instead move it to another bundle you can call from your jsp.
>>> 2) If you're in full control of your platform add a fragment to the
>>> commons.logging bundle that imports log4j
>>> 3) Take a look at SLF4J and jcl-over-slf4j and create bundles to replace
>>> the commons.logging bundle.
>>>
>>> HTH
>>> -Simon
>>>
>>> "Marcos Pereira" <marcos-luiz@ig.com.br> wrote in message
>>> news:f6hmf2$3dp$1@build.eclipse.org...
>>>> Hi all.
>>>>
>>>> I have been testing the JSP Examples Bundle found at:
>>>> http://www.eclipse.org/equinox/server/jsp_support.php
>>>>
>>>> It works fine without changes, but when I try to add a dependency to
>>>> org.apache.log4j (either as Import-Package or Require-Bundle) the error
>>>> below throws out.
>>>>
>>>> Any clue about how to fix this? I checked either on this group and on
>>>> Eclipse bugzilla but unfortunately I wasn't able to find a solution so
>>>> far.
>>>>
>>>> org.apache.commons.logging.LogConfigurationException:
>>>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>>>> constructor [Ljava.lang.Class;@ff2413 for
>>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
>>>> org.apache.commons.logging.LogConfigurationException: No suitable Log
>>>> constructor [Ljava.lang.Class;@ff2413 for
>>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category))
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
>>>> at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
>>>> at
>>>> org.apache.jasper.EmbeddedServletOptions.<init>(EmbeddedServletOptions.java:43)
>>>> at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:97 )
>>>> at org.eclipse.equinox.jsp.jasper.JspServlet.init(JspServlet.ja va:81)
>>>> at
>>>> org.eclipse.equinox.http.helper.ContextPathServletAdaptor.in it(ContextPathServletAdaptor.java:31)
>>>> at
>>>> org.eclipse.equinox.http.servlet.internal.ServletRegistratio n.init(ServletRegistration.java:64)
>>>> at
>>>> org.eclipse.equinox.http.servlet.internal.ProxyServlet.regis terServlet(ProxyServlet.java:140)
>>>> at
>>>> org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.re gisterServlet(HttpServiceImpl.java:50)
>>>> at
>>>> org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracke r.addingService(Activator.java:48)
>>>> at
>>>> org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1064)
>>>> at
>>>> org.osgi.util.tracker.ServiceTracker$Tracked.trackInitialSer vices(ServiceTracker.java:926)
>>>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:330)
>>>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.jav a:274)
>>>> at org.eclipse.equinox.jsp.examples.Activator.start(Activator.j ava:26)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:999)
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:993)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:974)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:350)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1118)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:634)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:508)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:282)
>>>> at
>>>> org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:468)
>>>> at
>>>> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:195)
>>>> at
>>>> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:297)
>>>> Caused by: org.apache.commons.logging.LogConfigurationException: No
>>>> suitable Log constructor [Ljava.lang.Class;@ff2413 for
>>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category)
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
>>>> ... 29 more
>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
>>>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>>>> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>>>> at java.lang.Class.getConstructor0(Unknown Source)
>>>> at java.lang.Class.getConstructor(Unknown Source)
>>>> at
>>>> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
>>>> ... 30 more
>>>>
>>>
>>>
>>
>>
>
>
Re: No suitable Log constructor error [message #102885 is a reply to message #91734] Sat, 15 December 2007 12:17 Go to previous message
Eclipse UserFriend
Originally posted by: scof.optonline.net

I'm experiencing a similar problem. Very insidious; I struggled for a long time before stumbling on this thread. My ultimate solution was to create a fragment for the commons-logging bundle.

You've entered a bug for this against eclipse, but it seems to me this is a commons-logging issue rather than a eclipse one, no?
Previous Topic:jvm.dll and Could not reserve enough space for object heap
Next Topic:newbie: management protocol?
Goto Forum:
  


Current Time: Fri Apr 19 16:55:24 GMT 2024

Powered by FUDForum. Page generated in 0.02276 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top