Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?

ssmtpmailtesting ssmtpmailtesting
http://localhost:8080/struts2_maven/User/Login.action

HTTP Status 404 - Not Found

type Status report

messageNot Found

descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.0

tree .
.
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── mkyong
│   │   │           └── user
│   │   │               └── action
│   │   │                   └── WelcomeUserAction.java
│   │   ├── resources
│   │   │   ├── struts.xml
│   │   │   └── struts.xml~
│   │   └── webapp
│   │       ├── index.jsp
│   │       ├── struts2-core-2.5.10.1.jar
│   │       ├── User
│   │       │   └── pages
│   │       │       ├── login.jsp
│   │       │       └── welcome_user.jsp
│   │       └── WEB-INF
│   │           ├── lib
│   │           ├── struts2-core-2.5.10.1.jar
│   │           └── web.xml
│   └── test
│       └── java
└── target
    ├── classes
    │   ├── com
    │   │   └── mkyong
    │   │       └── user
    │   │           └── action
    │   │               └── WelcomeUserAction.class
    │   └── struts.xml
    ├── m2e-wtp
    │   └── web-resources
    │       └── META-INF
    │           ├── MANIFEST.MF
    │           └── maven
    │               └── com.training
    │                   └── struts2_maven
    │                       ├── pom.properties
    │                       └── pom.xml
    ├── maven-archiver
    │   └── pom.properties
    ├── maven-status
    │   └── maven-compiler-plugin
    │       ├── compile
    │       │   └── default-compile
    │       │       ├── createdFiles.lst
    │       │       └── inputFiles.lst
    │       └── testCompile
    │           └── default-testCompile
    │               └── inputFiles.lst
    ├── struts2_maven
    │   ├── index.jsp
    │   ├── login.jsp
    │   ├── META-INF
    │   ├── struts2-core-2.5.10.1.jar
    │   ├── User
    │   │   └── pages
    │   │       ├── login.jsp
    │   │       └── welcome_user.jsp
    │   ├── WEB-INF
    │   │   ├── classes
    │   │   │   ├── com
    │   │   │   │   └── mkyong
    │   │   │   │       └── user
    │   │   │   │           └── action
    │   │   │   │               └── WelcomeUserAction.class
    │   │   │   └── struts.xml
    │   │   ├── lib
    │   │   │   ├── commons-fileupload-1.3.2.jar
    │   │   │   ├── commons-io-2.4.jar
    │   │   │   ├── commons-lang3-3.4.jar
    │   │   │   ├── freemarker-2.3.23.jar
    │   │   │   ├── javassist-3.20.0-GA.jar
    │   │   │   ├── log4j-api-2.7.jar
    │   │   │   ├── ognl-3.1.12.jar
    │   │   │   ├── servlet-api-2.5.jar
    │   │   │   └── struts2-core-2.5.10.1.jar
    │   │   ├── struts2-core-2.5.10.1.jar
    │   │   └── web.xml
    │   └── welcome_user.jsp
    ├── struts2_maven.war
    └── test-classes

46 directories, 39 files


Followed this: https://www.mkyong.com/struts2/struts-2-hello-world-example/

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <package name="user" namespace="/User" extends="struts-default">
        <action name="Login">
            <result>pages/login.jsp</result>
        </action>
        <action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
            <result name="SUCCESS">pages/welcome_user.jsp</result>
        </action>
    </package>

</struts>

web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Struts 2 Web Application</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
                </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.training</groupId>
  <artifactId>struts2_maven</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>struts2_maven Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.5.10.1</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>struts2_maven</finalName>
    <plugins>
        <plugin>
              <groupId>org.eclipse.jetty</groupId>
              <artifactId>jetty-maven-plugin</artifactId>
              <version>9.4.6</version>
          </plugin>
    </plugins>
  </build>
</project>

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry exported="true" kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="org.eclipse.jst.component.dependency"
value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="target/classes" path="src/main/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/classes"
path="src/main/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="target/test-classes"
path="src/test/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="target/classes"/>
</classpath>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?

Lukasz Lenart
You are mixing two different version of Struts - 2.3.x and 2.5.x - you
must stick with one. See my comments below

