Struts no action mapped issue - eclipse

When deploying a struts application to tomcat running in eclipse I'm getting the following error to the console when trying to load the welcome page.
"There is no Action mapped for namespace / and action name . - [unknown location]"
I was trying to follow the tutorial at: http://viralpatel.net/blogs/2009/12/tutorial-create-struts-2-application-eclipse-example.html.
I am obviously just getting started with struts and any help would be appreciated.

Make sure to have the URL-Pattern mapped to Struts in your web.xml file.
<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>*.html</url-pattern>
</filter-mapping>
Make sure you have the action name then mapped to a Java class in your struts.xml.
<action name="find" class="findAction" method="input">
<interceptor-ref name="myStack" />
<result name="input">find</result>
</action>
These are the essentials. The result will then need mapped to a JSP. Good Luck.

Related

Are groovy filters executed the same order as declared in site.xml in Crafter CMS?

Are groovy filters executed the same order as declared in site.xml in Crafter CMS?
For example, will filter1 always be executed before filter2?
<filter>
<script>/scripts/filters/filter1.groovy</script>
<mapping>
<include>/**</include>
<exclude></exclude>
</mapping>
</filter>
<filter>
<script>/scripts/filters/filter2.groovy</script>
<mapping>
<include>/**</include>
<exclude></exclude>
</mapping>
</filter>
I'm using Crafter 2.5
Yes, they should be exec in the same order as define

Why WildFly ignores filters defined in web.xml?

I have an application running on WildFly-10.1.0.Final. I deployed it correctly, but some entries of my web.xml are ignored.
This is a part of my web.xml:
<filter>
<filter-name>ExtProjectFilter</filter-name>
<filter-class>com.raylloy.filter.ExtProjectFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ExtProjectFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
When I use a jboss-5.1.0.GA this works fine, a new instance of my filter is created. But on wildfly-10.1.0.Final, my filter is ignored.
Is there a way to fix it? Is there something I need to add in standalone.xml?
Thanks in advance!

Struts 2 Hello World

I have a problem at this example
I work with eclipse for Java EE and Apache Tomcat 8.
My project structure:
The web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>Hello World Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>
The other files code is the same as the struts website.
When I run the index.jsp file I get the following error:
**HTTP Status 404 - /helloworld/index.jsp
type Status report
message /helloworld/index.jsp
description The requested resource is not available.**
Can someone spot the reason why can't I run it?
First of all the project is created by using Maven configuration, and to access the Struts action you should use url
Step 6 - Build the WAR File and Run The Application
Execute mvn clean package to create the war file.
Copy the war file to your Servlet container. After your Servlet
container successfully deploys the war file go to this URL
http://localhost:8080/helloworld/index.action where you should see
the following:
(source: apache.org)
Web application context is where the application was deployed. In the docs url it's /helloworld, on the image it's /Hello_World_Struts2_Ant. Use it as a part of the url. It doesn't matter which app context did you use during deployment but url depends on it. If you want to change the web app context you should read Java - How to change context root of a dynamic web project in Eclipse. After the context you use action name with .action extension to execute action.
Don't use URLs like localhost:8080/helloworld/index.jsp because you might not get the resource because it's already handled by the web server.

How to use swagger-ui with service deployed in tomcat running on eclipse

I have a REST api running at http://localhost:8080/MyService and can see the JSON produced by swagger at http://localhost:8080/MyService/api-docs. In the Servers project in eclipse I have modified web.xml to include the Cors filter:
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
but when I point swagger-ui (loaded in browser from file system) at http://localhost:8080/MyService/api-docs, I get the following error:
Can't read from server. It may not have the appropriate
access-control-origin settings.
Adding the Swagger dist directly to the webapps folder did the trick

implementing authentication using oauth 2.0 and wicket

I try to bring up secure communication with our customer using oauth 2.0.
first of all I have to confess that I am totally new to oauth.
Used technologies are as follow: wicket, spring,
I took the following steps.
Add dependency in pom.xml
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0.M3</version>
</dependency>
Then I added the following in WEB-INF/web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Finally I added these lines to META-INF/spring-context/application.xml
<beans:bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.InMemoryOAuth2ProviderTokenServices">
<beans:property name="supportRefreshToken" value="true" />
</beans:bean>
<oauth:provider client-details-service-ref="clientDetails" token-services-ref="tokenServices">
<oauth:verification-code user-approval-page="/oauth/confirm_access" />
</oauth:provider>
<oauth:client-details-service id="clientDetails">
<oauth:client clientId="foo" authorizedGrantTypes="authorization_code" />
</oauth:client-details-service>
But I got this error:
25 09 12 14:48:11:921:ERROR: [ContextLoader] Context initialization failed
java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getDeclaredConstructor(Class.java:2002)
...
I think you need the spring-core in your maven dependencies. Specifically version 3.1 or upwards.
It is usually like this that when we add a dependency, It contains necessary dependencies itself. Isn't it?
Cause I got so Error and I add till now many dependency but still face some new ones?
Is that logical ... to add dependency till I can run the project.
I have still no code inside ... just try to add OAUTH dependency!