classcastexception

Why am I getting a ClassCastException when generating javadocs?

I'm using ant to generate javadocs, but get this exception over and over - why? I'm using JDK version 1.6.0_06. [javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc [javadoc] at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java...

Java: Generics, arrays, and the ClassCastException

I think there must be something subtle going on here that I don't know about. Consider the following: public class Foo<T> { private T[] a = (T[]) new Object[5]; public Foo() { // Add some elements to a } public T[] getA() { return a; } } Suppose that your main method contains the following: Foo<Double> f = new Foo...

Why I cannot cast oracle BLOB from native java Blob

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! ...

Strange ClassCastException

This: Timerange longest = Timerange.longest(breaks); if (longest.durationInHours() >= MIN_FREE_HOURS) return true; is OK. But this: if (Timerange.longest(breaks).durationInHours() >= MIN_FREE_HOURS) return true; gives: java.lang.ClassCastException Do you know why?! For simplicity: public static final <T extends Timera...

Class cast exception in Groovy

I want to upload an image using a groovy on grails. My gsp page is as follows (I am showing a simplified version of the original) <g:form controller="post" action="save" enctype="multipart/form-data"> My picture <input type="file" name="myPicture" /> <g:submitButton name="submit" value="Save"/> </g:form> My dom...

ClassCastException when casting to the same class.

Hi, I have 2 different java projects, one has 2 classes dynamicbeans.DynamicBean2 dynamic.Validator On the other project, I load both of these classes dynamically and store them on an Object class Form { Class beanClass; Class validatorClass; Validator validator; } I then go ahead and create a Validator object using v...

Java updating JList using BeanBinding Netbeans

Hi, I have this JList (say MyList) in a JFrame. Im using Netbeans6 GUI builder and I've set a binding for this list. When run, the binding works fine, and MyList is populated correctly. Now, what im looking for is a way to add more data to this list from another text box on a button Click. But the problem exists here : W/o binding i ...

Unknown source of ClassCastException (in JTables)

I'm presently refactoring a JTable which displays a multitude of different types of data. The primary reason for this refactoring is that there a few ClassCastExceptions (the author/friend who wrote the code is off on hiatus), and I can't seem to find where these are originating from. Due to the large codebase, I'm at a loss as to where ...

Creating Object from Hibernate Mapping

If I have a mapping like this: <class name="Users" table="users"> <id column="id" name="id"> <generator class="native"/> </id> ... <set name="types" table="types" cascade="all"> <key column="user_id" /> <element column="type_name" type="string" /> </set> </class> How should the user object b...

Why is this code throwing a ClassCastException and how to avoid it

Consider this code: import java.util.*; class jm45 implements Comparator<jm45> { private int x; jm45(int input) { x = input; } public static void main( String args[] ) { List list = new ArrayList(); list.add(new jm45(2)); list.add(new jm45(2)); Collections.sort(list); //faulty line } public i...

OSGi in Netbeans, ClassCastException when retrieving service

Hi, im having a ClassLoader issue. Since im quite an osgi newby, hopefully the answer isn't that hard :) I think it has to do with Compile vs. Runtime libraries. in Netbeans 6.7.1 project properties, the compiletime libs are always propagated to the other categories.. so i can't differentiate there. When compiling the FelixHost the ...

Why is a ClassCastException only thrown when the return value is accessed?

Related to this question Given this function: public static <S extends CharSequence> S foo(S s) { return (S) new StringBuilder(s); } Why does this invocation execute without exception: foo("hello"); But this one throws ClassCastException? System.out.println(foo("hello")); ...

Do generics in Java avoid all ClassCastExceptins?

Since generics are only checked during compile time with Java 5, can they avoid ClassCastExceptions in all situations? ...

JBoss Class cast exception while accessing EJB3

Hi Java Gurus, I am having a weird problem here with EJB3. Deployed and EJB3 and am trying to access the business method from the deployed instance. I get the following error when the lookup is executed: UserAuthenticationRemote is the remote i/face UserAuthenticationBean is the Bean Code (which fails): UserAuthenticationRemote rem...

isAssignableFrom function of Class.java

Hi, I am trying following Context ctx = (Context) jndiCntx.lookup(fSTANDARD_ENVIRONMENT); Object obj = ctx.lookup(fSTANDARD_JNDINAME); And following code is returning me false MyClass.class.isAssignableFrom(obj.getClass()) although MyClass.class.getName().equalsIgnoreCase(obj.getClass().getName()) returns true. I am not able to...

Type of template if the template is the return value (Java)

I was wondering what is the data type of the template variable if the return is set to a template. I have seen this in a code somewhere but I do not know where does it cast the value retrieved from the session. public class RequestObject { public <T> T getFromSessionMap(String sessionKey) { return (T)session.getAttribute(sessio...

Why does ClassCastException not show the class name?

In Java 1.4.2 and earlier versions, if you get a ClassCastException, you can see the exception stack trace but not the class name. If you want to find out the class of the object for which casting failed, you have to debug. Is it still the same in later Java versions? If so, when did it change? ...

Servlet Exception + Class Cast Exception + Glassfish + Netbeans + JPA Entities + Vaadin

Hi all, I get this error: StandardWrapperValve[Vaadin Servlet]: PWC1406: Servlet.service() for servlet Vaadin Servlet threw exception java.lang.ClassCastException: com.delhi.entities.Category cannot be cast to com.delhi.entities.Category when I try to run my webapps on glassfish v2. Category is a JPA entity object the offending code...

ClassCastException trying to cast retrieved JPA object to concrete class

I am not certain what I am doing wrong, but I have a class that has a class within it, so when I save the Skill class the user class also gets created, so when I do the join and I want to pull everything in at one time, I get a classcastexception. This is how I am calling my query. val retrieved_obj = em.createNamedQuery("findAllSkills...

Java Generics GetThis Trick Explanation

I am reading about Java Generics and I came across this topic where I am a bit confused. From : http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ205 public abstract class Node <N extends Node<N>> { private final List<N> children = new ArrayList<N>(); private final N parent; protected Node(N par...