Results 1 to 6 of 6
  1. #1
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up java.lang.NoSuchMethodError: org.apache.log4j.Logger.log(Ljava/lang/String;Lorg/apach

    I got the following error
    java.lang.NoSuchMethodError: org.apache.log4j.Logger.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V

    while trying the Annotations.
    I am using the jar files as:
    hibernate-annotations.jar-3.4.0
    hibernate-commons-annotations.jar-3.4.0
    log4j.jar-1.2.15
    slf4j-log4j13-1.0.jar
    slf4j-api.jar 3.4.0

    I have one utils class as:

    Java Code:
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.AnnotationConfiguration;
    
    public class HibernateUtil {
      private static final SessionFactory sessionFactory;
      static {
        try {
          // Create the SessionFactory from hibernate.cfg.xml
          sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        } catch (Throwable ex) {
          // Make sure you log the exception, as it might be swallowed
          System.err.println("Initial SessionFactory creation failed." + ex);
          throw new ExceptionInInitializerError(ex);
        }
      }
    
      public static SessionFactory getSessionFactory() {
        return sessionFactory;
      }
    }
    The flow is always catched in the line:

    Java Code:
    sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
    and gives the above mentioned error. I am beginner in the hibernate field.
    Please let me know what is the problem and how could it be solved.
    Thanks,

  2. #2
    vkorenev is offline Member
    Join Date
    Aug 2009
    Location
    Kharkov, Ukraine
    Posts
    29
    Rep Power
    0

    Default

    log4j.jar-1.2.15
    slf4j-log4j13-1.0.jar
    Seems like you are trying to use slf4j adapter for log4j 1.3 with log4j 1.2.
    Full stack trace can tell this for sure.

  3. #3
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    do you have some idea on how to resolve this?

  4. #4
    ProviderP is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default I am getting this exact same error

    I am receiving this same error with my application and I am stumped too.

    I am using log4j-1.2.8.jar which I read somewhere would fix this but no luck. I am also using jdk1.5.

    When I run my program from the command line, my program errors out on the following line which I think is similar to your problem

    Configuration cfg = new Configuration().configure("controlTable.cfg.xml");

    My program works like a champ when I run it from MyEclipse, however when I compile it with ANT and deploy it to my server I get the same error.

    Exception in thread "Thread-0" java.lang.NoSuchMethodError: log (Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V

  5. #5
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Post

    make sure you don't have any other entry for log4j.jar in your classpath.

    My gut feeling says, your classpath refers to an earlier version of log4j.

  6. #6
    ProviderP is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default

    I am using the log4j-1.2.8.jar file and that is my only reference.

    I also am using commons-logging4.0.6.jar, does that have references to log4j properties?

Similar Threads

  1. [error] java.lang.NoSuchMethodError: main
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 04-29-2009, 11:21 PM
  2. [SOLVED] Ljava.lang.String;@923e30 at runtime
    By Jerome in forum New To Java
    Replies: 6
    Last Post: 12-31-2008, 11:08 AM
  3. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  4. Replies: 1
    Last Post: 08-06-2007, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •