spring mvc+ibatis+oracle ORA-02289: 序列不存在

代码是从svn更新下来的,在别人机器的运行环境下都可以正常运行,在我的环境下就水土不服了,请大神指点
sql如下:

select SEQ_SIAPP_COUPON_NO.nextval from dual

错误信息如下:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.paic.mhis.siapp.core.rps.proxy.MethodInvoker.invoke(MethodInvoker.java:27)
at com.paic.mhis.siapp.core.rps.proxy.MethodInvoker$$FastClassByCGLIB$$91548d27.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.paic.mhis.siapp.admin.general.logging.aop.LoggerInterceptor.invoke(LoggerInterceptor.java:45)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.paic.mhis.siapp.admin.general.logging.aop.SmsMethodInvoker$$EnhancerByCGLIB$$c201eac9.invoke()
at com.paic.mhis.siapp.core.rps.protocol.Receiver.invoke(Receiver.java:32)
at com.paic.mhis.siapp.core.rps.transport.server.RpsHttpServer.handleRequest(RpsHttpServer.java:19)
at com.paic.mhis.siapp.core.rps.transport.server.RpsHttpServlet.doPost(RpsHttpServlet.java:126)
at com.paic.mhis.siapp.core.rps.transport.server.RpsHttpServlet.doPost(RpsHttpServlet.java:90)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:

--- The error occurred in sqlmaps/market/sqlmap-mapping-couponManage.xml.

--- The error occurred while applying a parameter map.

--- Check the couponManage.getCouponNoSeq-InlineParameterMap.

--- Check the statement (query failed).

--- Cause: java.sql.SQLSyntaxErrorException: ORA-02289: 序列不存在

at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:279)
at com.paic.pafa.biz.dao.BaseDAO._getObject(Unknown Source)
at com.paic.pafa.biz.dao.BaseDAO._queryForObject(Unknown Source)
at com.paic.mhis.siapp.common.integration.dao.impl.CommonDaoImpl.get(CommonDaoImpl.java:121)
at com.paic.mhis.oaccount.market.service.impl.CouponManageServiceImpl.getCouponNo(CouponManageServiceImpl.java:89)
... 31 more

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:

--- The error occurred in sqlmaps/market/sqlmap-mapping-couponManage.xml.

--- The error occurred while applying a parameter map.

--- Check the couponManage.getCouponNoSeq-InlineParameterMap.

--- Check the statement (query failed).

--- Cause: java.sql.SQLSyntaxErrorException: ORA-02289: 序列不存在

at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:114)
at org.springframework.orm.ibatis.SqlMapClientTemplate$2.doInSqlMapClient(SqlMapClientTemplate.java:281)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)
... 36 more

Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: 序列不存在

at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1187)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3487)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62)
at $Proxy223.execute(Unknown Source)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.paic.pafa.app.lwc.service.persistence.dao.ibatis.PafaSqlExecutor.doSuperExecuteQuery(Unknown Source)
at com.paic.pafa.app.lwc.service.persistence.dao.ibatis.PafaSqlExecutor.executeQuery(Unknown Source)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 41 more

[03/30 10:53:27] [WARN] RpsHttpServlet: rollback
<[ServletContext@9937403[app:siapp-sms-app module:siapp-sms-app path:/siapp-sms-app spec-version:2.5]] Servlet failed with Exception
java.lang.NullPointerException
at com.paic.mhis.siapp.core.rps.transport.server.RpsHttpServlet.doPost(RpsHttpServlet.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
Truncated. see log file for complete stacktrace

6个回答

select SEQ_SIAPP_COUPON_NO.nextval from dual
改为
select 99999 from dual
试下好用与否?

如果好用,说明SEQ_SIAPP_COUPON_NO可能是你的用户没有权限使用,或者SEQ_SIAPP_COUPON_NO真是不存在。
如果不好用,说明你的项目配置或编码用问题。

engchina
engchina 还有就是用同一个sequence,换一个数据库试下?
3 年多之前 回复
engchina
engchina 换一个sequence试下呢?
3 年多之前 回复
caikelei
Clay_cai 改的sql肯定是好用的,代码是从svn上更新下来的,我们用的是同一个数据库,我把序列删除后重新建的也还是不行,关键问题是其他人也是从svn上更新代码就可以正常获取,真的很郁闷,谢谢你的回答!
3 年多之前 回复

你需要在oracle项目对应的数据库中新建一个序列 Check the couponManage.getCouponNoSeq-InlineParameterMap. 具体见这个mapper

caikelei
Clay_cai 序列是已经存在的,而且别人都可以正常获取这个序列,我们用的是同一个数据库
3 年多之前 回复

SQL有错,自己检查你的sql语句中使用到序列的地方,是序列写错了,还是根本就没有

caikelei
Clay_cai 序列是存在的,用的是同一个数据库,别人都可以正常获取
3 年多之前 回复
caikelei
Clay_cai 这个看过了,谢谢!这个是创建一个序列,现在序列是已经建好的
3 年多之前 回复

你看下你们数据库是用的同一个源吗? 如果是同一个不是本地数据库那应该没问题;如果是本地数据库那就是你数据库没建序列;去别人的数据库看下有哪些序列要建;

caikelei
Clay_cai 谢谢你的回答,数据库没有问题,序列也是存在的,在pl/sql中这个sql也可已正常获取数据,就是在代码中不行,关键问题是别人都可以正常获取,和我代码一样,就我这边获取不了序列,如果不用序列,而用sys_guid(),是可以正常获取值的,我感觉还是项目环境的问题,就是不知道问题出在哪里
3 年多之前 回复

问题已经找到
,建表时有对多个用户赋予了不同的权限,在weblogic中配置时,username用的是没有操作序列权限的用户名

dlc152133
房西的狗 我现在也是同样的问题,请问怎么才能解决啊?我登进我这个用户可以查到序列,就是在后台报序列不存在的错
一年多之前 回复
立即提问