Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nullpointer while using response.sendRedirect()

I am porting this application from weblogic to Jboss with maven and I am facing this message now on the second page. Any idea of what I could be missing?

It doesn't work with any JSP that I create or in any controller that I call it. I tried to create an instance of the PrintWriter and it outputs the String. The problem is with compiling any jsp through this function. Also, the index.jsp works fine.

Stacktrace in server.log:

ESC[0mESC[31m09:51:38,753 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cashvariance].[jsp]] (http-/0.0.0.0:8180-1) JBWEB
000236: Servlet.service() for servlet jsp threw exception: java.lang.NullPointerException
        at java.io.Writer.write(Writer.java:157) [rt.jar:1.8.0_101]
        at java.io.PrintWriter.newLine(PrintWriter.java:480) [rt.jar:1.8.0_101]
        at java.io.PrintWriter.println(PrintWriter.java:629) [rt.jar:1.8.0_101]
        at java.io.PrintWriter.println(PrintWriter.java:740) [rt.jar:1.8.0_101]
        at org.apache.jasper.compiler.ServletWriter.printil(ServletWriter.java:130) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Generator.genPreamblePackage(Generator.java:481) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Generator.generatePreamble(Generator.java:584) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Generator.generate(Generator.java:3462) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:359) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:339) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:326) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_101]

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>cashvariance</groupId>
    <artifactId>cashvariance</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <resources>
            <resource>
                <directory>WebContent</directory>
            </resource>
        </resources>
        <finalName>cashvariance</finalName>
        <sourceDirectory>src</sourceDirectory>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.unboundid/unboundid-ldapsdk -->
        <dependency>
            <groupId>com.unboundid</groupId>
            <artifactId>unboundid-ldapsdk</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-spec -->
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>jasper</artifactId>
            <version>6.0.32</version>
        </dependency>
    </dependencies>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>cashvariance</display-name>

  <servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>pageCheckSeconds</param-name>
        <param-value>-1</param-value>
    </init-param>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>keepgenerated</param-name>
        <param-value>true</param-value>
    </init-param> 
    <load-on-startup>0</load-on-startup>
  </servlet>

  <servlet>
        <servlet-name>HelloWorldServlet</servlet-name>
        <servlet-class>HelloWorldServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>CashVarianceController</servlet-name>     
        <servlet-class>cashvariance.controller.CashVarianceServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>DropDownController</servlet-name>     
        <servlet-class>cashvariance.controller.CashVarianceServletForDropDown</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>ManageRPAController</servlet-name>
        <servlet-class>cashvariance.controller.ManageRPAServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>AddRPAController</servlet-name>
        <servlet-class>cashvariance.controller.AddRPAServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>UpdateDeleteController</servlet-name>
        <servlet-class>cashvariance.controller.UpdateDeleteServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>DataDumpController</servlet-name>
        <servlet-class>cashvariance.controller.DataDumpServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>Main</servlet-name>
        <servlet-class>cashvariance.controller.LoginController</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>SnoopServlet</servlet-name>
        <servlet-class>SnoopServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>logon</servlet-name>
        <servlet-class>demo.log4j.servlet.LogonServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>ForgotPassword</servlet-name>
        <servlet-class>demo.log4j.servlet.ForgotPasswordServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>Register</servlet-name>
        <servlet-class>demo.log4j.servlet.RegisterServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>GetComments</servlet-name>
        <servlet-class>demo.log4j.servlet.GetCommentsServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>log4jsetup</servlet-name>
        <servlet-class>demo.log4j.servlet.Log4jSetupServlet</servlet-class>
        <init-param>
            <param-name>props</param-name>
            <param-value>log4j.properties</param-value>
        </init-param>
        <init-param>
            <param-name>watch</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>userDB</param-name>
            <param-value>userDB.properties</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloWorldServlet</servlet-name>
        <url-pattern>/HelloWorldServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CashVarianceController</servlet-name>
        <url-pattern>/CashVarianceController</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>DropDownController</servlet-name>
        <url-pattern>/DropDownController</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ManageRPAController</servlet-name>
        <url-pattern>/ManageRPAController</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AddRPAController</servlet-name>
        <url-pattern>/AddRPAController</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>UpdateDeleteController</servlet-name>
        <url-pattern>/UpdateDeleteController</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>DataDumpController</servlet-name>
        <url-pattern>/DataDumpController</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Main</servlet-name>
        <url-pattern>/Main</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>SnoopServlet</servlet-name>
        <url-pattern>/SnoopServlet</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>logon</servlet-name>
        <url-pattern>/log4j_demo/logon</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ForgotPassword</servlet-name>
        <url-pattern>/log4j_demo/ForgotPassword</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Register</servlet-name>
        <url-pattern>/log4j_demo/Register</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>GetComments</servlet-name>
        <url-pattern>/log4j_demo/GetComments</url-pattern>
    </servlet-mapping>


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

    <error-page>
        <error-code>404</error-code>
        <location>/jsp/error.jsp</location>
    </error-page>
<!--   <welcome-file-list> -->
<!--     <welcome-file>index.html</welcome-file> -->
<!--     <welcome-file>index.htm</welcome-file> -->
<!--     <welcome-file>index.jsp</welcome-file> -->
<!--     <welcome-file>default.html</welcome-file> -->
<!--     <welcome-file>default.htm</welcome-file> -->
<!--     <welcome-file>default.jsp</welcome-file> -->
<!--   </welcome-file-list> -->
</web-app>

Subsystem for jsp in standalone.xml

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
            <configuration>
                <jsp-configuration development="true" java-encoding="ISO8859_1"/>
            </configuration>
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem>
like image 676
davis Avatar asked Nov 07 '22 13:11

davis


1 Answers

I don't work with JBoss so i can't tell you where to fix this issue, but the StackTrace clearly indicates that the system-property line.separator isn't set or can't retrieved correctly.

From the comment of @davis

I've set the property inside the .properties file that I have and it worked!

like image 134
Edwardth Avatar answered Nov 15 '22 06:11

Edwardth