2017-06-18 4:06 GMT+02:00 ssmtpmailtesting ssmtpmailtesting
<[hidden email]>:

> http://localhost:8080/struts2_maven/User/Login.action
>
> HTTP Status 404 - Not Found
>
> type Status report
>
> messageNot Found
>
> descriptionThe requested resource is not available.
> GlassFish Server Open Source Edition 4.0
>
> tree .
> .
> ├── pom.xml
> ├── src
> │   ├── main
> │   │   ├── java
> │   │   │   └── com
> │   │   │       └── mkyong
> │   │   │           └── user
> │   │   │               └── action
> │   │   │                   └── WelcomeUserAction.java
> │   │   ├── resources
> │   │   │   ├── struts.xml
> │   │   │   └── struts.xml~
> │   │   └── webapp
> │   │       ├── index.jsp
> │   │       ├── struts2-core-2.5.10.1.jar

This JAR shouldn't be here, remove it

> │   │       ├── User
> │   │       │   └── pages
> │   │       │       ├── login.jsp
> │   │       │       └── welcome_user.jsp

You should move all the JSP files under WEB-INF to increase security
-> http://struts.apache.org/security/#never-expose-jsp-files-directly

> │   │       └── WEB-INF
> │   │           ├── lib
> │   │           ├── struts2-core-2.5.10.1.jar

This JAR shouldn't be here, remove it

> │   │           └── web.xml
> │   └── test
> │       └── java

> struts.xml
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
> "http://struts.apache.org/dtds/struts-2.0.dtd">

You are using an outdated DTD, please use version 2.5 (when using
Struts 2.5.10.1) or 2.3 (when using Struts 2.3.32)

> <struts>
>
>     <package name="user" namespace="/User" extends="struts-default">
>         <action name="Login">
>             <result>pages/login.jsp</result>

There is no such file, see your file structure, there is "User/pages/login.jsp"

>         </action>
>         <action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
>             <result name="SUCCESS">pages/welcome_user.jsp</result>

The same here, also result name is "success" not "SUCCESS"  and you
can omit it if this is the only result type defined - "success" is by
default.

>         </action>
>     </package>
>
> </struts>
>
> web.xml
>
> <!DOCTYPE web-app PUBLIC
>  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>  "http://java.sun.com/dtd/web-app_2_3.dtd" >

Not matching DTD, you are using 2.3 but declared 2.5 version of the
Servlet API in the pom - should be the same.

> <web-app>
>     <display-name>Struts 2 Web Application</display-name>
>
>     <filter>
>         <filter-name>struts2</filter-name>
>         <filter-class>
>
> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

The filter name is wrong, it has changed starting with Struts 2.5
https://struts.apache.org/docs/struts-23-to-25-migration.html#Struts2.3to2.5migration-StrutsPrepareAndExecuteFilter

And finally you should based on out Getting Started Guide which we try
to keep up to date with the latest Struts version
http://struts.apache.org/getting-started/


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?

ssmtpmailtesting ssmtpmailtesting
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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.training</groupId>
  <artifactId>struts2_maven</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>struts2_maven Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.5.10.1</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.0-b01</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>struts2_maven</finalName>
  </build>
</project>


