Bookmark Topic Watch Topic
  • New Topic

NullPointerException in Filter in java  RSS feed

 
cummins college
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,

We have created a jar file which contains filter and interface.The implementation of this interface is present in a package in a different application.In the filter's DoFilter() method we are extracting this class name using class.ForName() method. We have defined the fully qualified class name (packageName.classname) in the application's web.xml using the filter's init-param.

We are running the above on Tomcat6. We are facing NullPointerException in the doFilter method!! We think that the filter is not able to locate this class.

Please tell us where we are going wrong....

Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Surely the stack trace for the exception points to a line of code causing the NPE.

My crystal ball is in the shop for the 10000 vision checkup so I can't see that line of code.
 
Devaka Cooray
Marshal
Posts: 5516
687
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
"cummins college", please check your private messages regarding an important administrative matter.
 
cummins college
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

Actually we want to know how we can make a class visible at runtime. Basically,we have passed this class name(fully qualified class name) in web.xml file of our web application that resides on tomcat 6 and we want to extract this class name in DoFilter() method in a class implementing the Filter. This filter is in a different package in a Jar file. We are placing this jar file in Lib dir of tomcat6 and class is present in the application.

We have even made all packages and classes within packages public.However,filter is not able to locate this class.

Please help us.

Thanks
 
Devaka Cooray
Marshal
Posts: 5516
687
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
"cummins college", please understand that it is mandatory to follow the instructions of the private message which I sent to you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
The implementation of this interface is present in a package in a different application.I

Where, precisely, is the jar file in relation to the application that is experiencing the NPE (null pointer exception)?

Tomcat has custom class loaders that isolate applications from one another.
There are places in Tomcat to put jar files that are to be shared between different applications (which is not really a good idea IMO).

Tell us more about how you've structured your application and we will be more able to help you.
Also, as William mentioned, looking at the logs to determine the exact line where the NPE is occurring will save you a lot of time.
 
cummins college
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,

We have created a web application which is deployed on tomcat 6.We have used file system as database and have coded in java.Actually when we create a file ,we write OutputStream fo1=new FileOutputStream("file1.txt",true). However,it gets created in tomcat's bin directory.So, if we try to run this application on different terminal then it does not run. beacause file is not in web application.

But we want this file to get created inside web application . we can do it by writing a full path like c://.... but we dont want that. beacause it should be generic so that any remote user can access this application. Please help us .

Regards

- Cummins
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Since you have ignored repeated requests by moderators, your account is now closed.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!