I am doing JPA without persistence.xml (without Spring Boot) and instead used the PersistenceUnitInfo to create the entity manager. When running the application from my IDE, there are no errors, but it logs sensitive persistence unit information. I've struggled to disable the logging.
It gets worse, when I run it from the command line, I get the following:
Kindly assist, I've lost quite a few hours to this one.
The issue you encounter is a classloading issue during initialization of your EntityManager on your JBoss application environement.
Disabling the logging will not fix this error, but hide it. Check your deployment classpath, and your JDK version. And verify that all required hibernate libraries are present. You can check which libraries you need on the classpath by looking at the dependencies on a site such as mvnRepository (example: https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core/6.0.2.Final).
Are you using a dependency manager, such as Maven or Gradle?
Related
I am having an issue with logging information for some of the microservices running on Quarkus. Some of the projects have the below settings in the build.gradle:
implementation 'org.apache.logging.log4j:log4j-core'
runtimeOnly 'org.jboss.logmanager:log4j2-jboss-logmanager'
Our code uses apache log4j LogManager and Logger to log information. When we have the projects with these 2 dependencies in the gradle file, the log settings don't work and as a result, nothing gets written (except for the default setting of error) irrespective of any settings in the application.properties. For the other projects where there is no dependency on log4j-core, the logging works perfectly fine.
What i was told by one of my colleagues is that there is some overriding happens when these 2 libraries are included in a project and he suggested using the org.jboss.logging.Logger in place of the apache log4j LogManager. I haven't tried any other settings but i do see the info logs now in the log file so it is working though i am having to change some code to match the method signatures on the jboss Logger object. While i am happy it's working, i would like to avoid having to code logic in 2 different ways across projects (example - Logger comes from LogManager in apache log4j whereas it just comes from Logger class itself in jboss approach)
I am trying to understand what is causing this conflict and why and also if anyone has any better way than what I did to make it work. Please let me know
Thanks in advance for your help!
Best Regards
SG
I am working with a SpringBoot project. Initially, when I am running the application I was getting the "multiple bindings" warning and no log files were getting created but the application started taking the log-back classic dependency and ignoring the slf4j-log4j12 artifact (Both are child dependencies of spring-boot-starter-logging which is in turn a child of spring-boot-starter). However, once I excluded the logback-classic artifact it has started to hang at the line INFO: Initializing Spring embedded WebApplicationContext and no log files are being generated. In this project I see that log4j is being used and the web.xml has been entirely commented out. Is the hanging of the application at startup related to any of the above actions or conditions?
Thanks in advance for the help. Please note that I am new to SpringBoot and nothing seems to work in this framework as mentioned in the docs so I am a bit frustrated as well. Any help will be really appreciated.
Let's say we build a Java SDK and different projects can consume by adding it as a jar in the classpath or adding it as a dependency in the maven pom.xml or gradle file. Logs from the SDK are not visible at run-time when the other projects are consuming this library. I tried with SL4J, and none of the logs are visible at the run time when it is used by the other projects. Should I go with log4j2? If yes, should I provide with a log4j configuration /properties file in my SDK? Will the properties/configuration be picked-up at run time from the consumer libraries? What are the best practices for this? Can you please advise?
Best practice #1: never include the logging configuration file in your jar.
Applications using your library will likely want to provide their own logging configuration. If one of the jars contains a different configuration it becomes a “fun” guessing game for these applications to figure out why their configuration isn’t working. (And depending on the classpath order, their configuration may sometimes take precedence over the configuration in the library, so sometimes it will work, just to make it extra challenging...)
Maven uses slf4j, so as soon as it is launched, it initializes it with its default implementation contained into apache-maven-3.3.9\lib\slf4j-simple-1.7.5.jar and with configuration file defined in apache-maven-3.3.9\conf\logging\simplelogger.properties.
After that it loads the pom file and found my jetty-maven-plugin which launch a webapp. But in this webapp I want to use a different implementation for slf4j, but I can't because slf4j is already initialized.
I understand that maven is mainly a tool for build and not to launch apps, but I can't modify log configuration of apache-maven for each project to get pretty logs for each of them.
Is someone already face this issue and find a way to avoid that?
Note:
run-forked instead run works but in this case I can't no more debug from eclipse so I prefer an another solution.
older version of maven works as 3.0.3 because it didn't used slf4j
I know that many subject speak about classpath loader and transitive dependancy but i m little confused.
I m working on a legacy application that use spring 2.0.5 and spring-ws and all work fine from the beginning of the project to now.
And recently we are faced to a runtime problem with a an exception like methodnotfoundexception.
In fact we see that spring-ws depend on spring-2.5. So maven transitive dependancy add spring 2.5 in my webinf/lib directory near spring 2.0.5
But i dont understand why all working fine during many years and now why weblogic decide to load spring2.5 before spring2.0.5 and cause this error?
We have correct the problem and now i m looking for same jar with different version and do build failure when i have a conflit to avoid dependancy problem in the future.
But i just want to understand why weblogic decide to load one or another jar ? Because if its alphabetical order, same jar will be loaded all the time, but in my exemple the order change...
So i don t understand clearly whats happened.
Thanks by advance;)
While it is documented that WEB-INF/classes is loaded before WEB-INF/lib, the documentation is not clear in cases like yours - where there are sibling copies of Spring in the WEB-INF/lib.
In Tomcat it is alphabetical, but looks like Websphere, Jboss and Weblogic are random. See https://stackoverflow.com/a/5817890/327426
From some threads on the Oracle forums, the recommendation is to run the Classloader Analysis Tool available at http://docs.oracle.com/cd/E23943_01/web.1111/e13706/classloading.htm#BABHJGJJ for your app and see the results. This tool will identify classloading conflicts.
See similar issue at https://community.oracle.com/thread/2387921?tstart=0
This post from 2009 http://www.coderanch.com/t/472496/BEA-Weblogic/Loading-order-jar-WEB-INF on Weblogic v9.2 states "Checking the logs I see the .jars in WEB-INF/lib are being loaded in reverse alphabetical order". This may or may not be true for your version
Another option is to use Maven to bypass the transitive import being packaged in the WAR