Dev Anand Sadasivam
Dev Anand Sadasivam

Reputation: 753

Failed to determine servlet: java.lang.NullPointerException at org.jboss.as.web.deployment.JBossContextConfig.beforeLoadOnStartup

I'm migrating a WebSphere application to JBoss EAP 6.4. During deployment, I get the below error:

Failed to determine servlet: java.lang.NullPointerException

With this stack trace:

12:48:06,194 DEBUG [org.jboss.as.security] (MSC service thread 1-2) Qualified url patterns: {/=PatternInfo[pattern=/,type=3,isOverridden=false,qualifiers=[]]}
12:48:06,194 FINE  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 132) ConfigureListener.contextInitialized(/scWeb)
12:48:06,224 DEBUG [org.jboss.as.web.security] (ServerService Thread Pool -- 96) Failed to determine servlet: java.lang.NullPointerException
    at org.jboss.as.web.deployment.JBossContextConfig.beforeLoadOnStartup(JBossContextConfig.java:666) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:178) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
    at org.jboss.as.web.deployment.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:260) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3592) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.8.0_45]
    at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_45]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_45]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

12:48:43,934 DEBUG [org.jboss.ejb.client.txn] (Periodic Recovery) Send recover request for transaction origin node identifier 1 to EJB receiver with node name inbaghpc00516
12:52:40,593 ERROR [org.jboss.as.controller.management-operation] (HttpManagementService-threads - 1) JBAS013412: Timeout after [300] seconds waiting for service container stability. Operation will roll back. Step that first updated the service container was 'deploy' at address '[("deployment" => "PCB-5.3.ear")]'

How is this caused and how can I solve it?

Here is my configurations for scweb....

web.xml....

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_1234567890" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Shortcode Management Web</display-name>
    <distributable />

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-*.xml</param-value>
    </context-param>

    <filter>
        <filter-name>authenticationFilter</filter-name>
        <filter-class>
            com.singtel.pcb.scweb.filter.AuthenticationFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>authenticationFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener> 

    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>
            org.apache.struts.action.ActionServlet
        </servlet-class>        
        <init-param>
            <param-name>config</param-name>
            <param-value>
                /WEB-INF/struts-config.xml
            </param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

        <!-- Struts Action Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

<!--    
    <resource-ref id="ResourceRef_12345678909">
        <res-ref-name>jdbc/pcbDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
 -->    
    <error-page>
        <error-code>404</error-code>
        <location>/404.html</location>
    </error-page>
</web-app>

struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>

    <!-- Form Beans -->

    <form-beans>
        <form-bean name="LoginForm"  type="com.singtel.pcb.scweb.forms.LoginActionFormBean" />
        <!--many like this-->
        </form-beans>

    <global-forwards>
        <!-- Default forward to "Welcome" action -->
        <!-- Demonstrates using index.jsp to forward -->
        <forward name="failure" path="/Error.jsp" />
        <forward name="response" path="/Response.jsp" />
        <forward name="Error" path="/Error.jsp" />
    </global-forwards>    

    <action-mappings>
        <action 
            name="LoginForm"
            attribute="LoginForm"
            type="com.singtel.pcb.scweb.action.LoginAction"
            path="/pages/login" 
            input="/pages/login.jsp"
            scope="request" 
            validate="true">
                <forward name="ShortcodeHome" path="/pages/lumlum.jsp" />
                <forward name="NumberLevelHome" path="/pages/sumnum.jsp" />
                <forward name="Failure" path="/pages/login.jsp" />
        </action>
        <!--many like this-->
    </action-mappings>

    <controller locale="false" maxFileSize="500K" nocache="true" processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />                  

    <message-resources parameter="com.singtel.pcb.scweb.resource.ApplicationResources"/>

    <plug-in
        className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation"
            value="/WEB-INF/actions-*.xml" />
    </plug-in>

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
    </plug-in>

</struts-config>

applicationContext-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

    <bean id="userRoleService" class="com.singtel.pcb.sam.dto.UserRoleService">
        <property name="dataSource" ref="dataSource"></property>
    </bean>

    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>
                    classpath:com/singtel/pcb/scweb/resource/scweb.properties
                </value>
            </list>
        </property>
    </bean>

    <bean id="dataSource" 
        class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
        <value>${database.connection.datasource}</value>
        </property>
    </bean>

</beans>

Upvotes: 1

Views: 2564

Answers (1)

Dev Anand Sadasivam
Dev Anand Sadasivam

Reputation: 753

Failed to determine servlet: Problem is not coming if the environment set properly for web.xml.

In the given scenario datasource which is required for the web container (.war) web archive is not supplied. Meaning it is commented by unawareness because of that intialContext.lookup() fails which was called from Filter classes which is basically configured as Filter (AuthFilter.java) in web.xml

So un-commenting the following lines solves problem, which can initiate web life cycle, so Failed to determine servlet problem solved....

<resource-ref id="ResourceRef_12345678909">
    <res-ref-name>jdbc/pcbDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Other than that look for this error, it might also initiate the same error which we are discussing here for web container

Caused by: java.sql.SQLException: ORA-28001: the password has expired

It means your database password which was set is expired. Go and reset the password. In my case it is Oracle. Password is explicitly mentioned in my JBoss Server Config,- stanalone.xml. So I had logged in and reset it in SQL Plus Command Line Utility.

While you do this also make sure you're removing JBoss tmp foler cached data, as because web container is been cached and has the password stored as a state somewhere within a container.

Upvotes: 1

Related Questions