【发布时间】:2011-04-07 09:20:39
【问题描述】:
我正在使用 Oracle WebLogic、Netbeans 6.9.1。 我有以下几行代码:
Query query=entityManager.createNamedQuery("Items.findById").setParameter("id", Integer.parseInt((String) request.getParameter("id")));
Items it=(Items) query.getSingleResult();
他们抛出异常:
java.lang.ClassCastException: entity.Items cannot be cast to entity.Items
即使这看起来不可能,我也看到了类似的问题:here 作者尚未发布解决方案,但其中一位参与者对不同的类加载器做出了很好的假设。
同时,如果我使用 getResultList 然后在 JSP 中使用它,它可以正常工作。但我无法在 servlet 代码中进行强制转换。
如何在 weblogic 中解决这个问题?
【问题讨论】:
标签: netbeans jakarta-ee weblogic entities