Closed GoogleCodeExporter closed 9 years ago
Can you post the full stacktrace?
I would say that you have more than one mybatis version in your classpath.
Or you have an old log4j version.
Original comment by eduardo.macarron
on 10 Apr 2013 at 9:07
thanks for your reply
Below is my full stacktrace:
java.lang.NoSuchMethodError:
org.apache.ibatis.logging.jdbc.ResultSetLogger.isTraceEnabled()Z
at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:64) ~[mybatis-3.2.2.jar:3.2.2]
at com.sun.proxy.$Proxy24.next(Unknown Source) ~[?:?]
at org.apache.ibatis.executor.resultset.FastResultSetHandler.shouldProcessMoreRows(FastResultSetHandler.java:227) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:214) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:188) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:154) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) ~[mybatis-3.2.2.jar:3.2.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_15]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_15]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_15]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_15]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355) ~[mybatis-spring-1.1.1.jar:1.1.1]
at com.sun.proxy.$Proxy16.selectList(Unknown Source) ~[?:?]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195) ~[mybatis-spring-1.1.1.jar:1.1.1]
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58) ~[mybatis-3.2.2.jar:3.2.2]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) ~[mybatis-3.2.2.jar:3.2.2]
at com.sun.proxy.$Proxy20.searchUser(Unknown Source) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_15]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_15]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_15]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_15]
----------------------------------------------------------------------
my mybiatis version is 3.2.2 and I use log4j to print log information which
causes the problem.
if i add my configure file with
<setting name="logImpl" value="NO_LOGGING"/>
the exception will disappear, but mybatis does not print the log info.
Original comment by chens5...@gmail.com
on 10 Apr 2013 at 9:35
not log4j is log4j-2.0-beta4
Original comment by chens5...@gmail.com
on 10 Apr 2013 at 9:37
Probably the problem is that. The method isTraceEnabled() exist in
ResultSetLogger so the problem is not that.
Can you check this with log4j 1.2.17?
Original comment by eduardo.macarron
on 10 Apr 2013 at 9:41
Hi again,
I have just tested version 3.2.2 with log4j 2 and it does not work. So it looks
like you have and old log4j version in your classpath also [1]
So it looks like we need specific code for log4j 2.x.
Can you open an issue in github.com/mybatis asking for log4j2 support?
[1]
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in SQL Mapper Configuration
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper
Configuration. Cause: org.apache.ibatis.logging.LogException: Error setting Log
implementation. Cause: java.lang.NoClassDefFoundError:
org/apache/log4j/Priority
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
at org.apache.ibatis.submitted.basetest.BaseTest.setUp(BaseTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper
Configuration. Cause: org.apache.ibatis.logging.LogException: Error setting Log
implementation. Cause: java.lang.NoClassDefFoundError:
org/apache/log4j/Priority
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:106)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:89)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
... 17 more
Caused by: org.apache.ibatis.logging.LogException: Error setting Log
implementation. Cause: java.lang.NoClassDefFoundError:
org/apache/log4j/Priority
at org.apache.ibatis.logging.LogFactory.setImplementation(LogFactory.java:118)
at org.apache.ibatis.logging.LogFactory.useCustomLogging(LogFactory.java:74)
at org.apache.ibatis.session.Configuration.setLogImpl(Configuration.java:201)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.settingsElement(XMLConfigBuilder.java:215)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:100)
... 19 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
at java.lang.Class.getConstructor0(Class.java:2723)
at java.lang.Class.getConstructor(Class.java:1676)
at org.apache.ibatis.logging.LogFactory.setImplementation(LogFactory.java:113)
... 23 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 28 more
Original comment by eduardo.macarron
on 10 Apr 2013 at 4:31
Have a look at
https://github.com/mybatis/mybatis-3/issues/28
We would appreciate that you test it and also if you can help with any of the
doc translations.
Original comment by eduardo.macarron
on 10 Apr 2013 at 5:31
hank you for your help, and appears to be in need of version 3.2.3 to support
When it will launch the 3.2.3 version?
by the way. My English is difficult competent translation
Original comment by chens5...@gmail.com
on 11 Apr 2013 at 1:28
Hi!
3.2.2 is quite recent so I will not expect a release in some months.
If using log4j 2 (that is still a beta) is something you can get rid off, I'd
better go what way.
Original comment by eduardo.macarron
on 11 Apr 2013 at 4:18
For the time being you can use the snapshot. Right now it is 3.2.2 with two
minor changes.
https://code.google.com/p/mybatis/downloads/detail?name=mybatis-3.2.3-SNAPSHOT.j
ar
Original comment by eduardo.macarron
on 11 Apr 2013 at 4:39
Hi!
org\apache\ibatis\logging\jdbc\ResultSetLogger.java
in mybatis-3.2.2.jar ResultSetLogger uses isTraceEnabled method.(Decompilation)
public Object invoke(Object proxy, Method method, Object[] params) throws Throwable {
try {
Object o = method.invoke(rs, params);
if ("next".equals(method.getName())) {
if (((Boolean) o)) {
ResultSetMetaData rsmd = rs.getMetaData();
final int columnCount = rsmd.getColumnCount();
if (isTraceEnabled()) {
if (first) {
first = false;
printColumnHeaders(rsmd, columnCount);
}
printColumnValues(columnCount);
}
}
}
clearColumnInfo();
return o;
} catch (Throwable t) {
throw ExceptionUtil.unwrapThrowable(t);
}
}
But in mybatis-3.2.2-sources.jar ResultSetLogger has not isTraceEnabled method
public Object invoke(Object proxy, Method method, Object[] params) throws Throwable {
try {
Object o = method.invoke(rs, params);
if ("next".equals(method.getName())) {
if (((Boolean) o)) {
ResultSetMetaData rsmd = rs.getMetaData();
final int columnCount = rsmd.getColumnCount();
if (isDebugEnabled()) {
if (first) {
first = false;
printColumnHeaders(rsmd, columnCount);
}
printColumnValues(columnCount);
}
}
}
clearColumnInfo();
return o;
} catch (Throwable t) {
throw ExceptionUtil.unwrapThrowable(t);
}
}
why?
please check
Original comment by chens5...@gmail.com
on 12 Apr 2013 at 8:35
I see it right.
Sources are here:
http://repo1.maven.org/maven2/org/mybatis/mybatis/3.2.2/mybatis-3.2.2-sources.ja
r
public Object invoke(Object proxy, Method method, Object[] params) throws Throwable {
try {
Object o = method.invoke(rs, params);
if ("next".equals(method.getName())) {
if (((Boolean) o)) {
ResultSetMetaData rsmd = rs.getMetaData();
final int columnCount = rsmd.getColumnCount();
if (isTraceEnabled()) {
if (first) {
first = false;
printColumnHeaders(rsmd, columnCount);
}
printColumnValues(columnCount);
}
}
}
clearColumnInfo();
return o;
} catch (Throwable t) {
throw ExceptionUtil.unwrapThrowable(t);
}
}
Original comment by eduardo.macarron
on 12 Apr 2013 at 8:39
mybatis-3.2.3-SNAPSHOT.jar is the same uses isTraceEnabled method
Original comment by chens5...@gmail.com
on 12 Apr 2013 at 8:40
Yes.
The problem is not in MyBatis code because if that method does not exist
mybatis will not compile! :)
And it works for me and for thousands of people, and not for you.
So... what are you doing different? At least one thing: using log4j 2.x that is
not supported by version 3.2.2.
I still think that you are using and old log4j 1.x jar that nas not a
Logger.isTraceEnable() method and that is the reason of the failure.
Original comment by eduardo.macarron
on 12 Apr 2013 at 8:46
[deleted comment]
[deleted comment]
mybatis3.1.1 with log4j2 works well
because of Issue 377
Original comment by chens5...@gmail.com
on 12 Apr 2013 at 9:11
Hi:
my mistake
mybatis-3.2.3-SNAPSHOT.jar works
thank you for you help again
Original comment by chens5...@gmail.com
on 12 Apr 2013 at 10:27
Original issue reported on code.google.com by
chens5...@gmail.com
on 10 Apr 2013 at 8:23