Tomcat是否使用pl / sql模块的缓存版本? [英] Does Tomcat use cached versions of pl/sql modules?

查看:141
本文介绍了Tomcat是否使用pl / sql模块的缓存版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好想象一下这种情况。我对pl / sql模块进行了更改,重新编译它,一切都很好。没有错误。
然后我尝试访问在Tomcat上运行的应用程序的GUI屏幕。该屏幕调用oracle数据库中的pl / sql模块。

Ok imagine this situation. I make a change to a pl/sql module, recompile it and everything is fine. No errors. I then try to access a GUI screen on an application that runs on Tomcat. The screen calls a pl/sql module in an oracle database.

当我提交应该调用pl / sql模块处理数据的表单时,我收到此错误

When i submit the form which should have called that pl/sql module for processing the data, i get this error

ORA-20001: ORA-06508: PL/SQL: could not find program unit being called 

我检查了$ USER_OBJECTS中的所有包,并且没有状态为INVALID。

I checked all packages in $USER_OBJECTS and there is nothing with a status of INVALID.

我重启Tomcat然后开始工作。这是否意味着当我第一次重新编译包时,我有效地删除了对Tomcat使用的包的一些缓存引用?

I restarted Tomcat and then it starts working. Does this mean that when i recompiled the package the first time i effectively removed some cached reference to the package which Tomcat was using?

与数据库的连接是通过JDBC和DBCP连接池实现的。重新编译是否会使连接无效?

The connection to the database is via JDBC and DBCP connection pools. Does the recompile maybe invalidate the connection?

推荐答案

此问题与JDBC连接池有关,这是您在所有应用程序中遇到的问题使用JDBC连接池的服务器,而不仅仅是Tomcat。连接池将在池中打开许多连接,以便为下一个请求做好准备。如果连接引用了PL / SQL包并重新编译,则对该包的下一次调用将引发ORA-06508错误。这将影响调用堆栈中任何位置的包 - 而不仅仅是您直接调用的包。

This issue is with the JDBC connection pools and is an issue you get with all app servers using JDBC connection pools, not just Tomcat. The connection pools will keep a number of connections open in the pool ready for the next request. If a PL/SQL package has been referenced by the connection and is recompiled then the next call to that package will raise an ORA-06508 error. This will affect packages anywhere in the call stack - not just the package you called directly.

要解决此问题,一些应用服务器(如Weblogic)会调用一个测试方法定期。如果测试失败,则会从池中删除连接或以某种方式刷新连接。我不确定Tomcat有什么机制。

To resolve this some app servers (like Weblogic) have a test method that is called periodically. If the test fails the connection is removed from the pool or refreshed in some way. I'm not sure what mechanism Tomcat has.

另一种解决方法是调用dbms_session.reset_package作为JDBC调用中的第一个方法调用。这将从您的会话中清除包状态。不建议使用此方法,因为它具有性能开销,并且任何包范围的变量都会被重置,因此需要再次调用包初始化块 - 另一个性能损失。

Another way to address it is to call dbms_session.reset_package as the first method call in your JDBC call. This will clear the package state from you're session. This approach isn't recommended as it has a performance overhead plus any package-scoped variables are reset so package initialisation blocks need to be called again - another performance hit.

如果你遇到了问题而且你没有办法丢弃重置整个连接池所需的错误连接,因为池中的任何连接都会遭受同样的异常。

If you've got the issue and you haven't got a way of dropping bad connections you'll need to reset the whole connection pool as any connection in the pool will suffer from the same exception.

这篇关于Tomcat是否使用pl / sql模块的缓存版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