質問

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. 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. Now on to the problem. I get the following toplink exception in one application module.

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. 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. For more information, I am on tomcat version 6.0.37, Java version 1.6.0_45, toplink version 9.0.4.031126

Any ideas?

役に立ちましたか?

解決

This may be it; right from 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. 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). When this happens, the static SessionManager has trouble finding descriptors the second and subsequent times an application is deployed. 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.

  2. Write some code to manually clean up when the toplink application is torn down.

  3. For certain architectures they may be able to use the version sessionManager.getSession() that allows the session to be refreshed.

Workaround 3 is best and very feasible. The session has to be lazily obtained from the SessionManager and held in an application code variable. When the application is restarted its handle on the TopLink session will be null. 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. This will ensure that the old session (if any) is logged out and removed from the SessionManager before a new one is created.

Did any of the workarounds help?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top