Exception in thread "main" java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I

Hibernate的Exception in thread "main" java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I错误。

这种错误出现在你是用Hibernate对HQL语句使用?赋值时,做出现错误。即:setString(1,"111")的错误。

如果你单独使用Hibernate的时候,他不会出错,如果你是使用struts2和Hibernate3共同使用的,会出现这种错误。即

at org.hibernate.hql.internal.ast.HqlSqlWalker.generatePositionalParameter(HqlSqlWalker.java:929)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.parameter(HqlSqlBaseWalker.java:5005)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1347)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4426)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3901)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2076)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:794)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:595)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:249)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:184)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:137)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
	at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
	at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
	at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1778)
	at com.view.Text1.main(Text1.java:45)

这时因为struts2中的antlr-2.7.2.jar和Hibernate的antlr-2.7.7.jar冲突,只要将struts2中的antlr-2.7.2.jar文件remove即可既不会出现这个问题了。你可以试试。

如果还是报这样的错误:那你就去你的tomcat下的这个WEB应用下的WEB-INF下的lib中将antlr-2.7.2.jar删除即可。。

你可能感兴趣的:(thread,Hibernate,exception,in)