简体   繁体   English

Tomcat 6中的Toplink运行时错误

[英]Toplink runtime error in Tomcat 6

Let me give a little background to give context to this question. 让我提供一些背景知识来说明这个问题。 Over the course of time, the application I have been assigned to work on lost the ability to be built and deployed as a full application. 随着时间的流逝,我被分配处理的应用程序失去了作为完整应用程序进行构建和部署的能力。 By that I mean the previous developer compiled the code in his local IDE, and dropped single class files, as opposed to building out proper JARs and WARs to be deployed out to tomcat. 我的意思是说,以前的开发人员在其本地IDE中编译了代码,并删除了单个类文件,而不是构建适当的JAR和WAR以部署到tomcat。 So I have been tasked to clean up the project so it is a standard deployable app again. 因此,我受命清理项目,使其再次成为标准的可部署应用程序。 So to sum up the important part, the application exists in a working format on a windows tomcat environment, that hasn't had a clean deploy in a long time, my goal is to make the app buildable and deployable via a jenkins CI server to a tomcat instance running on a Linux server. 因此,总而言之,该应用程序以工作格式存在于Windows tomcat环境中,很长时间以来还没有进行过清晰的部署,我的目标是使该应用程序可以通过jenkins CI服务器进行构建和部署。在Linux服务器上运行的tomcat实例。 Now on to the problem. 现在解决问题。 I get the following toplink exception in one application module. 我在一个应用程序模块中收到以下toplink异常。

Local Exception Stack:
Exception [TOPLINK-6007] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
Exception Description: Missing descriptor for [class edu.cornell.finsys.datamodel.AccountDTO].
Query: ReadObjectQuery(edu.cornell.finsys.datamodel.AccountDTO)

I have verified that the toplink mapping file has been loaded by tomcat, and the AccountDTO is mapped in the file. 我已经验证了tomcat已加载toplink映射文件,并且AccountDTO已映射到该文件中。 To double check that, I have moved the mapping file out, and I get a completly different error at load time. 为了再次确认,我已经将映射文件移出了,在加载时出现了完全不同的错误。 I know the file mapping is correct, as it worked correctly on the old server. 我知道文件映射是正确的,因为它在旧服务器上可以正常工作。 I don't know what else could be causing the toplink exception. 我不知道还有什么可能导致toplink异常。 For more information, I am on tomcat version 6.0.37, Java version 1.6.0_45, toplink version 9.0.4.031126 有关更多信息,我使用的是tomcat 6.0.37版,Java 1.6.0_45版,toplink 9.0.4.031126版

Any ideas? 有任何想法吗?

This may be it; 可能就是这样; right from Metalink: 来自Metalink:

Cause: 原因:

This is an issue with loading the sessions.xml file, once when the application was first deployed using that application's classloader and then not reloading the session when the application was redeployed and a new XMLContext was created. 这是在第一次使用该应用程序的类加载器部署该应用程序时加载sessions.xml文件,然后在重新部署该应用程序并创建新的XMLContext时不重新加载会话的问题。 The caused us to attempt to use a session that had been loaded with a different classloader than the current application. 这导致我们尝试使用已使用与当前应用程序不同的类加载器加载的会话。

Possible solution: 可能的解决方案:

The issue occurs when TopLink is part of the main classpath (Eg: Applib directory rather than stored in the ear file). 当TopLink是主类路径的一部分(例如,Applib目录而不是存储在ear文件中)时,会发生此问题。 When this happens, the static SessionManager has trouble finding descriptors the second and subsequent times an application is deployed. 发生这种情况时,静态SessionManager在第二次及以后部署应用程序时很难找到描述符。 Basically the descriptors are indexed by class. 基本上,描述符是按类索引的。 When the application is redeployed, the classes used for the indexing are unloaded and new versions of those classes appear. 重新部署应用程序后,将卸载用于索引的类,并显示这些类的新版本。 This causes "Descriptor not found" exceptions. 这将导致“找不到描述符”异常。

Potential Workarounds 潜在的解决方法

  1. Put the toplink.jar file in the ear. 将toplink.jar文件放在耳朵里。

  2. Write some code to manually clean up when the toplink application is torn down. 编写一些代码以在toplink应用程序被删除时手动清理。

  3. For certain architectures they may be able to use the version sessionManager.getSession() that allows the session to be refreshed. 对于某些体系结构,他们可能能够使用版本sessionManager.getSession()来刷新会话。

Workaround 3 is best and very feasible. 解决方法3是最好的,也是非常可行的。 The session has to be lazily obtained from the SessionManager and held in an application code variable. 会话必须从SessionManager延迟获取,并保存在应用程序代码变量中。 When the application is restarted its handle on the TopLink session will be null. 重新启动应用程序时,其在TopLink会话上的句柄将为空。 The session can then be obtained from the SesssionManager using the getSession(XMLLoader xmlLoader, String sessionName, ClassLoader objectClassLoader, boolean shouldLoginSession, boolean shouldRefreshSession) API with shouldRefreshSession set to true. 然后可以使用getSession(XMLLoader xmlLoader,String sessionName,ClassLoader objectClassLoader,boolean shouldLoginSession,boolean shouldRefreshSession)API从SesssionManager获取会话,并将shouldRefreshSession设置为true。 This will ensure that the old session (if any) is logged out and removed from the SessionManager before a new one is created. 这将确保在创建新会话之前注销旧会话(如果有)并将其从SessionManager中删除。

Did any of the workarounds help? 有任何变通办法有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM