users@glassfish.java.net

Re: GF3.1 - setup for clustering + load balancing with mod_jk: NullPointerException at Web Container

From: Amy Roh <amy.roh_at_oracle.com>
Date: Mon, 20 Dec 2010 10:19:41 -0800

The instructions from the blog [1] are for glassfish v2. In v3, you
don't need to copy any jars into the lib directory.

"asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK"
is deprecated and jk enabled connectors should be created using
create-network-listener instead in v3.

asadmin create-network-listener --jkenabledtrue --target cluster1 --protocol http-listener-1 --listenerport ${AJP_PORT} jk-listener

Please follow updated instructions for v3 [2].

[1] http://blogs.sun.com/arungupta/entry/totd_67_how_to_front
[2] http://wikis.sun.com/display/GlassFish/LoadBalanceMod_jkDemo

Amy

On 12/20/10 3:21 AM, diluzio2000_at_hotmail.com wrote:
> Shreedhar Ganapathy suggested me to post my issue here, to the Web
> Container team.
> Can someone help me? Not sure whether this is a bug of GF3.1 or I
> missed some configurations steps (I used
> glassfish-3.1-b33-12_10_2010.zip)
>
> I followed instructions as per this blog:
> http://blogs.sun.com/arungupta/entry/totd_67_how_to_front (Apache and
> mod_jk have been installed and configured in a Ubuntu machine and
> worker.properties contains two ajp ports which points to instances of a
> GF server cluster in another Ubuntu machine);
> but when I deploy an app on my instances (e.g. clusterjsp), I get:
> SEVERE|glassfish3.1|javax.enterprise.system.core.com.sun.enterprise.v3.
> server|_ThreadID=16;_ThreadName=Thread-1;|Cannot start container web
> java.lang.NullPointerException at
> com.sun.enterprise.web.connector.coyote.PECoyoteConnector.configureJKPr
> operties(PECoyoteConnector.java:974)
> at
> com.sun.enterprise.web.WebContainer.createJKConnector(WebContainer.java
> :937)
> at
> com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:551
> )
> ...
> And it looks like ajp ports are not exposed at all.
>
> I had a look on the WebContainer source code; It looks like "listener"
> is null @PECoyoteConnector.java:974:
> File propertiesFile = new File(listener.getJkConfigurationFile());
>
> This is what happened, I guess:
> @ WebContainer.java
> public void postConstruct() {
> ...
> // Configure HTTP listeners
> NetworkListeners networkListeners =
> networkConfig.getNetworkListeners();
> if (networkListeners != null) {
> List<NetworkListener> listeners =
> networkListeners.getNetworkListener();
> for (NetworkListener listener : listeners) {
> if
> (ConfigBeansUtilities.toBoolean(listener.getJkEnabled())) {
> createJKConnector(listener, httpService);
> } else {
> createHttpListener(listener, httpService);
> }
> }
> }
> createJKConnector(null, httpService);
> ...
> }
>
> I think only the second "createJKConnector" is called, passing "null"
> as first attribute (listener), therefore:
>
> protected WebConnector createJKConnector(NetworkListener listener,
> HttpService httpService) {
>
> int port = 8009;
> boolean isSecure = false;
> String address = null;
>
> if (listener == null) {
> String portString =
>
> System.getProperty("com.sun.enterprise.web.connector.enableJK");
> if (portString == null) {
> // do not create JK Connector if property is not set
> return null;
> } else {
> try {
> port = Integer.parseInt(portString);
> } catch (NumberFormatException ex) {
> // use default port 8009
> port = 8009;
> }
> }
> } else {
> port = Integer.parseInt(listener.getPort());
> isSecure =
> Boolean.valueOf(listener.findHttpProtocol().getSecurityEnabled());
> address = listener.getAddress();
> }
>
> if (isSecure&& defaultRedirectPort == -1) {
> defaultRedirectPort = port;
> }
>
> if ("any".equals(address) || "ANY".equals(address)
> || "INADDR_ANY".equals(address)) {
> address = null;
> /*
> * Setting 'address' to NULL will cause Tomcat to pass a
> * NULL InetAddress argument to the java.net.ServerSocket
> * constructor, meaning that the server socket will accept
> * connections on any/all local addresses.
> */
> }
>
> jkConnector = (WebConnector) _embedded.createConnector(address,
> port, "ajp");
> jkConnector.configureJKProperties(listener);
> ...
> ...
> }
> When jkConnector.configureJKProperties is called, "listener" is still
> null.
> This creates an NullPointerException in the "configureJKProperties"
> method (in PECoyoteConnector.java)
>
> Besides of setting GF as suggested in the Arun Gupta's blog,
> asadmin create-jvm-options --target diluzio
> "-DjvmRoute=\${AJP_INSTANCE_NAME}"
> asadmin create-jvm-options --target diluzio
> "-Dcom.sun.enterprise.web.connector.enableJK=\${AJP_PORT}"
> asadmin create-system-properties --target mila
> AJP_INSTANCE_NAME=mila
> asadmin create-system-properties --target mila AJP_PORT=8012
> asadmin create-system-properties --target luca
> AJP_INSTANCE_NAME=luca
> asadmin create-system-properties --target luca AJP_PORT=8013
> I also created a glassfish-jk.properties file as suggested in another
> blog
> (http://weblogs.java.net/blog/amyroh/archive/2006/08/glassfish_suppo.ht
> ml) and run following command:
> asadmin create-jvm-options --target diluzio
> "-Dcom.sun.enterprise.web.connector.enableJK.propertyFile=/root/tools/g
> lassfish3/glassfish/nodes/localhost-domain1/mila/config/glassfish-jk.pr
> operties"
> but that didn't help at all.
>
> Commands like this are not working:
> ./asadmin set --host localhost
> configs.config.server-config.network-config.network-listeners.network-l
> istener.jk-connector.jk-enabled=true
> because configs.config.server-config.network-... does not exist
>
> and I don't even know whether I can apply commands like this one:
> asadmin create-http-listener --listenerport 8012 --listeneraddress
> 0.0.0.0 --defaultvs server jk-connector
> because I have more than one ajp ports in my cluster