| Author |
Unreachable catch block for ClassNotFoundException
|
Prathik Ashok
Greenhorn
Joined: Mar 27, 2012
Posts: 12
|
|
Hello everyone can some one help me out here i am trying to develop this servlet for my jsp and when i try to deploy it using tomcat i get this error saying "Unreachable catch block for ClassNotFoundException. This exception is never thrown from the try statement body"
can some one help me figure this out or tell me what i am doing wrong ???
this is my code down below and the problem is at line 88
I am using Struts
basically what i have done is created an action class and a DAO which inserts the data into the tables I could fill up the data fields without the servlet but once i created the servlet i get that error
Regards
Prathik
this is my web.xml file
And this is what i get when i try to deploy it
SEVERE: Servlet.service() for servlet [candrep] in context with path [/project] threw exception [Servlet execution threw an exception] with root cause
java.lang.Error: Unresolved compilation problem:
Unreachable catch block for ClassNotFoundException. This exception is never thrown from the try statement body
|
 |
Neeraj Dhiman
Ranch Hand
Joined: Dec 19, 2011
Posts: 63
|
|
|
check curly braces in servlet.!!
|
Correct Me if i am wrong
|
 |
Prathik Ashok
Greenhorn
Joined: Mar 27, 2012
Posts: 12
|
|
Neeraj Dhiman wrote:check curly braces in servlet.!!
I don't think that's the problem braces seem to be in order
|
 |
Piyush Mangal
Ranch Hand
Joined: Jan 22, 2007
Posts: 196
|
|
|
ClassNotFoundException is a checked exception and your code is not throwing it anywhere explicitly. So compiler is telling you that this code will never be executed, Please remove that try and catch block as it is not required.
|
 |
Prathik Ashok
Greenhorn
Joined: Mar 27, 2012
Posts: 12
|
|
Piyush Mangal wrote:ClassNotFoundException is a checked exception and your code is not throwing it anywhere explicitly. So compiler is telling you that this code will never be executed, Please remove that try and catch block as it is not required.
i removed the try and catch block but this is what i get when i try to deploy
Your FirstName is :null
Your Last Name is :null Your Contact Number is :null Your Contact Number is :null Your Contact Number is :null Your Email is :null Your Current Industry :null Your Current Industry :null Your Preferred Industry is :null Your Current Industry :null
and further more it inserts the querry into the database table
Insert Query formed: INSERT INTO candreppage4.posts(FirstName,LastName,Gender,Qualification,Email,ContactNumber,Industry,WorkExperience,PreferredIndustry,EmploymentStatus) VALUES('null','null','null','null','null','null','null','null','null','null')
|
 |
Piyush Mangal
Ranch Hand
Joined: Jan 22, 2007
Posts: 196
|
|
|
What does that have to do with try and catch block?
|
 |
Prathik Ashok
Greenhorn
Joined: Mar 27, 2012
Posts: 12
|
|
Piyush Mangal wrote:What does that have to do with try and catch block?
well when i deploy it does not show me the required jsp and after i removed the try and catch block that's the result i got and it inserted a querry into the table
|
 |
Piyush Mangal
Ranch Hand
Joined: Jan 22, 2007
Posts: 196
|
|
well when i deploy it does not show me the required jsp and after i removed the try and catch block that's the result i got and it inserted a querry into the table
And why do you think it should show you a required jsp? Where are you forwarding to a JSP page in your servlet? Where are you checking for null values in your servlet?
|
 |
 |
|
|
subject: Unreachable catch block for ClassNotFoundException
|
|
|