Problem setting type with java for each loop

I have drawn a problem with the application that I am developing, it gives me a cast exception. It’s funny that he says that he can’t abandon “entities”. Movi cannot be cast to entities. Movy?! Movies is an ArrayList.

    try {
        movies = getMovies();
    } catch (Exception e) {
        e.printStackTrace(System.out);
    } finally {
        try {
            for (Movie movie : movies) {
                output.append("                 <tr>\n");
                output.append("                     <td>" + movie.getId() + "</td>");
                output.append("                 </tr>\n");
            }
         } catch (Exception e) {
             e.printStackTrace(System.out);
         }
     }
+3
source share
6 answers

Sounds like a class loader conflict. The same class definition loaded by different class loaders is considered by the JVM as two different classes.

There is not much to say with this little information. See this article for more information on class loaders and their problems.

.

+7

, ( )

getClass() Movie.

, , . , .

, , JAR .

+4

, , - Collection<Movie> .

0

, Java.

0

, , , serialversionuid.

0

, (, ORM), , IDE , IDE .

, ? , , , "".

0

Source: https://habr.com/ru/post/1746350/


All Articles