[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Capturing java.lang.reflect.InvocationTargetException in the code  XML
Forum Index -> Ehcache
Author Message
okomba

journeyman

Joined: 10/22/2011 06:57:08
Messages: 12
Offline

Hello everyone,

I have the code:
Code:
 		
 		Element element = cache.get( id );
 		if (element != null) {
 			try {
 			  return (Response)element.getValue();
 			}
 			catch (net.sf.ehcache.CacheException except) {}
 			catch (Exception except) {}
 		}
 			
 
 
 


which was working fine till I made changes to Response. Now it's throwing the error:


Code:
 
 java.lang.reflect.InvocationTargetException
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.lang.reflect.Method.invoke(Method.java:616)
 	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
 	at java.lang.Thread.run(Thread.java:679)
 Caused by: net.sf.ehcache.CacheException: java.io.InvalidClassException: com.aqqin.jaxrsapi.Response; local class incompatible: stream classdesc serialVersionUID = 7876614684643502017, local class serialVersionUID = -3128657363762751944
 	at net.sf.ehcache.store.compound.factories.DiskPersistentStorageFactory.retrieve(DiskPersistentStorageFactory.java:212)
 	at net.sf.ehcache.store.compound.factories.DiskPersistentStorageFactory.retrieve(DiskPersistentStorageFactory.java:60)
 
 
 


I would like to capture this particular error/exception in the try/catch block but even using Exception is not able to capture. How can I capture java.lang.reflect.InvocationTargetException or related error/exception that's thrown in the code?

Thanks.

Mugoma.
hhuynh

cherubim

Joined: 06/16/2006 11:54:06
Messages: 761
Offline

maybe it happens outside of your try block? Try moving

Element element = cache.get( id );

inside the try block.

okomba

journeyman

Joined: 10/22/2011 06:57:08
Messages: 12
Offline

Thanks hhuynh.

Expanding the try/catch block solved the problem.

Thanks again.

Mugoma.
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team