Code: Select all
public ServerRoomsResponse handleGetRoomsInfo() throws Exception
{
log.debug("handleGetRoomsInfo");
ServerRoomsResponse serverRoomsResponse = new ServerRoomsResponse();
List<ServerRoomsResponse.RoomInfo> roomInfoList = new ArrayList<ServerRoomsResponse.RoomInfo>();
Zone gelatoZone = zoneManager.getZoneByName("Gelato");
SFSExtension zoneExtension = (SFSExtension) gelatoZone.getExtension();
try
{
@SuppressWarnings("unchecked")
Collection<GameRoom> gameRooms = (Collection<GameRoom>) zoneExtension.handleInternalMessage(
MessageName.SERVER_ROOM_INFO, new SFSObject());
for (GameRoom
gameRoom : gameRooms)
{
ServerRoomsResponse.RoomInfo roomInfo = new ServerRoomsResponse.RoomInfo();
roomInfo.setRoomName(gameRoom.getRoomName());
roomInfo.setPlayerCount(gameRoom.getPlayerCount());
roomInfo.setUserCount(gameRoom.getUserCount());
roomInfo.setSpectatorCount(gameRoom.getSpectatorCount());
roomInfoList.add(roomInfo);
}
} catch (Exception ex)
{
log.error("Error in handleRoomInfo", ex);
throw new Exception("Error in handleRoomInfo", ex);
}
serverRoomsResponse.setRooms(roomInfoList);
return serverRoomsResponse;
}
but, if I use a subclass of GameRoom, that exits in my extension jar (which is in an extension folder, not the __lib__ directory), I get a ClassCastException due to different class loaders:
Code: Select all
16:04:06.365 [154655349@qtp-1426481592-7] ERROR o.b.g.messages.SFSMessageHandler - Error in handleRoomInfo
java.lang.ClassCastException: org.buffalo.gelato.entities.GelatoRoom cannot be cast to org.buffalo.gelato.entities.GelatoRoom
at org.buffalo.gelato.messages.SFSMessageHandler.handleGetRoomsInfo(SFSMessageHandler.java:97) [classes/:na]
at org.buffalo.gelato.resources.ServerDataResource.getRoomData(ServerDataResource.java:22) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [na:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601) [na:1.7.0_04]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-bundle-1.13.jar:1.13]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) [jersey-bundle-1.13.jar:1.13]
Is there a strategy I should use to be dealing with this issue? I've tried excluding my extension classes from the webapp (using provided scope in our pom) but that results in a java.lang.ClassNotFoundException.