I am using Glassfish 3.1.2 with NetBeans 7.1.2.
I have downloaded hibernate-release-4.1.5.SP1.
I have added next libs to my EJB project:
hibernate-release-4.1.5.SP1\lib\envers\hibernate-envers-4.1.5.SP1.jar
hibernate-release-4.1.5.SP1\lib\jpa\hibernate-entitymanager-4.1.5.SP1.jar
hibernate-release-4.1.5.SP1\lib\required\antlr-2.7.7.jar
hibernate-release-4.1.5.SP1\lib\required\dom4j-1.6.1.jar
hibernate-release-4.1.5.SP1\lib\required\hibernate-commons-annotations-4.0.1.Final.jar
hibernate-release-4.1.5.SP1\lib\required\hibernate-core-4.1.5.SP1.jar
hibernate-release-4.1.5.SP1\lib\required\hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-release-4.1.5.SP1\lib\required\javassist-3.15.0-GA.jar
hibernate-release-4.1.5.SP1\lib\required\jboss-logging-3.1.0.GA.jar
hibernate-release-4.1.5.SP1\lib\required\jboss-transaction-api_1.1_spec-1.0.0.Final.jar
As I have sad, I am using Glassfish and the names of libs such as jboss-* seems to me strange.
But without jboss-logging-3.1.0.GA.jar and jboss-transaction-api_1.1_spec-1.0.0.Final.jar I cannot deploy my project to Glassfish.
I want to see what SQL queries generates while executing different JPA constructions.
For example:
Code:
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery();
Root<Surgery> table = criteriaQuery.from(SomeTable.class);
criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(table.get("id"), idvar)));
TypedQuery<Object> typedQuery = em.createQuery(select);
List<Object[]> some_ret = (List) typedQuery.getResultList();
Is equvivalent to:
Code:
select * from SomeTable where id=:idvar
I have googled and then I have found that to see the queries in log I need log4j and configure it in log4j.properties.
It seems to me that jboss-logging-3.1.0.GA.jar conflicts with log4j-1.2.17.jar
Because I have this errors:
Code:
SEVERE: log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
SEVERE: log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
SEVERE: log4j:ERROR [EarLibClassLoader :
urlSet = [URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/antlr-2.7.7.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/dom4j-1.6.1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-commons-annotations-4.0.1.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-core-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-entitymanager-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-envers-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/javassist-3.15.0-GA.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/jboss-logging-3.1.0.GA.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/log4j-1.2.17.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/LpuCore.jar]
doneCalled = false
Parent -> org.glassfish.internal.api.DelegatingClassLoader@1f594f7
] whereas object of type
SEVERE: log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [EarLibClassLoader :
urlSet = [URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/antlr-2.7.7.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/dom4j-1.6.1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-commons-annotations-4.0.1.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-core-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-entitymanager-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-envers-4.1.5.SP1.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/javassist-3.15.0-GA.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/jboss-logging-3.1.0.GA.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/log4j-1.2.17.jar, URLEntry : file:/D:/SVNLpu/branches/EnterpriseTry/dist/gfdeploy/EnterpriseTry/lib/LpuCore.jar]
doneCalled = false
Parent -> org.glassfish.internal.api.DelegatingClassLoader@e84cfa
].
SEVERE: log4j:ERROR Could not instantiate appender named "stdout".
SEVERE: log4j:WARN No appenders could be found for logger (org.hibernate.annotations.common.Version).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
It says that there is two copies of log4j.jar in libraries.
How can I use log4j in this situation?