How to fix Spring Security Oauth 2.0 tonr & sparklr application error? - security

I am trying sample application "sparklr" and "tonr" packaged with Spring Security OAuth 2.0. Unfortunately, I failed to make these applications work correctly as described in the Spring Security website.
To be specific, I tried two versions of Spring Security OAuth 2.0, one is M5 , the other is the master.
For M5, a exception is thrown out when visiting "sparklr" app with the error message "No bean named 'springSecurityFilterChain' is defined". Accessing sparklr photo through "tonr" application received a blank page as well.
For the master version, the blank page is always returned for any request to both applications.
Is there anyone who has the same problem?

I have fixed the exception problem on M5 by commenting out the "oauth2EndpointUrlFilter" configuration in Sparklr app's web.xml as below.
- <!-- filter>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping
-->

Related

JSF 1.2 application not getting deployed on websphere 8.5

I am trying to deploy JSF 1.2 application on WAS 8.5 server. But it is throwing below error on deployment.
Note: In the WAS admin, Under JSF implementation use console, I have selected the "Sun Reference Implementation 1.2 " option . But still problem persist.
[12/17/14 15:12:41:222 PST] 00000095 webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextDestroyed SRVE0285E: Exception caught while destroying context: {0}
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener- class> org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:196)
at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:131)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:261)
at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:293)
at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:153)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextDestroyed(WebApp.java:1748)
You should restart the application server (not just the app). You should also make sure jsf-api.api and jsf-impl.jar are not in WEB-INF/lib of your app.

Why uploading file with tomahawk is not working?

I have an Icefaces 3.x + JSF 2.1 app where I tried to integrate upload file solution from here but I receive
14:31:24,506 WARN
[org.apache.myfaces.custom.fileupload.HtmlFileUploadRenderer]
(http-localhost-127.0.0.1-8080-3) t:inputFileUpload requires
ExtensionsFilter or TomahawkFacesContextFactory configured to handle
multipart file upload, and any of them has been detected. Please read
the instructions on
http://myfaces.apache.org/tomahawk/extensionsFilter.html for more
information about how to setup your environment correctly. Please be
sure ExtensionsFilter is the top most filter if you are using multiple
jsf libraries. 14:31:24,507 WARN
[org.apache.myfaces.custom.fileupload.HtmlFileUploadRenderer]
(http-localhost-127.0.0.1-8080-3) t:inputFileUpload requires the
current request be intercepted by the filter in order to handle forms
with multipart encode type. ExtensionsFilter was initialized but the
current request was not intercepted. Please add a filter-mapping entry
to intercept jsf page requests.
which is pretty strange because I added:
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
into my web.xml but still the uploaded file is null.
Any clue to what I do wrong?

Forwarding a request from a JSF managed bean to a Struts 2 action does not work

Within a JSF managed bean, I have the following code taken from this past question:
String uri = "/myAction";
FacesContext.getCurrentInstance().getExternalContext().dispatch(uri);
myAction is the name of a Struts action that is defined in my struts.xml.
However when I access the JSF bean, I am not forwarded to /myAction. Instead I'm getting a 404 http error: The requested resource (/MyApp/myAction) is not available.
Why doesn't it work??
When I try to access /myAction directly from a browser by going to http://localhost:8080/MyApp/myAction all works fine.
The clue is in the javadoc for the dispatchmethod:
"Parameters:
path - Context relative path to the specified resource, which must start with a slash ("/") character"
i.e it's dispatching to a url relative to your application context,not your webserver root folder
What you need is the redirect method which redirects to an absolute url.
Set the Struts 2 Filter in web.xml to accept forwards (and direct requests (or redirects)):
In your web.xml, change:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
To:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<!-- uncomment if you plan to include struts action output -->
<!--
<dispatcher>INCLUDE</dispatcher>
-->
</filter-mapping>
Credit:
http://www.coderanch.com/t/59584/Struts/request-dispatcher-struts-action
http://docs.oracle.com/cd/B32110_01/web.1013/b28959/filters.htm#BCFIEDGB

CometD demo on JBoss 6

I am planning to use Cometd library in my application that runs on JBoss AS 6. Therefore I downloaded cometd 2.4.0 and tried to deploy example war (from cometd-demo/target) to my AS. I was aware that this was not possible without modifications, so I did the changes in web.xml:
Changed to servlet 3.0 in web-app tag (it is originally 2.5). Used complete tag from CometD faq answer. Also uncommented continuation filter that was already in web.xml, based on this description
Based on faq answer, added async-supported tag. However, this causes problems: if I just uncomment it, web.xml can't be parsed. I found out that this is due to order of tags in XML, so moved async-supported tag down the order, just after load-on-startup tag. However, Jboss still throws exceptions:
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.IllegalStateException: The servlet or filters that are being
used by this request do not support async operation
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.ClassNotFoundException:
org.eclipse.jetty.server.AbstractHttpConnection from
BaseClassLoader#12a54b
Complete web.xml file that I use is here.
Example runs no my Jboss despite all errors reported, but by watching firebug, I can see that it does quick pooling instead of long pool. It seems that server thinks that browser has multiple connections open, which is not the case (see JSON below):
[{"id":"137","successful":true,"advice":{"interval":2000,"reconnect":"retry","multiple-clients":true,"timeout":20000},"channel":"/meta/connect"}]
Did anyone managed to make examples work with JBoss as6 and how? What I did wrong here?
remove:
<!-- Portability Filter, needed only to run on non Jetty or non Servlet-3.0 containers -->
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
from web.xml
I have the same setup and the same problem even if I remove continuation filter from web.xml.
I've found a thread on cometd-users group complaining about multiple-client issue on Tomcat 7 and the cause seems to be a Tomcat bug around Content-Type that is not set to "application/json".
However I've inspected packets and on JBossAS6 the content-type is correctly set on server responses.
UPDATE
I've give a try using Jetty 7 and the problem disappeared. The "multiple-clients" issue affects Tomcat as well as JBoss6 AS

Oracle WebLogic GroovyServlet Error

We have a J2EE app running beautifully on tomcat-based app servers, but all groovy scripts seem to fail on weblogic (10.3.5.0) and also IBM WebSphere. It seems the script processing, not the content of the scripts are the issue. The app itsells is a spring MVC web app and the GroovyServlet is part of the web.xml descriptor:
<!-- Servlets -->
<servlet>
<servlet-name>Groovlet</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Groovlet</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>
Calling a simple executor.groovy file results in an exception. My test script is small:
response.contentType = "application/json"
out.println "test"
But fails:
GroovyServlet Error: script: '/executor.groovy': Script processing failed.null
java.lang.NullPointerException
Anyone has a solution? Are there general issues with Groovy on weblogic or websphere?
Don't know if you're still having this issue :)
I had the same problem - the NullPointerException is caused by ServletContext.getRealPath(...) returning null.
There is a setting in Weblogic admin console which controls whether getRealPath() can be used.
It can also be configured in your weblogic.xml file by inserting the following (not sure how to deal with this in Websphere).
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
Sounds like response or out are not properly binded in weblogic. Did you try your servlet on another container. Also publishing more about the stacktrace and the web.xml could help

Resources