classcastexception

Why I cannot cast oracle BLOB from native java Blob

℡╲_俬逩灬. 提交于 2019-12-23 14:56:09
问题 I am reading file from ResultSet and it's required to save file into Oracle Database. ... ResultSet rs = ... java.sql.Blob myfile = rs.getBlob("field") java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream(); I get get this error message java.lang.ClassCastException Any one have solution to this? Thanks! 回答1: I have found the solution. I'd like to share with those who has this problem. The code to get outputstream from oracle blob is: java.io.OutputStream os = ((oracle

Strange classCastException hibernate 3.5 glassfish

拟墨画扇 提交于 2019-12-23 10:09:58
问题 Hi I have a problem that I can't solve on my own. I have a war file packaged in ear and running on glassfish 3.0.1 with hibernate 3.5 as JPA provider. I compile it with maven and deploy it with idea or manually. Every other time I get a cast exception in my DAOs: java.lang.ClassCastException: com.myproject.domain.entity.User cannot be cast to com.myproject.domain.entity.User Other times it works perfectly fine. There is no pattern in this behaviour. Could someone shine some light on what is

ClassCastException using a custom adapter for an AutoCompleteTextView

倖福魔咒の 提交于 2019-12-23 04:22:48
问题 In Xamarin, I am having trouble with a custom adapter for a AutoCompleteTextView. Here is my code: private void SetupAutoCompleteTextViewWithCustomAdapter() { List<CustomItem> customItems = new List<CustomItem>(); CustomItem customItem = new CustomItem(); customItem.Heading = "TestHeading"; customItem.SubHeading = "TestSubHeading"; customItems.Add(customItem); customItem = new CustomItem(); customItem.Heading = "TestHeading 2"; customItem.SubHeading = "TestSubHeading 2"; customItems.Add

Android LinkedHashMap deserializing as HashMap, causes CCE error

妖精的绣舞 提交于 2019-12-22 12:27:14
问题 I'm attempting to pass a serialized LinkedHashMap between activities, and getting a confusing result/error when I deserialize the object. I serialize the object as follows: Bundle exDetails = new Bundle(); LinkedHashMap<String, Exercise> exMap = new LinkedHashMap<String, Exercise (workout.getExercises()); exDetails.putString(WORKOUTNAME, workout.getWorkoutName()); exDetails.putSerializable(workout.getWorkoutName(), exMap); iComplete.putExtra("wName", exDetails); startActivity(iComplete); That

extending superclass and ClassCastException

左心房为你撑大大i 提交于 2019-12-22 08:37:11
问题 I have a superclass, which two methods i want to override. Here's my code: public class MyCustomClass extends SomeSuperClass { protected MyCustomClass(params) { super(params); } @Override public void method1() { super.method1(); /* here goes my code */ } @Override public void method2() { super.method2(); /* here goes my another code */ } I have some constructor, that passes SomeSuperClass object as a parameter, and what i do next: MyCustomClass object; /* now i have object of type

Oracle JDBC driver conflict

雨燕双飞 提交于 2019-12-22 08:18:59
问题 JBoss EAP 6.1 standlone server Application deployed as a war file throws a runtime exception java.lang.ClassCastException: oracle.sql.ARRAY cannot be cast to oracle.sql.ARRAY at line oracle.sql.ARRAY obj = (oracle.sql.ARRAY) rs.getObject("RATINGOBJ"); JDBC libary included is ojdbc6.jar (WEB_INF/lib). All libraries are included in the war file and there are no "global" libaries setup on the server. I have verified no other jdbc libraries are included anywhere in the app. In order to create a

Class Cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

懵懂的女人 提交于 2019-12-22 06:37:29
问题 I'm struck with a problem in jboss. When I try to deploy my .war into the server, I get this following error, java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.SAXParserF actoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory from which, it is quite evident that there is a clash of libraries. So, I removed the jar file which contains xerces, which happened to by jaxp-ri-1.4.1.jar. Now, when I try to re-deploy, I get this new error, java.lang.NullPointerException

If A extends B extends C, why can I cast to A but get a ClassCastException casting to C?

孤人 提交于 2019-12-22 04:44:09
问题 I am trying to read an ASN1 object using Bouncycastle on Android. I expect it to be a DERSequence, which in Bouncycastle is a subclass of ASN1Sequence, which is a subclass of ASN1Object. import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.DERSequence; ... ASN1InputStream ais = ...; Object o = ais.readObject(); // Eclipse's debugger now says o is a DERSequence, as expected. DERSequence o2

How to detect ambiguous method calls that would cause a ClassCastException in Java 8?

限于喜欢 提交于 2019-12-21 07:39:07
问题 We are currently in the process of migrating an application from Java 7 to Java 8. After fixing a some compilation issues, I stumbled upon an issue similar to the following question: ClassCast Error: Java 7 vs Java 8. To summarise, here is a sample code that shows the issue: public class Test { public static void main(String[] args) { System.out.println(String.valueOf(getVal("xxx"))); // 7: prints the result, 8: Exception } @SuppressWarnings("unchecked") public static <T> T getVal(String

How to detect ambiguous method calls that would cause a ClassCastException in Java 8?

限于喜欢 提交于 2019-12-21 07:39:06
问题 We are currently in the process of migrating an application from Java 7 to Java 8. After fixing a some compilation issues, I stumbled upon an issue similar to the following question: ClassCast Error: Java 7 vs Java 8. To summarise, here is a sample code that shows the issue: public class Test { public static void main(String[] args) { System.out.println(String.valueOf(getVal("xxx"))); // 7: prints the result, 8: Exception } @SuppressWarnings("unchecked") public static <T> T getVal(String