In web.xml web-app_2_5.dtd and  Web Application 2.3 don't work. It
gets error: "Referenced file contains errors
(http://java.sun.com/dtd/web-app_2_5.dtd). For more information, right
click on the message in the Problems View
 and select "Show Details..."

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.5//EN"
"http://java.sun.com/dtd/web-app_2_5.dtd">

<web-app>
    <display-name>Struts 2 Web Application</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

2.3 and _2_3 works in web.xml

On Sun, Jun 18, 2017 at 2:11 PM, Lukasz Lenart <[hidden email]> wrote:

> You are mixing two different version of Struts - 2.3.x and 2.5.x - you
> must stick with one. See my comments below
>
> 2017-06-18 4:06 GMT+02:00 ssmtpmailtesting ssmtpmailtesting
> <[hidden email]>:
>> http://localhost:8080/struts2_maven/User/Login.action
>>
>> HTTP Status 404 - Not Found
>>
>> type Status report
>>
>> messageNot Found
>>
>> descriptionThe requested resource is not available.
>> GlassFish Server Open Source Edition 4.0
>>
>> tree .
>> .
>> ├── pom.xml
>> ├── src
>> │   ├── main
>> │   │   ├── java
>> │   │   │   └── com
>> │   │   │       └── mkyong
>> │   │   │           └── user
>> │   │   │               └── action
>> │   │   │                   └── WelcomeUserAction.java
>> │   │   ├── resources
>> │   │   │   ├── struts.xml
>> │   │   │   └── struts.xml~
>> │   │   └── webapp
>> │   │       ├── index.jsp
>> │   │       ├── struts2-core-2.5.10.1.jar
>
> This JAR shouldn't be here, remove it
>
>> │   │       ├── User
>> │   │       │   └── pages
>> │   │       │       ├── login.jsp
>> │   │       │       └── welcome_user.jsp
>
> You should move all the JSP files under WEB-INF to increase security
> -> http://struts.apache.org/security/#never-expose-jsp-files-directly
>
>> │   │       └── WEB-INF
>> │   │           ├── lib
>> │   │           ├── struts2-core-2.5.10.1.jar
>
> This JAR shouldn't be here, remove it
>
>> │   │           └── web.xml
>> │   └── test
>> │       └── java
>
>> struts.xml
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE struts PUBLIC
>> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>> "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> You are using an outdated DTD, please use version 2.5 (when using
> Struts 2.5.10.1) or 2.3 (when using Struts 2.3.32)
>
>> <struts>
>>
>>     <package name="user" namespace="/User" extends="struts-default">
>>         <action name="Login">
>>             <result>pages/login.jsp</result>
>
> There is no such file, see your file structure, there is "User/pages/login.jsp"
>
>>         </action>
>>         <action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
>>             <result name="SUCCESS">pages/welcome_user.jsp</result>
>
> The same here, also result name is "success" not "SUCCESS"  and you
> can omit it if this is the only result type defined - "success" is by
> default.
>
>>         </action>
>>     </package>
>>
>> </struts>
>>
>> web.xml
>>
>> <!DOCTYPE web-app PUBLIC
>>  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>>  "http://java.sun.com/dtd/web-app_2_3.dtd" >
>
> Not matching DTD, you are using 2.3 but declared 2.5 version of the
> Servlet API in the pom - should be the same.
>
>> <web-app>
>>     <display-name>Struts 2 Web Application</display-name>
>>
>>     <filter>
>>         <filter-name>struts2</filter-name>
>>         <filter-class>
>>
>> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
>
> The filter name is wrong, it has changed starting with Struts 2.5
> https://struts.apache.org/docs/struts-23-to-25-migration.html#Struts2.3to2.5migration-StrutsPrepareAndExecuteFilter
>
> And finally you should based on out Getting Started Guide which we try
> to keep up to date with the latest Struts version
> http://struts.apache.org/getting-started/
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?

Lukasz Lenart
2017-06-24 7:21 GMT+02:00 ssmtpmailtesting ssmtpmailtesting
<[hidden email]>:

> 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/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.training</groupId>
>   <artifactId>struts2_maven</artifactId>
>   <packaging>war</packaging>
>   <version>0.0.1-SNAPSHOT</version>
>   <name>struts2_maven Maven Webapp</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>       <groupId>org.apache.struts</groupId>
>       <artifactId>struts2-core</artifactId>
>       <version>2.5.10.1</version>
>     </dependency>
>     <dependency>
>       <groupId>javax.servlet</groupId>
>       <artifactId>javax.servlet-api</artifactId>
>       <version>4.0.0-b01</version>

I would rather use a stable version

> In web.xml web-app_2_5.dtd and  Web Application 2.3 don't work. It
> gets error: "Referenced file contains errors
> (http://java.sun.com/dtd/web-app_2_5.dtd). For more information, right
> click on the message in the Problems View
>  and select "Show Details..."
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE web-app PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.5//EN"
> "http://java.sun.com/dtd/web-app_2_5.dtd">

You are using wrong definition, please check this out
http://wiki.metawerx.net/wiki/Web.xmlDTDAndXSD


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...