NullPointerException at com.hazelcast.web.WebFilter.getAppContext(WebFilter.java:1212)

145 views
Skip to first unread message

Frankee787

unread,
Mar 14, 2010, 5:26:19 PM3/14/10
to Hazelcast
Dear Buddy,
I am trying to cluster a webapp on Tomcat with Hazelcast. However I
keep getting a null pointer exception. I am just using a simple
Servlet which is given below. Can someone please help.


SEVERE: Exception sending context destroyed event to listener instance
of class com.hazelcast.web.WebFilter$ContextListener
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:
157)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:
730)
at com.hazelcast.web.WebFilter.getAppContext(WebFilter.java:1212)
at com.hazelcast.web.WebFilter.getAppContext(WebFilter.java:1269)
at com.hazelcast.web.WebFilter.access$000(WebFilter.java:40)
at com.hazelcast.web.WebFilter
$ContextListener.contextDestroyed(WebFilter.java:72)
at
org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:
3836)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:
4366)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4282)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
740)


Below is the servlet
---------------------------
package com.datel.app;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PageServlet extends HttpServlet {


protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();


// Print the HTML header
out.println("<HTML><HEAD><TITLE>");
out.println("Request info");
out.println("</TITLE></HEAD>");

// Print the HTML body
out.println("<BODY><H1>Request info</H1><PRE>");
out.println("getCharacterEncoding: " +
request.getCharacterEncoding());
out.println("getContentLength: " + request.getContentLength());
out.println("getContentType: " + request.getContentType());

out.println("Getting Session VALUE: " +
request.getSession().getAttribute("VALUE"));

out.println("Setting Session VALUE");
request.getSession().setAttribute("VALUE", "FRANKLIN");
out.println("Getting Session VALUE: " +
request.getSession().getAttribute("VALUE"));


}


}

Jaryl

unread,
Mar 16, 2010, 3:44:13 AM3/16/10
to Hazelcast
I am encountering this problem as well on the latest 1.8.2 files.

I'm using NetBeans as my IDE and added all the necessary jar files to
a new web application project. After compiling into the war file (no
changes were made to the codes), I executed clusterWebapp.sh on it and
created the clustered-Project.war file.

However, I could not deploy this on Tomcat; I used the upload war file
function in the Tomcat manager.

Talip Ozturk

unread,
Mar 16, 2010, 3:48:12 AM3/16/10
to haze...@googlegroups.com
Please create an issue for this at
http://code.google.com/p/hazelcast/issues/list

1.8.3 or 1.8.4 should have it fixed.

-talip

> --
> You received this message because you are subscribed to the Google Groups "Hazelcast" group.
> To post to this group, send email to haze...@googlegroups.com.
> To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.
>
>

Franklin Antony

unread,
Mar 16, 2010, 3:49:56 AM3/16/10
to haze...@googlegroups.com
Dear Jaryl,
   Me too...The hack I did to fix it was as follows
 
1)Make the Cluster-App.war file from your Source-App.war file.
2)Open up the web.xml file inside the Cluster-App.war file.
3)Comment/Remove out the entry which has something like this

<listener>

<listener-class>com.hazelcast.web.WebFilter$ContextListener</listener-class>

</listener>

4)Deploy now and try.
 
 
This worked for me.
 
Regards,
Franklin

Jaryl

unread,
Mar 16, 2010, 7:17:26 AM3/16/10
to Hazelcast
I removed those lines but I get a slightly different error:

SEVERE: Exception starting filter hazel-filter
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:
768)


I believe that this is something internal to Hazelcast and I will be
creating a ticket for it.

> > hazelcast+...@googlegroups.com<hazelcast%2Bunsu...@googlegroups.com>

Talip Ozturk

unread,
Mar 16, 2010, 7:33:43 AM3/16/10
to haze...@googlegroups.com
> I believe that this is something internal to Hazelcast and I will be
> creating a ticket for it.

Great!

Thanks,
-talip

Franklin Antony

unread,
Mar 16, 2010, 8:11:47 AM3/16/10
to haze...@googlegroups.com, ja...@tinkerbox.com.sg
Can you just post your web.xml file that is inside the clustered war file.  I am sure it should work.

PS: This was the exact same error I was getting.
PPS: I placed the war file in the deploy folder

Got it working after removing just the listener class entry


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>hazel-filter</
filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<init-param>
<param-name>listener-count</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>apps-sharing-sessions</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hazel-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

/* REMOVE THIS

<listener>
<listener-class>com.hazelcast.
web.WebFilter$ContextListener</listener-class>
</listener>



*/
   
    <servlet>
        <servlet-name>HelloWorld</servlet-name>
        <servlet-class>com.hazelcast.web.ServletWrapper</servlet-class>
    <init-param>
<param-name>*hazelcast-base-servlet-class</param-name>
<param-value>com.datel.hazelcastel.main.HelloWorld</param-value>
</init-param>
</servlet>
   
    <servlet-mapping>
        <servlet-name>HelloWorld</servlet-name>
        <url-pattern>/HelloWorld</url-pattern>
    </servlet-mapping>
</web-app>




Regards,
Franklin

To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages