Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException: class org.entur.lamassu.model.entities.Vehicle #155

Open
hbruch opened this issue Mar 25, 2023 · 3 comments
Open

ClassCastException: class org.entur.lamassu.model.entities.Vehicle #155

hbruch opened this issue Mar 25, 2023 · 3 comments
Labels
wontfix This will not be worked on

Comments

@hbruch
Copy link
Collaborator

hbruch commented Mar 25, 2023

When starting up Lamassu, occasionally ClassCastExceptions get logged which are apparently caused by SpringBoot's devtools classloading (see e.g. this stackoverflow thread):

java.lang.ClassCastException: null
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:564)
	at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:591)
	at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:689)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
	at org.entur.gbfs.GbfsSubscriptionManager.lambda$update$0(GbfsSubscriptionManager.java:68)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.ClassCastException: class org.entur.lamassu.model.entities.Vehicle cannot be cast to class org.entur.lamassu.model.entities.Vehicle (org.entur.lamassu.model.entities.Vehicle is in unnamed module of loader 'app'; org.entur.lamassu.model.entities.Vehicle is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @5185ac30)
	at org.entur.lamassu.leader.entityupdater.VehiclesUpdater.lambda$addOrUpdateVehicles$4(VehiclesUpdater.java:140)
	at java.base/java.util.HashMap.forEach(HashMap.java:1421)
	at org.entur.lamassu.leader.entityupdater.VehiclesUpdater.addOrUpdateVehicles(VehiclesUpdater.java:138)
	at org.entur.lamassu.leader.entityupdater.EntityCachesUpdater.updateEntityCaches(EntityCachesUpdater.java:46)
	at org.entur.lamassu.leader.FeedUpdater.receiveUpdate(FeedUpdater.java:133)
	at org.entur.lamassu.leader.FeedUpdater.lambda$createSubscription$1(FeedUpdater.java:113)
	at org.entur.gbfs.GbfsSubscription.update(GbfsSubscription.java:104)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.concurrent.ConcurrentHashMap$ValueSpliterator.forEachRemaining(ConcurrentHashMap.java:3612)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
	... 5 common frames omitted

I'm unsure about the impact of this exception, but for production deployments devtools should explicitly not be packaged. Another option would be to disable devtools restart by adding spring.devtools.restart.enabled = false to application.properties.

@testower
Copy link
Collaborator

Yes I have also noticed this, but not yet found a solution.

@hbruch
Copy link
Collaborator Author

hbruch commented Sep 13, 2023

Consequence of this error seems to be, that caches are cleared, it seems to me. As this seems to happen only in dev mode with spring devtools enabled, that would not impact production.

@testower
Copy link
Collaborator

Yeah possibly a conflict between spring dev tools and kryo. Keeping the issue open just for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants