Tag Archives: exception

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter when starting Simple Struts2 Application

Questions: I am trying to run a simple Struts2 application but it always throw the following exception: java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter I have followed the step by step tutorial in http://struts.apache.org/development/2.x/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html but I cannot make it work. I also managed to find other Struts2 tutorial which uses maven but all failed. It throws the same exception when… Read More »

Getting class cast exception where both classes are exactly the same

Questions: I am doing a JBoss SEAM project and when I view a form I get this error. java.lang.ClassCastException: it.cogitoweb.csi.entity.csiorelav.CsiTipoLav cannot be cast to it.cogitoweb.csi.entity.csiorelav.CsiTipoLav Its alway the same JPA class which is related to the form which is shown on the screen, it doesn’t make sense to me why is it the same class,… Read More »

Java unreported exception

Questions: While learning Java I stumble upon this error quite often. It goes like this: Unreported exception java.io.FileNotFound exception; must be caught or declared to be thrown. java.io.FileNotFound is just an example, I’ve seen many different ones. In this particular case, code causing the error is: OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(“myfile.pdf”))); Error always… Read More »

Solve error javax.mail.AuthenticationFailedException

Questions: I’m not familiar with this function to send mail in java. I’m getting an error while sending email to reset password. Hope you can give me a solution. Below is my code: public synchronized static boolean sendMailAdvance(String emailTo, String subject, String body) { String host = AppConfigManager.getProperty(“SENDER-EMAIL-SMTP-ADDRESS”); String userName = AppConfigManager.getProperty(“SENDER-EMAIL-SMTP-USERNAME”); String password =… Read More »

Why did Servlet.service() for servlet jsp throw this exception?

Questions: I get the following error, what could be the problem? My context descriptor: <?xml version=”1.0″ encoding=”UTF-8″?> <web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” id=”WebApp_ID” version=”2.5″> <servlet> <servlet-name>UploadServlet</servlet-name> <servlet-class>controller.UploadServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>UploadServlet</servlet-name> <url-pattern>/UploadServlet</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52) at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)… Read More »

Mockito: InvalidUseOfMatchersException

Questions: I have a command line tool that performs a DNS check. If the DNS check succeeds, the command proceeds with further tasks. I am trying to write unit tests for this using Mockito. Here’s my code: public class Command() { // …. void runCommand() { // .. dnsCheck(hostname, new InetAddressFactory()); // .. // do… Read More »