11 Replies Latest reply on Jul 14, 2006 11:04 AM by jaikiran pai

    Problem with ClassNotFoundException while trying to add extr

    Boris Lipsman Newbie

      Hello JBoss gurus,

      Any help would be greatly appreciated!

      I have created wrapper around log4j Logger, not extended.
      Reason was: to add extra level, which I called TRACE.

      I added the trace() method to my wrapper, and while I am trying to start my JBoss I get the message:
      "log4j:ERROR Could not create level [trace].
      Reported error follows.
      java.lang.ClassNotFoundException: com.mywebsite.services.logging.ExtraLevel

      The ExtraLevel is actually extending the Level, so I could add the TRACE to it.

      Apparenttly JBoss is not able to see my com.mywebsite.services.logging.ExtraLevel class.

      I have myApp.ear file deploeyd into the deploy/default directory, which has myApp.war file which has the com.mywebsite.services.logging.ExtraLevel class.

      My environment is:
      Window XP
      jboss-4.0.4.GA
      java 1.5

      Thanks again for any help or suggestion.

      Boris Lipsman

        • 1. Re: Problem with ClassNotFoundException while trying to add
          jaikiran pai Master

          The LoggingService starts even before your application is deployed. As a result, the classes present in your application are not yet loaded by the classloader and hence the ClassNotFoundException. Place the jar/classes representing your wrapper logger in the %JBOSS_HOME%/server/default/lib directory so that they are visible to the classloader when the LoggingService is starting. For more details about classloading, have a look at:

          http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases

          http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

          • 2. Re: Problem with ClassNotFoundException while trying to add
            Boris Lipsman Newbie

            jaikiran!

            Thanks a lot for your prompt help and advice.
            Worked !
            best.

            • 3. Re: Problem with ClassNotFoundException while trying to add
              Boris Lipsman Newbie

              jaijiran,
              sorry to bother you again.

              Now as I have said, I have no problems building the extra trace level, but when I call mylogger.trace() method, it is not showing up in the console and in the file.

              I have log4j.xml
              which I have modified :

              <!-- start of what I have actually added -->
              <level value="trace#com.myapp.services.logging.MyExtraLevel" <!-- end of what I have actually added -->

              Thanks again for your help
              <appender-ref ref="CONSOLE" />
              <appender-ref ref="FILE" />



              • 4. Re: Problem with ClassNotFoundException while trying to add
                jaikiran pai Master

                Can you post your entire log4j.xml and the snippet of code where you are logging the message (Use the 'Code' button to enclose the contents in a code block, for better readability)

                • 5. Re: Problem with ClassNotFoundException while trying to add
                  Boris Lipsman Newbie

                  jaikiran,
                  thank you so much for your support and help.

                  Here is the log4.xml with my additions and modifications:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                  
                  <!-- ===================================================================== -->
                  <!-- -->
                  <!-- Log4j Configuration -->
                  <!-- -->
                  <!-- ===================================================================== -->
                  
                  <!-- $Id: log4j.xml,v 1.26.2.10 2006/04/21 17:29:20 csuconic Exp $ -->
                  
                  <!--
                   | For more configuration infromation and examples see the Jakarta Log4j
                   | owebsite: http://jakarta.apache.org/log4j
                   -->
                  
                  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
                  
                   <!-- ================================= -->
                   <!-- Preserve messages in a local file -->
                   <!-- ================================= -->
                  
                   <!-- A time/date based rolling appender -->
                   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="File" value="${jboss.server.log.dir}/server.log"/>
                   <param name="Append" value="false"/>
                  
                   <!-- Rollover at midnight each day -->
                   <param name="DatePattern" value="'.'yyyy-MM-dd"/>
                  
                   <!-- Rollover at the top of each hour
                   <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
                   -->
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <!-- The default pattern: Date Priority [Category] Message\n -->
                   <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                  
                   <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
                   <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
                   -->
                   </layout>
                   </appender>
                  
                  
                   <!-- ================================= -->
                   <!-- use this appender to log my messages in a separate file >
                   <!-- ================================= -->
                  
                   <!-- EXTRA TRACE2 LEVEL -->
                   <!-- this level called TRACE2 is
                   actually based on Level.DEBUG_INT - 1,
                   so it basically between DEBUG and original TRACE of the log4j -->
                  
                  
                   <!-- static public final int TRACE2_INT = Level.DEBUG_INT - 1;
                  
                   private static String TRACE2_STR = "TRACE2";
                  
                   public static final MyExtraLevel TRACE2 = new MyExtraLevel (TRACE2_INT, TRACE2_STR, 0);
                   -->
                  
                  
                   <appender name="TRACE2_LOG" class="org.apache.log4j.FileAppender">
                   <param name="File" value="${jboss.server.log.dir}/MyAppTrace.log
                   <param name="Append" value="false"/>
                  
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss}, %-6p %C:%M:%L%m%n"/>
                  
                   </layout>
                   </appender>
                  
                  
                  
                  
                   <!-- A size based file rolling appender
                   <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="File" value="${jboss.server.log.dir}/server.log"/>
                   <param name="Append" value="false"/>
                   <param name="MaxFileSize" value="500KB"/>
                   <param name="MaxBackupIndex" value="1"/>
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                   </layout>
                   </appender>
                   -->
                  
                   <!-- ============================== -->
                   <!-- Append messages to the console -->
                   <!-- ============================== -->
                  
                   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="Target" value="System.out"/>
                   <!-- I set level here to TRACE2, so when I log the mesage to the file
                   it is also
                   <param name="Threshold" value="INFO"
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <!-- The default pattern: Date Priority [Category] Message\n -->
                   <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                   </layout>
                   </appender>
                  
                  
                  
                   <!-- ====================== -->
                   <!-- More Appender examples -->
                   <!-- ====================== -->
                  
                   <!-- Buffer events and log them asynchronously
                   <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <appender-ref ref="FILE"/>
                   <appender-ref ref="CONSOLE"/>
                   <appender-ref ref="SMTP"/>
                   </appender>
                   -->
                  
                   <!-- EMail events to an administrator
                   <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="Threshold" value="ERROR"/>
                   <param name="To" value="admin@myhost.domain.com"/>
                   <param name="From" value="nobody@myhost.domain.com"/>
                   <param name="Subject" value="JBoss Sever Errors"/>
                   <param name="SMTPHost" value="localhost"/>
                   <param name="BufferSize" value="10"/>
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
                   </layout>
                   </appender>
                   -->
                  
                   <!-- Syslog events
                   <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="Facility" value="LOCAL7"/>
                   <param name="FacilityPrinting" value="true"/>
                   <param name="SyslogHost" value="localhost"/>
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
                   </layout>
                   </appender>
                   -->
                  
                   <!-- Log events to JMS (requires a topic to be created)
                   <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="Threshold" value="ERROR"/>
                   <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
                   <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
                   </appender>
                   -->
                  
                   <!-- Log events through SNMP
                   <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
                   <param name="ManagementHost" value="127.0.0.1"/>
                   <param name="ManagementHostTrapListenPort" value="162"/>
                   <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
                   <param name="LocalIPAddress" value="127.0.0.1"/>
                   <param name="LocalTrapSendPort" value="161"/>
                   <param name="GenericTrapType" value="6"/>
                   <param name="SpecificTrapType" value="12345678"/>
                   <param name="CommunityString" value="public"/>
                   <param name="ForwardStackTraceWithTrap" value="true"/>
                   <param name="Threshold" value="DEBUG"/>
                   <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
                   </layout>
                   </appender>
                   -->
                  
                   <!-- Emit events as JMX notifications
                   <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                  
                   <param name="Threshold" value="WARN"/>
                   <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
                   </layout>
                   </appender>
                   -->
                  
                  
                  
                   <!-- ================ -->
                   <!-- Limit categories -->
                   <!-- ================ -->
                  
                   <!-- define our own category -->
                  
                   <category name="com.mywebapp">
                   <priority value="TRACE2" class="com.mywebapp.logging.MyExtraLevel" />
                   <appender-ref ref="TRACE2_LOG" />
                   </category>
                  
                  
                  
                  
                   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
                   <category name="org.apache">
                   <priority value="INFO"/>
                   </category>
                  
                   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
                   <category name="org.jboss.serial">
                   <priority value="INFO"/>
                   </category>
                  
                   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
                   <category name="org.jgroups">
                   <priority value="WARN"/>
                   </category>
                  
                   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
                   <category name="jacorb">
                   <priority value="WARN"/>
                   </category>
                  
                   <!-- Limit JBoss categories
                   <category name="org.jboss">
                   <priority value="INFO"/>
                   </category>
                   -->
                  
                   <!-- Limit the JSR77 categories -->
                   <category name="org.jboss.management">
                   <priority value="INFO"/>
                   </category>
                  
                   <!-- Limit Axis based webservice category -->
                   <category name="org.jboss.webservice">
                   <priority value="DEBUG"/>
                   </category>
                   <category name="org.jboss.axis">
                   <priority value="INFO"/>
                   </category>
                  
                   <!-- Limit JBossWS webservice category
                   <category name="org.jboss.ws">
                   <priority value="DEBUG"/>
                   </category>
                   -->
                  
                   <!-- Decrease the priority threshold for the org.jboss.varia category
                   <category name="org.jboss.varia">
                   <priority value="DEBUG"/>
                   </category>
                   -->
                  
                   <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
                   <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
                   <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                   </category>
                   -->
                  
                   <!--
                   | An example of enabling the custom TRACE level priority that is used
                   | by the JBoss internals to diagnose low level details. This example
                   | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
                   | subpackages. This will produce A LOT of logging output.
                   <category name="org.jboss.system">
                   <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                   </category>
                   <category name="org.jboss.ejb.plugins">
                   <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                   </category>
                   -->
                  
                   <!--
                   | Logs these events to SNMP:
                   - server starts/stops
                   - cluster evolution (node death/startup)
                   - When an EJB archive is deployed (and associated verified messages)
                   - When an EAR archive is deployed
                  
                   <category name="org.jboss.system.server.Server">
                   <priority value="INFO" />
                   <appender-ref ref="TRAP_LOG"/>
                   </category>
                  
                   <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
                   <priority value="INFO" />
                   <appender-ref ref="TRAP_LOG"/>
                   </category>
                  
                   <category name="org.jboss.deployment.MainDeployer">
                   <priority value="ERROR" />
                   <appender-ref ref="TRAP_LOG"/>
                   </category>
                  
                   <category name="org.jboss.ejb.EJBDeployer">
                   <priority value="INFO" />
                   <appender-ref ref="TRAP_LOG"/>
                   </category>
                  
                   <category name="org.jboss.deployment.EARDeployer">
                   <priority value="INFO" />
                   <appender-ref ref="TRAP_LOG"/>
                   </category>
                  
                   -->
                  
                  
                  
                   <!-- ======================= -->
                   <!-- Setup the Root category -->
                   <!-- ======================= -->
                  
                  
                   <!-- Jaikiran,
                   I have added to root attempting to make it work, but it did not work anyway -->
                   <root>
                   <level value="trace2#com.mywebapp.logging.MyExtraLevel" />
                  
                   <appender-ref ref="CONSOLE"/>
                   <appender-ref ref="FILE"/>
                  
                  
                   </root> <!-- Clustering logging -->
                   <!-- Uncomment the following to redirect the org.jgroups and
                   org.jboss.ha categories to a cluster.log file.
                  
                   <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
                   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                   <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
                   <param name="Append" value="false"/>
                   <param name="MaxFileSize" value="500KB"/>
                   <param name="MaxBackupIndex" value="1"/>
                  
                   <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                   </layout>
                   </appender>
                   <category name="org.jgroups">
                   <priority value="DEBUG" />
                   <appender-ref ref="CLUSTER"/>
                   </category>
                   <category name="org.jboss.ha">
                   <priority value="DEBUG" />
                   <appender-ref ref="CLUSTER"/>
                   </category>
                   -->
                  
                  </log4j:configuration>
                  


                  Thanks again for your help and patience.
                  Best regards
                  Boris Lipsman

                  • 6. Re: Problem with ClassNotFoundException while trying to add
                    jaikiran pai Master

                    I tried out a standalone application which creates a new Level and logs using that level. Everything worked fine for me. I tried uploading the sample project onto some site, but my firewall blocks those sites. So, here's the code, which is working. There are 2 java files involved. One corresponds to the new log level (MyTraceLevel.java) and other is a test file(TestMyLogLevel.java) containing the main() method. The log4j.xml is also posted here:

                    MyTraceLevel.java:

                    package org.myapp.log;
                    
                    import org.apache.log4j.Level;
                    
                    /**
                     * My own {@link org.apache.log4j.Level} for logging.
                     *
                     * @author Jaikiran Pai
                     *
                     */
                    public class MyTraceLevel extends Level {
                    
                     /**
                     * Value of my trace level. This value is lesser than {@link org.apache.log4j.Priority#DEBUG_INT}
                     * and higher than {@link org.apache.log4j.Level#TRACE_INT}
                     */
                     public static final int MY_TRACE_INT = DEBUG_INT - 10;
                    
                     /**
                     * {@link Level} representing my log level
                     */
                     public static final Level MY_TRACE = new MyTraceLevel(MY_TRACE_INT,"MY_TRACE",7);
                    
                     /**
                     * Constructor
                     *
                     * @param arg0
                     * @param arg1
                     * @param arg2
                     */
                     protected MyTraceLevel(int arg0, String arg1, int arg2) {
                     super(arg0, arg1, arg2);
                    
                     }
                    
                     /**
                     * Checks whether <code>sArg</code> is "MY_TRACE" level. If yes then returns {@link MyTraceLevel#MY_TRACE},
                     * else calls {@link MyTraceLevel#toLevel(String, Level)} passing it {@link Level#DEBUG} as the defaultLevel
                     *
                     * @see Level#toLevel(java.lang.String)
                     * @see Level#toLevel(java.lang.String, org.apache.log4j.Level)
                     *
                     */
                     public static Level toLevel(String sArg) {
                     if (sArg != null && sArg.toUpperCase().equals("MY_TRACE")) {
                     return MY_TRACE;
                     }
                     return (Level) toLevel(sArg, Level.DEBUG);
                     }
                    
                     /**
                     * Checks whether <code>val</code> is {@link MyTraceLevel#MY_TRACE_INT}. If yes then returns {@link MyTraceLevel#MY_TRACE},
                     * else calls {@link MyTraceLevel#toLevel(int, Level)} passing it {@link Level#DEBUG} as the defaultLevel
                     *
                     * @see Level#toLevel(int)
                     * @see Level#toLevel(int, org.apache.log4j.Level)
                     *
                     */
                     public static Level toLevel(int val) {
                     if (val == MY_TRACE_INT) {
                     return MY_TRACE;
                     }
                     return (Level) toLevel(val, Level.DEBUG);
                     }
                    
                     /**
                     * Checks whether <code>val</code> is {@link MyTraceLevel#MY_TRACE_INT}. If yes then returns {@link MyTraceLevel#MY_TRACE},
                     * else calls {@link Level#toLevel(int, org.apache.log4j.Level)}
                     *
                     * @see Level#toLevel(int, org.apache.log4j.Level)
                     */
                     public static Level toLevel(int val, Level defaultLevel) {
                     if (val == MY_TRACE_INT) {
                     return MY_TRACE;
                     }
                     return Level.toLevel(val,defaultLevel);
                     }
                    
                     /**
                     * Checks whether <code>sArg</code> is "MY_TRACE" level. If yes then returns {@link MyTraceLevel#MY_TRACE},
                     * else calls {@link Level#toLevel(java.lang.String, org.apache.log4j.Level)}
                     *
                     * @see Level#toLevel(java.lang.String, org.apache.log4j.Level)
                     */
                     public static Level toLevel(String sArg, Level defaultLevel) {
                     if(sArg != null && sArg.toUpperCase().equals("MY_TRACE")) {
                     return MY_TRACE;
                     }
                     return Level.toLevel(sArg,defaultLevel);
                     }
                    
                    }



                    TestMyLogLevel.java

                    package org.myapp.core;
                    
                    import org.apache.log4j.Level;
                    import org.apache.log4j.Logger;
                    import org.myapp.log.MyTraceLevel;
                    
                    /**
                     * Tests whether the new log level {@link org.myapp.log.MyTraceLevel#MY_TRACE} is working
                     *
                     * @author Jaikiran Pai
                     *
                     */
                    public class TestMyLogLevel {
                    
                     /**
                     * Writes a log message with {@link org.myapp.log.MyTraceLevel#MY_TRACE} and another message
                     * with {@link Level#DEBUG}
                     *
                     * @param args
                     */
                     public static void main(String[] args) {
                     Logger logger = Logger.getLogger(TestMyLogLevel.class.getName());
                     System.out.println("Got the logger. Invoking log() method");
                     logger.log(MyTraceLevel.MY_TRACE,"Did i get into the log file?");
                     System.out.println("Wrote the log with my trace level");
                     logger.log(Level.DEBUG ,"I am a debug message");
                     System.out.println("Wrote the log with debug level");
                     }
                    }


                    log4j.xml

                    <?xml version="1.0" encoding="UTF-8"?>
                    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                    
                    <!-- ===================================================================== -->
                    <!-- -->
                    <!-- Log4j Configuration -->
                    <!-- -->
                    <!-- ===================================================================== -->
                    
                    <!-- $Id: log4j.xml,v 1.13.2.8 2003/09/23 14:16:27 slaboure Exp $ -->
                    
                    <!--
                     | For more configuration infromation and examples see the Jakarta Log4j
                     | owebsite: http://jakarta.apache.org/log4j
                     -->
                    
                    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
                    
                     <!-- ================================= -->
                     <!-- Preserve messages in a local file -->
                     <!-- ================================= -->
                    
                     <!-- A size based rolling appender -->
                     <appender name="FILE" class="org.apache.log4j.FileAppender">
                     <param name="File" value="D:/log/myLogFile.log"/>
                     <param name="Append" value="false"/>
                    
                     <layout class="org.apache.log4j.PatternLayout">
                     <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n"/>
                     </layout>
                     </appender>
                    
                    
                    
                     <!-- ============================== -->
                     <!-- Append messages to the console -->
                     <!-- ============================== -->
                    
                     <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
                     <param name="Target" value="System.out"/>
                     <param name="Threshold" value="INFO"/>
                    
                     <layout class="org.apache.log4j.PatternLayout">
                     <!-- The default pattern: Date Priority [Category] Message\n -->
                     <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1}] %m%n"/>
                     </layout>
                     </appender>
                    
                     <!-- ================ -->
                     <!-- Limit categories -->
                     <!-- ================ -->
                    
                    
                     <category name="org.myapp">
                     <priority value="MY_TRACE" class="org.myapp.log.MyTraceLevel" />
                     <appender-ref ref="FILE"/>
                     </category>
                    
                    
                    
                    
                     <!-- ======================= -->
                     <!-- Setup the Root category -->
                     <!-- ======================= -->
                    
                     <root>
                     <appender-ref ref="CONSOLE"/>
                     </root>
                    
                    </log4j:configuration>


                    And here's the log file that got generated:

                    2006-07-12 13:45:40,633 MY_TRACE [org.myapp.core.TestMyLogLevel] Did i get into the log file?
                    2006-07-12 13:45:40,633 DEBUG [org.myapp.core.TestMyLogLevel] I am a debug message


                    See if this works for you. By the way, i used log4j-1.2.12.jar, if at all that matters.


                    • 7. Re: Problem with ClassNotFoundException while trying to add
                      Elias Ross Master


                      This has nothing to do with messaging. Put your level in a .jar file and put it in server/default/lib

                      • 8. Re: Problem with ClassNotFoundException while trying to add
                        Boris Lipsman Newbie

                        jaikiran,
                        thanks a lot man for the help! I really appreciate it.
                        it does work if I use Logger from log4j ( as you have suggested !! ).
                        but if I used wrapper around Logger, it did not work.
                        Really strange, but anyway, thanks a lot for your help!!

                        I am struggling with last problem regarding SMTPAppender.
                        This is the code I am trying to run directlly inside my init method.

                        Handler eHandler = new Handler("test");
                        SMTPAppender smtpAppender = new SMTPAppender();
                        
                        smtpAppender.setLayout(new SimpleLayout());
                        smtpAppender.setThreshold(ExtraLevel.toExtraLevel(props.getProperty(EMAIL_THRESHOLD)));
                        smtpAppender.setSMTPHost(props.getProperty(SMTP_SERVER));
                        smtpAppender.setTo(props.getProperty(EMAIL_RECIPIENT));
                        smtpAppender.setFrom(props.getProperty(EMAIL_FROM));
                        smtpAppender.setSubject(props.getProperty(EMAIL_SUBJECT));
                        smtpAppender.activateOptions();
                        eHandler.addAppender(smtpAppender);
                        handlers.add(eHandler);
                        
                        


                        Unfortunatelly, I get the error

                        java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
                        


                        when I try to execute the line

                        SMTPAppender smtpAppender = new SMTPAppender();
                        


                        I put into the JBOSS_HOME/server/default/lib 2 jars
                        mail.jar and activation.jar, but I still get this error.

                        Any idea ...?
                        Really strange, if I try to execute the same code outside of jboss all works just fine.

                        Cheers jaikiran, and thanks again for sharing experience!!

                        • 9. Re: Problem with ClassNotFoundException while trying to add
                          jaikiran pai Master

                           

                          I put into the JBOSS_HOME/server/default/lib 2 jars mail.jar and activation.jar, but I still get this error


                          Placing the mail.jar in the server/default/lib should have worked. Can you run this command and post the output:

                          jar -tf mail.jar


                          This will display the contents of the mail.jar. Just wanted to make sure that this jar file has no problems.

                          I tried out that sample code you had posted(with a few minor changes) and it worked fine, both in jboss and as a standalone program.



                          • 10. Re: Problem with ClassNotFoundException while trying to add
                            Boris Lipsman Newbie

                            hey jaikiran

                            this is what I get after running jar command for mail.jar

                            
                            C:\dev_inst\jboss-4.0.4.GA\server\ejb3\lib>jar -tf mail.jar
                            META-INF/MANIFEST.MF
                            META-INF/SUN_MICR.SF
                            META-INF/SUN_MICR.RSA
                            META-INF/
                            META-INF/javamail.default.providers
                            META-INF/javamail.default.address.map
                            META-INF/javamail.charset.map
                            META-INF/mailcap
                            javax/
                            javax/mail/
                            javax/mail/SecuritySupport12.class
                            javax/mail/SecuritySupport12$1.class
                            javax/mail/SecuritySupport12$2.class
                            javax/mail/SecuritySupport12$3.class
                            javax/mail/SecuritySupport12$4.class
                            javax/mail/SecuritySupport12$5.class
                            javax/mail/Address.class
                            javax/mail/AuthenticationFailedException.class
                            javax/mail/Authenticator.class
                            javax/mail/BodyPart.class
                            javax/mail/FetchProfile.class
                            javax/mail/FetchProfile$Item.class
                            javax/mail/Flags.class
                            javax/mail/Flags$Flag.class
                            javax/mail/Folder.class
                            javax/mail/Folder$1.class
                            javax/mail/FolderClosedException.class
                            javax/mail/FolderNotFoundException.class
                            javax/mail/UIDFolder.class
                            javax/mail/UIDFolder$FetchProfileItem.class
                            javax/mail/Header.class
                            javax/mail/IllegalWriteException.class
                            javax/mail/Message.class
                            javax/mail/Message$RecipientType.class
                            javax/mail/MessageAware.class
                            javax/mail/MessageContext.class
                            javax/mail/MessagingException.class
                            javax/mail/MethodNotSupportedException.class
                            javax/mail/NoSuchProviderException.class
                            javax/mail/Multipart.class
                            javax/mail/MultipartDataSource.class
                            javax/mail/Part.class
                            javax/mail/PasswordAuthentication.class
                            javax/mail/ReadOnlyFolderException.class
                            javax/mail/SendFailedException.class
                            javax/mail/SecuritySupport.class
                            javax/mail/Service.class
                            javax/mail/Service$1.class
                            javax/mail/Session.class
                            javax/mail/Session$1.class
                            javax/mail/Session$2.class
                            javax/mail/StreamLoader.class
                            javax/mail/Store.class
                            javax/mail/StoreClosedException.class
                            javax/mail/Transport.class
                            javax/mail/URLName.class
                            javax/mail/Provider.class
                            javax/mail/Provider$Type.class
                            javax/mail/EventQueue.class
                            javax/mail/EventQueue$QueueElement.class
                            javax/mail/event/
                            javax/mail/event/ConnectionAdapter.class
                            javax/mail/event/ConnectionEvent.class
                            javax/mail/event/ConnectionListener.class
                            javax/mail/event/FolderAdapter.class
                            javax/mail/event/FolderEvent.class
                            javax/mail/event/FolderListener.class
                            javax/mail/event/MailEvent.class
                            javax/mail/event/MessageChangedEvent.class
                            javax/mail/event/MessageChangedListener.class
                            javax/mail/event/MessageCountAdapter.class
                            javax/mail/event/MessageCountEvent.class
                            javax/mail/event/MessageCountListener.class
                            javax/mail/event/StoreEvent.class
                            javax/mail/event/StoreListener.class
                            javax/mail/event/TransportAdapter.class
                            javax/mail/event/TransportEvent.class
                            javax/mail/event/TransportListener.class
                            javax/mail/search/
                            javax/mail/search/AddressTerm.class
                            javax/mail/search/AddressStringTerm.class
                            javax/mail/search/AndTerm.class
                            javax/mail/search/BodyTerm.class
                            javax/mail/search/ComparisonTerm.class
                            javax/mail/search/DateTerm.class
                            javax/mail/search/FlagTerm.class
                            javax/mail/search/FromTerm.class
                            javax/mail/search/FromStringTerm.class
                            javax/mail/search/HeaderTerm.class
                            javax/mail/search/IntegerComparisonTerm.class
                            javax/mail/search/MessageIDTerm.class
                            javax/mail/search/MessageNumberTerm.class
                            javax/mail/search/NotTerm.class
                            javax/mail/search/OrTerm.class
                            javax/mail/search/RecipientTerm.class
                            javax/mail/search/RecipientStringTerm.class
                            javax/mail/search/SearchException.class
                            javax/mail/search/SentDateTerm.class
                            javax/mail/search/ReceivedDateTerm.class
                            javax/mail/search/SizeTerm.class
                            javax/mail/search/StringTerm.class
                            javax/mail/search/SubjectTerm.class
                            javax/mail/search/SearchTerm.class
                            javax/mail/internet/
                            javax/mail/internet/InternetAddress.class
                            javax/mail/internet/AddressException.class
                            
                            javax/mail/internet/HeaderTokenizer.class
                            javax/mail/internet/HeaderTokenizer$Token.class
                            javax/mail/internet/ParseException.class
                            javax/mail/internet/MimeUtility.class
                            javax/mail/internet/MimeUtility$1$NullInputStream.class
                            javax/mail/internet/AsciiOutputStream.class
                            javax/mail/internet/ContentType.class
                            javax/mail/internet/ParameterList.class
                            javax/mail/internet/ContentDisposition.class
                            javax/mail/internet/InternetHeaders.class
                            javax/mail/internet/hdr.class
                            javax/mail/internet/matchEnum.class
                            javax/mail/internet/MailDateFormat.class
                            javax/mail/internet/MailDateParser.class
                            javax/mail/internet/MimeBodyPart.class
                            javax/mail/internet/MimeMessage.class
                            javax/mail/internet/MimeMessage$RecipientType.class
                            javax/mail/internet/MimeMultipart.class
                            javax/mail/internet/MimePart.class
                            javax/mail/internet/MimePartDataSource.class
                            javax/mail/internet/NewsAddress.class
                            javax/mail/internet/SharedInputStream.class
                            javax/mail/internet/UniqueValue.class
                            javax/mail/MessageRemovedException.class
                            com/sun/mail/util/
                            com/sun/mail/util/LineInputStream.class
                            com/sun/mail/util/BASE64DecoderStream.class
                            com/sun/mail/util/QPDecoderStream.class
                            com/sun/mail/util/UUDecoderStream.class
                            com/sun/mail/util/BASE64EncoderStream.class
                            com/sun/mail/util/QPEncoderStream.class
                            com/sun/mail/util/UUEncoderStream.class
                            com/sun/mail/util/BEncoderStream.class
                            com/sun/mail/util/QEncoderStream.class
                            com/sun/mail/util/ASCIIUtility.class
                            com/sun/mail/util/QDecoderStream.class
                            com/sun/mail/util/LineOutputStream.class
                            com/sun/mail/util/SharedByteArrayInputStream.class
                            com/sun/mail/util/CRLFOutputStream.class
                            com/sun/mail/util/SharedFileInputStream.class
                            com/sun/mail/util/SocketFetcher.class
                            com/sun/mail/util/TraceInputStream.class
                            com/sun/mail/util/TraceOutputStream.class
                            com/sun/mail/smtp/
                            com/sun/mail/smtp/DigestMD5.class
                            com/sun/mail/smtp/SMTPMessage.class
                            com/sun/mail/smtp/SMTPOutputStream.class
                            com/sun/mail/smtp/SMTPTransport.class
                            com/sun/mail/iap/
                            com/sun/mail/iap/Argument.class
                            com/sun/mail/iap/Atom.class
                            com/sun/mail/iap/AString.class
                            com/sun/mail/iap/BadCommandException.class
                            com/sun/mail/iap/ByteArray.class
                            com/sun/mail/iap/CommandFailedException.class
                            com/sun/mail/iap/ConnectionException.class
                            com/sun/mail/iap/Literal.class
                            com/sun/mail/iap/LiteralException.class
                            com/sun/mail/iap/ParsingException.class
                            com/sun/mail/iap/Protocol.class
                            com/sun/mail/iap/ProtocolException.class
                            com/sun/mail/iap/Response.class
                            com/sun/mail/iap/ResponseHandler.class
                            com/sun/mail/iap/ResponseInputStream.class
                            com/sun/mail/imap/
                            com/sun/mail/imap/ACL.class
                            com/sun/mail/imap/DefaultFolder.class
                            com/sun/mail/imap/DefaultFolder$1.class
                            com/sun/mail/imap/DefaultFolder$2.class
                            com/sun/mail/imap/IMAPBodyPart.class
                            com/sun/mail/imap/IMAPFolder.class
                            com/sun/mail/imap/IMAPFolder$FetchProfileItem.class
                            com/sun/mail/imap/IMAPFolder$1.class
                            com/sun/mail/imap/IMAPFolder$2.class
                            com/sun/mail/imap/IMAPFolder$3.class
                            com/sun/mail/imap/IMAPFolder$4.class
                            com/sun/mail/imap/IMAPFolder$5.class
                            com/sun/mail/imap/IMAPFolder$6.class
                            com/sun/mail/imap/IMAPFolder$7.class
                            com/sun/mail/imap/IMAPFolder$8.class
                            com/sun/mail/imap/IMAPFolder$9.class
                            com/sun/mail/imap/IMAPStore.class
                            com/sun/mail/imap/IMAPFolder$10.class
                            com/sun/mail/imap/IMAPFolder$11.class
                            com/sun/mail/imap/IMAPFolder$12.class
                            com/sun/mail/imap/IMAPFolder$13.class
                            com/sun/mail/imap/IMAPFolder$14.class
                            com/sun/mail/imap/IMAPFolder$15.class
                            com/sun/mail/imap/IMAPFolder$16.class
                            com/sun/mail/imap/IMAPFolder$17.class
                            com/sun/mail/imap/IMAPFolder$ProtocolCommand.class
                            com/sun/mail/imap/MessageLiteral.class
                            com/sun/mail/imap/LengthCounter.class
                            com/sun/mail/imap/IMAPInputStream.class
                            com/sun/mail/imap/IMAPMessage.class
                            com/sun/mail/imap/IMAPMessage$1$FetchProfileCondition.class
                            com/sun/mail/imap/IMAPMultipartDataSource.class
                            com/sun/mail/imap/IMAPNestedMessage.class
                            com/sun/mail/imap/IMAPStore$ConnectionPool.class
                            com/sun/mail/imap/protocol/
                            com/sun/mail/imap/protocol/BASE64MailboxDecoder.class
                            com/sun/mail/imap/protocol/BASE64MailboxEncoder.class
                            com/sun/mail/imap/protocol/BODY.class
                            com/sun/mail/imap/protocol/BODYSTRUCTURE.class
                            com/sun/mail/imap/protocol/ENVELOPE.class
                            com/sun/mail/imap/protocol/IMAPAddress.class
                            com/sun/mail/imap/protocol/FetchResponse.class
                            com/sun/mail/imap/protocol/FLAGS.class
                            com/sun/mail/imap/protocol/IMAPProtocol.class
                            com/sun/mail/imap/protocol/IMAPResponse.class
                            com/sun/mail/imap/protocol/INTERNALDATE.class
                            com/sun/mail/imap/protocol/Item.class
                            com/sun/mail/imap/protocol/ListInfo.class
                            com/sun/mail/imap/protocol/MailboxInfo.class
                            com/sun/mail/imap/protocol/MessageSet.class
                            com/sun/mail/imap/protocol/Namespaces.class
                            com/sun/mail/imap/protocol/Namespaces$Namespace.class
                            com/sun/mail/imap/protocol/UID.class
                            com/sun/mail/imap/protocol/RFC822DATA.class
                            com/sun/mail/imap/protocol/RFC822SIZE.class
                            com/sun/mail/imap/protocol/SearchSequence.class
                            com/sun/mail/imap/protocol/Status.class
                            com/sun/mail/imap/Quota.class
                            com/sun/mail/imap/Quota$Resource.class
                            com/sun/mail/imap/Rights.class
                            com/sun/mail/imap/Rights$Right.class
                            com/sun/mail/imap/Utility.class
                            com/sun/mail/imap/Utility$Condition.class
                            com/sun/mail/pop3/DefaultFolder.class
                            com/sun/mail/pop3/POP3Folder.class
                            com/sun/mail/pop3/POP3Message.class
                            com/sun/mail/pop3/POP3Store.class
                            com/sun/mail/pop3/Response.class
                            com/sun/mail/pop3/Status.class
                            com/sun/mail/pop3/Protocol.class
                            com/sun/mail/pop3/SharedByteArrayOutputStream.class
                            com/sun/mail/handlers/
                            com/sun/mail/handlers/text_html.class
                            com/sun/mail/handlers/text_plain.class
                            com/sun/mail/handlers/text_xml.class
                            com/sun/mail/handlers/image_gif.class
                            com/sun/mail/handlers/image_jpeg.class
                            com/sun/mail/handlers/multipart_mixed.class
                            com/sun/mail/handlers/message_rfc822.class
                            
                            


                            I see the AddressException class does exist in the mail.jar and this really makes me confused. I am almost ready to give up.
                            Outside of JBOSS I have no problems to run this code, but inside jboss I keep getting the same error.


                            Cheers and thanks again.

                            • 11. Re: Problem with ClassNotFoundException while trying to add
                              jaikiran pai Master

                               

                              C:\dev_inst\jboss-4.0.4.GA\server\ejb3\lib


                              Have you created your own directory(server) under the %JBOSS_HOME%/server directory? Because, looking at the above directory hiearchy, it looks like that you have placed the mail.jar under %JBOSS_HOME%/server/ejb3/lib directory. If that's the case, how are you starting Jboss? Is it just :

                              C:\dev_inst\jboss-4.0.4.GA> run


                              or is it:

                              C:\dev_inst\jboss-4.0.4.GA>run ejb3


                              If you have created a separate server then you should use the second command, mentioned above, to start JBoss. Or else if you are using the first command then you will have to place mail.jar in:

                              C:\dev_inst\jboss-4.0.4.GA\server\default\lib
                              directory.