users@glassfish.java.net

RE: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Wed, 26 Aug 2009 22:17:32 -0400

Optional Packages
domain-dir/lib/ext is a java.ext.dirs directory and is the location for installing optional packages.

Global Sharing
Place libraries in domain-dir/lib and domain-dir/lib/classes to add
libraries to the common classloader. This is commonly used for
libraries like JDBC drivers that used by multiple applications.
Requires an AS restart.

i would
cp log4j*.jar to /domain-dir/lib/ext FIRST
and if not log4j still CNFE
cp log4j*.jar domain-dir/lib

//our of curiosity how are you instantantiating the Log4j classes?

import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;

static final Category log = Category.getInstance(YouClassName.class);
static final String LOG_PROPERTIES_FILE = "log4J.properties"; //PUT THIS at WEB-INF/classes

//i use this standard log4j initialiser
  private void initializeLogger()
  {
    logProperties = new java.util.Properties();

    try
    {
      logProperties.load(new java.io.FileInputStream(LOG_PROPERTIES_FILE));
      org.apache.log4j.PropertyConfigurator.configure(logProperties);
      log.info("Logging initialized.");
    }
    catch(java.io.IOException e)
    {
     System.err.println("Unable to load logging property " + LOG_PROPERTIES_FILE);
    }
  }

let me know if you need any help with this..
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 26 Aug 2009 18:25:16 -0700
> From: glassfish_at_javadesktop.org
> To: users_at_glassfish.dev.java.net
> Subject: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
>
> I am getting the error below when i try to start the application on Glassfish App server. As per the error i copied the log4j jar file to WEB-INF/lib folder and restart the server same error comes back again and the log4j jar file is getting deleted from WEB-INF/lib folder. Any ideas?
>
> [#|2009-08-26T17:53:31.576-0500|SEVERE|sun-appserver2.1|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=pool-1-thread-14;_RequestID=9fcc9c81-4e14-4d5d-84c4-f1b84faee801;|WebModule[/APM]PWC1396: Servlet /APM threw load() exception
> java.lang.NoClassDefFoundError: org/apache/log4j/Logger
> at com.acs.util.APMServiceLocator.<clinit>(APMServiceLocator.java:30)
> at com.acs.util.APMDataFactory.<clinit>(APMDataFactory.java:65)
> at com.acs.login.CacheManager.loadData(CacheManager.java:48)
> at com.acs.login.CacheManager.init(CacheManager.java:42)
> at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194)
> at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1023)
> at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4917)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:5324)
> at com.sun.enterprise.web.WebModule.start(WebModule.java:353)
> at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:58)
> at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:304)
> at com.sun.appserv.management.util.misc.RunnableBase.run(RunnableBase.java:341)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
> at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:715)
> at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:628)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> ... 18 more
> |#]
>
> [#|2009-08-26T17:53:31.577-0500|SEVERE|sun-appserver2.1|javax.enterprise.system.container.web|_ThreadID=14;_ThreadName=pool-1-thread-6;_RequestID=e2391e8a-9630-4486-83a6-a1a5ff958c50;|WEB0207: Error starting web context StandardEngine[com.sun.appserv].StandardHost[server].StandardContext[/APM] on virtual server server
> LifecycleException: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
> at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4927)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:5324)
> at com.sun.enterprise.web.WebModule.start(WebModule.java:353)
> at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:58)
> at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:304)
> at com.sun.appserv.management.util.misc.RunnableBase.run(RunnableBase.java:341)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> [Message sent by forum member 'divvela' (divvela1_at_yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=362073
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on Facebook.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_facebook:082009