Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

ClassCastException inside of UnusableEntryException

hi,

i'm trying to implement a gigaspaces based search service which impements caching.

so the searchService first checks weather there is already a corresponding SearchResponse in the space. if there is one, than reads it, and returns with the hit ist. if there is no corresponding (matching query string) SearchResponse, than it writes a SearchRequest (POJO) to the space and the PU is responding by writing a SearchResponse (POJO) back to the space (with a lease time of let's say 5 minutes). the PU is using a poling container and is running as a puInstance.sh.

when the SearchService is writing the the SearchRequest to the space the PU is able to take it, and able to write the ServiceResponse. but when the SearchService tries to read it there is an UnusableEntryException. when checking the exceptions content: - unusable fields :null - partialEntry :null - nested Exception: exception:java.lang.ClassCastException: org.mypackage.SearchResponse at com.j_spaces.core.client.JSpaceProxyUtil.getEntry(SourceFile:730) at com.j_spaces.core.client.JSpaceProxyUtil.getEntry(SourceFile:871) at com.j_spaces.core.client.JSpaceProxyUtil.getEntry(SourceFile:854) at com.j_spaces.core.client.single.action.AbstractSingleSpaceReadTakeActionListener.read(SourceFile:210) at com.j_spaces.core.client.single.action.SingleSpaceReadActionListener.onAction(SourceFile:35) at com.j_spaces.core.client.single.action.SingleSpaceReadActionListener.onAction(SourceFile:16) at com.j_spaces.core.client.AbstractSpaceProxy.read(SourceFile:167) at com.j_spaces.core.client.AbstractSpaceProxy.read(SourceFile:150) at org.mypackage.SerarchService.performSearch()

The strange thing is that from gs.sh i can see that there is 1 object of SearchResponse, and i can even display it with: space sql -url jini://*/searchSpace_container/searchSpace -query select * from org.mypackgae.SearchResponse

also when i run the SearchService.performSearch() with the same parameters, it's able to read the SearchResponse (produce by the previous cal)

some more detail about the POJO: - SearchResponse implements Serializable - it has a: private static final long serialVersionUID - it implements hashCode() based on apaches HashCodeBuilder - it impements equals() based on EqualsBuilder - its using the following annotations for the getId() field: @SpaceRouting @SpaceProperty(index=IndexType.BASIC) @SpaceId(autoGenerate = false)

any tips are appreciated!

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2654]{quote}

asked 2008-10-13 12:22:27 -0500

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Do you have your Space Domain classes (i.e. org.mypackage.SearchResponse) as part of a jar under a folder called shared-lib under the PU folder?

Shay

answered 2008-10-13 13:02:55 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

hi shay,

thanks for your quick response! sure i have all the jar files in shared-lib. i even tried to combine all jars in the shared lib into one single giant.jar (as i one my college suggested) but it didn't help.

by the way if the class were not in the shared-lib, i would get a ClassNotFound, or ClassDefNotFound exception, but what i got is a ClassCastException. isn't true?

gipszlyakab gravatar imagegipszlyakab ( 2008-10-13 15:32:33 -0500 )edit

oh one more thing, the exception is thrown on the "client" side, the PU is working without any problem.

and the classpath problem cann't explain, how is the client able to read the SearchResponse for the second run.

On the first run: - SearchService checks the space, and relize that it contains no SearchResponse - SearchService write a SearchRequest to the space - PU takes the SearchRequest and writes a SearchResponse - SearchService tries to read() - UnusableException (nested Classcast) is trown

On the second run: - SearchService checks the space, and tries to read it. - successfully read, its able to print it out.

In the 2 run the casspath settings are the same of course ...

gipszlyakab gravatar imagegipszlyakab ( 2008-10-13 15:43:47 -0500 )edit

Can you provide more details about the client? Is this a stand alove Java client ? web server? Any chance you got different class loader used at the client side?

Why you have not implemented caching using the interfaces that has been created to deal with such scenarios (DataPersister and com.gigaspaces.datasource.SQLDataProvider and com.gigaspaces.datasource.DataPersister) ? This is much better way to deal with lazy loading than the request/response pattern.

Which product version you use?

Can you post the SearchRequest and SearchResponse with the relevant client code?

Shay

shay hassidim gravatar imageshay hassidim ( 2008-10-13 16:04:37 -0500 )edit

i'm using 6.0 build 2040 and i was reading your mind ;) and give a go to 6.6, and miracle ...
6.6 throws no UnusableEntry exception any more.

The only problem that the production system is still using 6.0
is there any patch.jar for 6.0?

gipszlyakab gravatar imagegipszlyakab ( 2008-10-14 04:15:15 -0500 )edit

You can try 6.0.5 build 2150 release:
http://www.gigaspaces.com/PreviousSupportedVersions

In any case moving from 6.0.X to 6.6 does not involve any major changes.

In most cases it just involves replacing the jars.

Shay

shay hassidim gravatar imageshay hassidim ( 2008-10-14 06:14:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-10-13 12:22:27 -0500

Seen: 15 times

Last updated: Oct 13 '08