classcastexception

ClassCastException when casting Class.forName object to interface implemented by this object

你说的曾经没有我的故事 提交于 2019-12-12 19:08:56
问题 I want to create some plugin example for android, so I have 3 projects for it: ExternalLibInterface - contains IExternalLib , and builds to externallibinterface.jar file package com.example.externallibinterface; public interface IExternalLib { public String someMethod( String param ); } ExternalLib - contains externallibinterface.jar and SomeClass implements IExternalLib , builds to externallib.apk package com.example.externallib; import com.example.externallibinterface.IExternalLib; public

Retrofit2: ClassCastException: java.util.ArrayList cannot be cast to retrofit2.Call

允我心安 提交于 2019-12-12 16:33:27
问题 please help with Retrofit2. I'm very new in Retrofit. I create simple server application. The application manage list of Journals: add Journal in the in-memory list and return Journal by id. There is an Journal.java: public class Journal { private AtomicInteger getNewId = new AtomicInteger(0); @SerializedName("id") @Expose private Integer id; @SerializedName("name") @Expose private String name; public Journal(String name) { this.id = getNewId.incrementAndGet(); this.name = name;} public

Need help understanding JNDI and a particular ClassCastException in J2EE

与世无争的帅哥 提交于 2019-12-12 12:27:22
问题 I have an enterprise application A and B deployed (in WLS 10.0). A is the "framework", B is a client app. The client issues the following calls: Object o = ctx.lookup(jndiName); // line 1 cf = (ConnectionFactory) o; // line 2 ConnectionFactory is an interface, defined as: public interface ConnectionFactory extends java.io.Serializable, javax.resource.Referenceable { ... } What happens is: If the jar containing the interface class is on the system classpath, line 2 is executed fine If the

Java cast double to long exception

两盒软妹~` 提交于 2019-12-12 09:16:55
问题 1- long xValue = someValue; 2- long yValue = someValue; 3- long otherTolalValue = (long)(xValue - yValue); That line of code give me the following exception: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long. Update : code piece: StackedBarChart<String,Number> sbc = new StackedBarChart<String,Number>(); XYChart.Series<String, Number> series = new XYChart.Series<String, Long>(); series.getData.add(new XYChart.Data<String, Number>("X1",150)); series.getData.add(new

java.lang.ClassCastException: android.support.v7.widget.ActivityChooserView$InnerLayout cannot be cast to android.support.v7.widget.LinearLayoutCompat

丶灬走出姿态 提交于 2019-12-12 08:33:51
问题 Switching from LinearLayout to ConstraintLayout throwing this error java.lang.ClassCastException: android.support.v7.widget.ActivityChooserView$InnerLayout cannot be cast to android.support.v7.widget.LinearLayoutCompat The error occurs when i try to inflate the menu in onCreateOptionsMenu() in my fragment. My menu which I inflate :- <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item

Hibernate -> ArrayList cannot be cast to Set

这一生的挚爱 提交于 2019-12-12 08:31:01
问题 I have a Java EE application and I use Hibernate. The domain objects, I changed the List / ArrayList to Set / HashSet, because it is better to use Sets. But in my Dao implementation I run into a problem: public Set<Person> getAllPersons() { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session sess = sessionFactory.getCurrentSession(); Transaction tx = sess.beginTransaction(); @SuppressWarnings("unchecked") Set<Item> items = (Set<Item>) sess.createQuery("from Item").list(

“Iterable<Element> cannot be cast to List<Element>” - Isn't `List` a type of `Iterable`?

帅比萌擦擦* 提交于 2019-12-12 08:24:30
问题 I called a getElements method which returns Iterable<Element> . I did this: List<Element> elements = (List<Element>) getElements(); This generates the error: java.lang.ClassCastException: com.utesy.Element$3 cannot be cast to java.util.List I thought a List was a type of Iterable ? 回答1: Yes, List<T> extends Iterable<T> , but that doesn't mean that you can cast from any Iterable<T> to List<T> - only when the value actually refers to an instance of a type of List<T> . It's entirely possible to

Getting 'java.lang.ClassCastException' while trying to set subtitle of a CollapsingToolbarLayout

喜夏-厌秋 提交于 2019-12-12 04:23:30
问题 I'm trying to set 'Sub-title' of a CollapsingToolbarLayout in my app using this example here. Here's the code from onCreate() of Profile.java : CollapsingToolbarLayout collapsingToolbarLayout; Toolbar toolbar; HeaderView toolbarHeaderView; HeaderView floatHeaderView; collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar); // error on the line below toolbarHeaderView = (HeaderView) findViewById(R.id.toolbar_header_view); floatHeaderView = (HeaderView)

ClassCastException: Lucene40PostingsFormat on Hibernate Search

余生长醉 提交于 2019-12-12 04:20:55
问题 I am trying using Hibernate-Search for add full text search capabilities but when i try deploy the ear proyect on glashfish application server i get the Lucene40PostingsFormat classCastException. here it is the complete server log: Información: HHH000412: Hibernate Core {[WORKING]} Información: HHH000206: hibernate.properties not found Información: HHH000021: Bytecode provider name : javassist Información: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} Información: HHH000400: Using

Getting 'java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map' even when I'm not casting any Long

醉酒当歌 提交于 2019-12-12 01:54:33
问题 I'm trying to retrieve some data from Firebase using addChildEventListener() like this (code is in a Service ): aReference.child(requestID).addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { if (dataSnapshot.getValue() != null) { // error on the line below Map<String, String> nUser = (Map<String, String>) dataSnapshot.getValue(); userNameAU = nUser.get("uName"); Log.d("uName", userNameAU); } ... ... }); but I'm getting