This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I built a webapp that uses JNDI to lookup JavaMail. I was getting ClassCastExceptions trying to retreive a mail Session from JNDI, which turned out to be because NetBeans bundled mail.war in the WAR lib/ (which causes classloader issues when getting a Session that was configured up in Tomcat itself). Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); Object o = envCtx.lookup("mail/Session"); // the debugger verifies that 'o' holds a javamail Session, but // but the next line raises a ClassCastException sendMailSession = (Session) o; My workaround currently is to edit nbproject/build.xml and remove the <copyfiles> element from the 'library-inclusion-in-archive' target. I couldn't find a knob in the GUI to enable this behaviour, so each time I change project properties I have to re-edit the file. I may well be doing something wrong, but it'd be good to be able to have this enabled in the UI as an option.
My bad, just found the 'Package' checkbox next to the JAR in project properties.