0

Source Code :

@Controller
public class HomeController {

    private  static final Logger log = LogManager.getLogger();
    @GetMapping("/hello")
    public @ResponseBody String getHello()
    {
        
        DemoClass cls = new DemoClass();
        cls.helloworld();
        
        log.info("INFO =====================");
        return "Hello2";
    }
    
}

The culprit in above code is "LogManager.getLogger()". The above code is working perfectly fine on apache tomcat.

The stacktrace is as follows : Java 11 is used. Weblogic 14 is used. log4j version : 2.19.0

Caused By: java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.
    at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
    at com.example.demo.controller.HomeController.<clinit>(HomeController.java:12)
  • Please provide more info. In the mean time try downgrade the version of java to 10 and let us know the output after deployment. – Rahul Jan 07 '23 at 04:18
  • The problem is either lack of _multi-release_ support in WebLogic or a corrupted Log4j2 library (e.g. shaded). There is a [Weblogic ticket](https://support.oracle.com/knowledge/Middleware/2824697_1.html) in Oracle's support page that _might_ solve the problem. – Piotr P. Karwasz Jan 07 '23 at 08:23

0 Answers0