Questions tagged [classcastexception]
The Java exception thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.
1,701
questions
0
votes
0
answers
6
views
JedisClusterStringCommands.get(...) 67 line throw java.lang.ClassCastException by chance
In the case of high concurrency and frequent reads of the same key,JedisClusterStringCommands.get(...) 67 line throw java.lang.ClassCastException,it's an accidental event.
spring-data-redis version:2....
0
votes
0
answers
31
views
Hibernate String column - found [character (Types#CHAR)], but expecting [char (Types#VARCHAR)]
So I have a String attribute about a code which is exactly 4 characters long: "1A9C".
Therefor I chose CHAR(4) as a datatype on the database (DB2 z/OS or in-mem H2).
My entity looks like ...
2
votes
0
answers
21
views
Kafka stream with protobuf messages
I have stream of protobuf messages with one type AccountHolder.proto with {name,balance,time} as fields and doing some aggregations on the data content and writing the result as protobuf message of ...
0
votes
1
answer
30
views
How to achieve an quantity summed up object list where the name of object is same in java stream collect operation avoiding toMap
I'm trying to get the quantity of the object summed up if the name of the object matches.
The POJO details are as below:
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ...
0
votes
0
answers
65
views
Android Studio Giraffe IDE internal error, java.lang.ClassCastException, everytime I launch Studio
Android Studio Giraffe | 2022.3.1 Patch 2
Build #AI-223.8836.35.2231.10811636, built on September 15, 2023
Runtime version: 17.0.6+0-17.0.6b829.9-10027231 aarch64
VM: OpenJDK 64-Bit Server VM by ...
0
votes
3
answers
78
views
ClassCastException when using clojure.string/split
I'm writing a website using clojure hiccup for html and clojure garden for css. Now I'm having trouble using clojure.string/split to split a path for the filename. So for some/path/file.md I want file....
1
vote
1
answer
62
views
java.lang.ClassCastException: com.google.firebase.FirebaseException cannot be cast to com.google.firebase.auth.FirebaseAuthException [duplicate]
Whenever I am trying to get the errorCode from the exception received from task.getException() by typecasting to "FirebaseAuthException" it gives and error as java.lang.ClassCastException: ...
2
votes
2
answers
113
views
Google Play In-App Reviews API java.lang.ClassCastException
After implementing google play In-App reviews API in my app i keep getting ClassCastException crash in firebase.
Fatal Exception: java.lang.ClassCastException: android.os.RemoteException cannot be ...
1
vote
1
answer
213
views
java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType in the pre launch report
I updated my app recently and I've got the Google Play pre-launch report found this issue on 9 tested devices
Exception java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang....
0
votes
0
answers
28
views
WebLogic 12c ClassCastException when Using JPA
We are currently migrating our Java EE application from Weblogic 11g to Weblogic 12c.
Here were are facing ClassCastException when using JPA EntityManager's query.getSingleResult() method.
It seems to ...
1
vote
0
answers
400
views
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.springboot.Employeeportal.dto.EmployeeDto
I am using Elastic Search Request object to perform a Get request by passing a SQL query. The EntityUtils.toString(response.getEntity()) returns a String with following values,
{
"columns":
[...
0
votes
0
answers
42
views
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: cannot be cast to class
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException:
class application.Admin_HomePage_Controller cannot be cast to
class application.HomePage_Controller
(...
4
votes
2
answers
2k
views
java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType with retrofit2
I have this code:
val profile: UserProfile = userApi.profile()
@GET("users/profile")
suspend fun profile(): UserProfile
When i run userApi.profile() i get this error:
java.lang....
1
vote
0
answers
108
views
Java classcasting / classloading mess in SAP CPI
I'm working on a Groovy script in the SAP CPI environment which means the script runs in a somewhat canned JVM.
I uploaded the jjwt-api-0.11.2, jjwt-impl-0.11.2 and jjwt-jackson-0.11.2 jars, in order ...
0
votes
0
answers
105
views
ClassCastException with Spring and eclipselink configuration
I'm getting a strange error while using Spring with eclipselink
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The class, [MigriertAttributeTransformer] cannot be used ...
0
votes
0
answers
162
views
Java throwing class cast exception even if types are correct
I was learning about Matrix Variables in spring boot but I encountered problems while extracting the data.
@GetMapping(value = "/{query}/plan", produces = {"application/xml"})
...
0
votes
1
answer
183
views
java.lang.ClassCastException: BottomNavigationView cannot be cast to BottomNavigationItemView
I was working on adding a top bar to my bottom navigation view selected item, I followed this thread. But I got hit with a cast exception and the app crash. How to fetch the BottomNavigationItemView ...
1
vote
1
answer
1k
views
Kotlin, Retrofit, ClassCastException, com.google.gson.internal.LinkedTreeMap cannot be cast to List<CatListItem>?
My interface
interface ApiService {
@GET("URL")
fun getCatList(
@Query("var1") var1: String,
@Query("var2") var2: String,
): Call<List<...
0
votes
0
answers
108
views
Can SnakeYAML be used to parse a map of objects?
I have the following YAML file:
a:
name: alpha
b:
name: beta
I want to turn this into a Map<String, Item>, where an Item looks like this:
@Data
@NoArgsConstructor
public static class Item {
...
2
votes
1
answer
88
views
Force inlining of Kotlin inline-class?
@LukasEder, this question is more Kotlin related, you can probably skip it in favour of the more jOOQ-related continuation in https://github.com/jOOQ/jOOQ/issues/14972 :)
So part of a legacy database ...
0
votes
0
answers
23
views
Apache Camel Solr-component expecting file?
I am using java with Apache Camel (version 3.18.3) to perform operations in solr but I keep having the problem that I can't use direct routes but have to print the documents to be ingested, delete-...
0
votes
0
answers
92
views
`ClassCastException` with Eclipse RCP Internals on 2022-12
I am currently responsible for upgrading a legacy Eclipse RCP application at my job from Java 11 to Java 17. As part of this, I am upgrading from Eclipse 2018-12 to 2022-12.
However, this has ...
3
votes
3
answers
4k
views
ClassCastException: with unnamed module of loader 'app': Spring Data Redis
I am working on a small demo project for Redis and Spring Boot. But for the following GET endpoints I am getting ClassCastException.-
@GetMapping("/all")
public List<Product> ...
0
votes
0
answers
57
views
Why is my Android app is crashing - android.content.ComponentName cannot be cast to java.lang.Object[]?
I am seeing app crashes in Crashlytics across all Android versions. Unable to reproduce the crash locally. Seeing the following stacktrace -
Fatal Exception: java.lang.ClassCastException
android....
0
votes
1
answer
16
views
java.lang.ClassCastException:com.eltoh.date.onboarding.screens.FavouriteListFragment cannot cast to com.eltoh.date.onboarding.screens.ChatListFragment
I tried to execute a method in a specific fragment from the ViewPager2 fragment of that fragment.
It works fine on startup, but when moving between other fragments in ViewPager and back again for that ...
1
vote
1
answer
514
views
ClassCastExceptions running Keycloak with remote Infinispan cache
Setup
Keycloak 16.1.1 wired up to an Infinispan 14 cluster for remote caching of session data (user sessions, authentication sessions, client sessions, etc.). Both Keycloak and Infinispan are using ...
0
votes
1
answer
610
views
Spring Cloud route to webscoket service causes "ResponseFacade cannot be cast to class HttpServerResponse"
I have this section in application.yml
cloud:
gateway:
routes:
- id: websocket
uri: ws://localhost:53110
predicates:
- Path=/ws/**
- id: ...
0
votes
0
answers
72
views
java.lang.ClassCastException: org.springframework.jndi.JndiObjectFactoryBean$$EnhancerBySpringCGLIB$$ceb3620f cannot be cast to javax.sql.DataSource
My code is like below, this (DataSource) dataSource.getObject() is giving classcast exception.
@Bean
public DataSource dataSource() throws IllegalArgumentException {
JndiObjectFactoryBean ...
-2
votes
2
answers
100
views
JavaFX ClassCastException using iText PDF
I am trying to download a TableView in JavaFx as an pdf document. I am using iText 7.2.5 . When I am clicking the button to download the TableView, it is asking me to select the folder then it is ...
0
votes
0
answers
178
views
Apache Avro does not print BigDecimal into parquet file Error : java.math.BigDecimal cannot be cast to java.nio.ByteBuffer
I need to create parquet file with using apache-avro library in Java8. the POJO created automatically from ".avsc" file with maven generation-resource. but I have trouble with BigDecimal ...
1
vote
0
answers
59
views
org.springframework.security.core.userdetails.User cannot be cast
@RestController
public class ChangePasswordController {
@Autowired
private UserService userService;
@Autowired
private PasswordEncoder passwordEncoder;
@PostMapping("/...
1
vote
1
answer
285
views
Unable to read and write DELTA files via SPYLON-KERNEL in JupyterLab: java.lang.ClassCastException
Unable to read delta files via spylon kernel in JupyterLab.
Upon trying to read the delta files via spylon kernel in JupyterLab I am facing the java.lang.ClassCastException error as below,
I tested ...
1
vote
1
answer
70
views
Understanding why inlining function fixes runtime crash when collecting
I want to understand why inlining function fixes runtime error.
The following code results in a runtime error (see bellow)
[error] java.lang.ClassCastException: class Herbivore cannot be cast to class ...
0
votes
1
answer
131
views
Jetty WARs container - different class loader for the same class
I have a jetty server that contains 6 wars.
for example: a.war, b.war and more..
a and b have a dependency on x jar. both of them use the same version.
I have a strange problem:
when the jetty is ...
0
votes
2
answers
147
views
Cannot cast object 'class centaur.demo.Profile' with class 'java.lang.Class' to class 'centaur.demo.Profile'
Please help me to fix this issue. Thank you!
I am working on a Grails-5.2.4 project with Java 1.8. Class Loader is not working as expected.
I am getting class cast exception for the following piece of ...
0
votes
0
answers
31
views
ClassCastException handling
I have a legacy code that looks like this,
///
....
List<Object[]> reportResults = new ArrayList<Object[]>();
reportResults = query.getResultList();
logger.info("reportResults ==== &...
0
votes
1
answer
2k
views
SPARK java.lang.ClassCastException: org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema cannot be cast
i am trying to use the agg function with type safe check ,i created a case class for the dataset and defined its schema
case class JosmSalesRecord(orderId: Long,
...
1
vote
0
answers
277
views
AvroParquetWriter - addLogicalTypeConversion not working as expected (using version parquet-avro 1.12.3) - causing ClassCastException
I am writing ResultSet to parquet file using AvroParquetWriter. One column in the ResultSet is java.sql.Timestamp. When writing, I get the exception :
java.sql.Timestamp cannot be cast to java.lang....
0
votes
1
answer
109
views
How can I debug this java.lang.ClassCastException that occurs when using an iterator?
I am trying to separate Passenger objects from an ArrayList into eight smaller lists. I am traversing the list of Passengers using iterator.
I have tried to use the iterator without explicitly casting ...
6
votes
1
answer
342
views
ClassCastException with Stacktrace Hazelcast version 4.2.5 using ReplicatedMap
Using Hazelcast version 4.2.5 in a webapp deployed on Tomcat on Kubernetes. We're frequently("every 5 seconds") seeing ClassCastException with a stacktrace in the application logs.
Here's ...
0
votes
1
answer
89
views
Raw use of unparameterized class vs. unchecked assignment vs. generic array creation
For various reasons I'm stuck with this bit of Java code that uses Scala types:
scala.Tuple2<scala.Enumeration.Value, Integer>[] tokens = new scala.Tuple2[] {
new scala.Tuple2(scala.math....
-2
votes
2
answers
111
views
Why do I get ClassCastException?
I am trying this piece of code. Why do I get ClassCastException when I have initialized my set to contain elements of type Object which is directly or indirectly parent of all classes in Java?
Set s =...
1
vote
1
answer
282
views
ClassCastException: difference between "cannot be cast to class" and "incompatible with" message
It's clear, the following code can cause a ClassCastException:
Integer a = 1;
Object b = a;
Long c = (Long)b;
The exception is:
Exception in thread "main" java.lang.ClassCastException: ...
0
votes
2
answers
43
views
What is the difference between assigning a raw type to a patamaterized type reference and vice versa?
public class Tr <T> {
T t;
Tr(T t){ this.t = t; }
T get(){ return t; }
public static void main(String args[]) {
//Tr VarOne = new Tr<Integer>("i");
...
0
votes
1
answer
64
views
How to throw a ClassCastException when a Double variable is cast to the generic type T?
I'm implementing a generics class LabelEncoder<T> in Java, referring to sklearn.preprocessing.LabelEncoder.
Besides providing the method void fit(T[] labels, boolean natural), this class also ...
10
votes
1
answer
12k
views
ClassCastException when stopping Tomcat 10 inside Eclipse
I am using Eclipse 2022-06 and Tomcat 10.0.10.
Often, when shutting down Tomcat running inside Eclipse, I get
WARNUNG: Failed to clear soft references from ObjectStreamClass$Caches for web application ...
0
votes
1
answer
639
views
Why am I getting a java.lang.ClassCastException in Kotlin?
I wrote this sample code that I extracted from a library that I'm making because it is causing a java.lang.ClassCastException and I don't understand why. Here's the code:
interface Event
data class ...
0
votes
1
answer
366
views
Getting a ClassCastException when trying a join query in Hibernate
This is my tables:
@Entity
@Table(name="Students")
public class Students {
@Id
@Column(name="Student_ID")
private int id;
@Column(name="Student_Name")
private String ...
0
votes
0
answers
815
views
ClassCastException: class java.util.LinkedHashMap cannot be cast to class on forEach call
I'm trying to make a list of Integers from an attribute of an object inside a list, but I keep getting this error, I've tried using lambdas, and common loops, but I can't figure out what's the problem ...
0
votes
1
answer
150
views
ClassCastException occured while using Comparator
I'm having trouble in understanding how to solve this exception:
Exception in thread "main" java.lang.ClassCastException: class java.lang.Object cannot be cast to class Studente (java.lang....