Reputation: 119
Hi am upgrading hazelcast from 3.6.5 to 3.7.4 followed the instructions from hazelcast doc.
am getting an exception like: java.lang.ClassCastException: com.hazelcast.spi.impl.UnmodifiableLazyList cannot be cast to java.util.ArrayList
i just upgraded hazelcast jar do i need to do any other jar upgrade?
stacktrace follows:
2017-01-24 11:33:44 ERROR error:162 - Exception occurred in class com.rathish.test.services.authentication.impl.LocalClient the exception details are: Exception:
[errorCode = 504,
errorMessage = Failure - Unable to retrieve entity from database
Detailed exception trace =
java.lang.ClassCastException: com.hazelcast.spi.impl.UnmodifiableLazyList cannot be cast to java.util.ArrayList
at com.rathish.test.services.authentication.dao.RoleDao.getRoleByUserId(RoleDao.java:367)
at com.rathish.test.services.authentication.impl.LocalClient.authorizeCredentials(LocalClient.java:108)
at com.rathish.test.services.authentication.AuthValidation.validateAuthorization(AuthValidation.java:420)
at com.rathish.test.services.authentication.AuthValidation.loginValidation(AuthValidation.java:104)
at com.rathish.test.services.authentication.AuthenticationService.login(AuthenticationService.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:141)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.process(ProxyServlet.java:74)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.doFilter(ProxyServlet.java:291)
at org.eclipse.equinox.servletbridge.BridgeServlet.process(BridgeServlet.java:149)
at org.eclipse.equinox.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.rathish.test.web.filter.SessionValidationFilter.doFilter(SessionValidationFilter.java:105)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.hazelcast.spi.impl.UnmodifiableLazyList cannot be cast to java.util.ArrayList at com.rathish.test.services.authentication.dao.RoleDao.getRoleByUserId(RoleDao.java:367) ... 56 more using along with maven
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.7.4</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-client</artifactId>
<version>3.7.4</version>
</dependency>
Upvotes: 1
Views: 252
Reputation: 73548
Based entirely on your stacktrace, your RoleDao class on line 367 is something like the following (variable and method names are entirely arbitrary):
ArrayList<Baz> foo = (ArrayList<Baz>)hazelCast.findById(bar);
This presumably worked before since the actual type returned was ArrayList
. However it has since changed to UnmodifiableLazyList
.
Solution is to always program to interfaces, and change the code to
List<Baz> foo = hazelCast.findById(bar);
(or Collection<Baz>
, depending on what the API states as the return type).
Upvotes: 1
Reputation: 1642
Are you sure it used to work in 3.6.x?
I'm looking at the history in github and it always used to extend the java.util.AbstractList
like this:
public class UnmodifiableLazyList<E> extends AbstractList<E> implements DataSerializable {
So it never used to extend ArrayList
Upvotes: 0