Specifying multiple filters in portlet.xml (gatein) - portlet

I have created a portlet that runs under Gatein on JBoss 7.2. (To be precise, this was a web app converted to a portlet.) I need two filters on my portlet, the Gatein CDI filter and the Primefaces Upload filter (since my portlet needs to handle uploads). In my portlet.xml file, I tried specifying the two filters like so:
<filter>
<filter-name>PortletCDIFilter</filter-name>
<filter-class>org.gatein.cdi.PortletCDIFilter</filter-class>
<lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
<filter>
<filter-name>PrimeFacesFileUploadFilter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
<filter-mapping>
<filter-name>PortletCDIFilter</filter-name>
<portlet-name>FleetManagementPortlet</portlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>PrimeFaces FileUploadFilter</filter-name>
<portlet-name>FleetManagementPortlet</portlet-name>
</filter-mapping>
However, when I try to access the portlet, I get an error in the log file saying that there is no portlet named FleetConnector.FleetManagementPortlet (my war file is FleetConnector.war). Interestingly, before I added the second filter and filter-mapping blocks, I did not get any error, even though the portlet name is the same.
I have not been able to find any example of the syntax to specify multiple filters in portlet.xml, so I'm not sure my syntax is correct. Any help would be appreciated.

Okay, I found out what the problem with my configuration was. The PrimeFaces upload filter is for servlets - not for portlets. The API is different. There was an error in the log indicating that the filter did not have the correct API, but the last error shown indicated that the portlet name was incorrect, which was not the case. I will now search for an upload filter that works with portlets.

Related

Jersey REST Web Service with Tomcat, Eclipse and 404's - Need another set of eyes please

This should be so simple, but its blowing my mind... I have read through hundreds of the questions here, and so far none of the responses has made a difference in what I have tried. It is obviously time for another set of eyes..
I am getting a 404 error when trying to do the most simple of rest tests.
My Tomcat 7.0 Servers starts up just fine. No errors.
My project name in Eclipse is: atomic_services_poc
The Context in Tomcat is set to: /atomic_services_poc
I can successfully return static pages with: http://localhost:8080/atomic_services_poc/index.html
Here is my web.xml:
<servlet>
<servlet-name>workflowmanagerserlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.tp.wfm.webservice</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>workflowmanagerserlvet</servlet-name>
<url-pattern>/workflowmanager/*</url-pattern>
</servlet-mapping>
Here is the java code for WorkFlowManagerRestService.java
package com.tp.wfm.webservice;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("/workflow")
public class WorkFlowManagerRestService {
#GET
#Produces(MediaType.TEXT_XML)
public String sayXMLHello()
{
return "Data Return";
}
}
I am using SoapUI to test the GET method of the restful request. I have tried numerous variations of the following and they all result in a 404 error.
GET host:8080/atomic_services_poc/workflowmanager/workflow
Help please before I throw this laptop...
I don't see anything wrong in your setup, from what you show. You don't mention which Jersey version you are using but I guess is bigger than 2. (I believe in Jersey < 2 the name of the property in the web.xml was different).
I would suggest the following to try to debug:
(1) For the moment remove the
#Produces(MediaType.TEXT_XML)
as suggested by #braunpet, and just test it with your web browser
(2) Add a ResourceConfig class so that you can at least debug what the server is doing in startup. This is pretty simple, you define a class like this:
package com.tp.wfm.application;
import org.glassfish.jersey.server.ResourceConfig;
public class MyApplication extends ResourceConfig {
public MyApplication() {
super();
packages("com.tp.wfm.webservice");
}
}
And change your web.xml like this:
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.tp.wfm.application.MyApplication</param-value>
</init-param>
Then you add a breakpoint in Eclipse to make sure your resources are loading.
I hope it helps!
Ok, so this morning I went back to basics. I created a brand new workspace with eclipse on my laptop from the vogella tutorial. I got this one to work on my laptop in all of 10 minutes. I then went to my problem work area and added the same items step by step. It worked...
I then started adding in my components and slowly one by one, I was able to get them working. I must have had some type of spelling or something wrong, but I feel better that no one here could see it either.
The good news it is now working. (Even after I removed the vogella stuff)..
:)
Thanks all that helped!
well I had the same problem. I was looking for a solution for about 2 weeks. After having passed 20 tutorials it drived me crazy why my tomcat is still showing the 404 response. I just wanted to get a helloworld-example working but the server was showing the 404 every time when I tried to open a ResourcePATH (e.g. #Path("/hello")). My Web.xml was "setupped" for jersey 2.x and the url param was declared as "/rest/*". The URL was called correctly by localhost:PORT/PROJECT/rest/hello.. but no Chance.
Finally I found a solution for myself that may help someone else who is troubling with this (like the author of this question):
Create a .WAR file of your Project and put it into your "apache_tomcat/webapps" directory
(Eclipse: Right Click on the Project-> Export-> as .WAR file)
Restart the Tomcat-Server
Run the Application on the restarted Server
After that, it worked for me, I was able to connect to any #Path("") I implemented. And if I want to implement a new #Path I have to reprocess the 3 steps. Hope this can be helpful!

ATG CRS changing context root causes raw JSP to display

I am working on ATG 10.1.2 with Endeca 3.1.2 with the CRS app. Here is what I've done so far.
wanted to change my context root to /mystore
I changed the contexts in web.xml, application.xml and MANIFEST.MF entry for CommerceReferenceStore, subsequently changed my site configuration for one of the CRS stores to have my custom baseUrl and production URL.
In my case I am not using path based multi-site approach. my baseUrl and production Url are same. If I start my application, all pages are coming fine. However, when I try to browse the category pages (cartridges), the JSP's code is displayed on the browser, they do not compile.
I found some solution on oracle community that I should remove the FORWARD dispatcher from PageFilter from my web.xml, and that should solve the issue. I did that, now the page compiles, but intermittent raw JSPs are displayed along with JSP comments on the browser.
Below threads might give you some context on my issue.
https://community.oracle.com/thread/2508338
https://community.oracle.com/thread/3518254
Has someone tried it and have a solution, please share your inputs.
Would suggest you look at your configuration for these components as changing the context root might require configuration changes to:
ContentItemToRendererPath in the ATG documentation
The getRendererPathForContentItem() method returns the web-app relative path of the JSP file used to render the ContentItem.
/atg/endeca/servlet/request/NucleusHttpServletRequestProvider which provides access to the endeca components
/atg/endeca/assembler/AssemblerPipelineServlet with a full explanation here.
Try to add REQUEST and ERROR as well to the dispatcher element.
If you have ...
<filter>
<filter-name>PageFilter</filter-name>
<filter-class>atg.filter.dspjsp.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PageFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
then change it to...
<filter>
<filter-name>PageFilter</filter-name>
<filter-class>atg.filter.dspjsp.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PageFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Sorry for posting the answer to this after so long.
This was an issue with Oracle Commerce itself. You should try to get a patch for it from Oracle, if you see this on Oracle Commerce version 10.x

GWT: example of an "Admin" and "Normal-mode" application

I am using GWT (and GWT-Plateform) and GAE, and I would like to have an Admin and a Normal-mode of my application.
I read this post https://turbomanage.wordpress.com/2009/11/19/tips-on-organizing-gwt-modules/#comment-5064 and I would like to see a complete project structure of an application using an Admin and a Normal-mode application. Do you know any sample code of this case (with GWT and GAE if possible...and with GWTP would be perfect) ?
In the link, M. Chandler says that I could have 3 modules (admin, app, common) and just 2 entry point (admin and app). Admin and app inherits common. But I do not know more stuffs such as :
- I am using "Client Bundle" so will it be possible to have my resource folder just inside the "common module". Will it works ? Do I need just one CSS for the 2 modules (admin and normal-mode) ?
- Does my whole domain model needs to be in the common module ?
Any recommendation about how to structure a code with an Admin module using GWT is welcome.
My current problem is that I do not know how to do this with Eclipse (should I copy paste the "client", "server", "share" folders of the "app" package and to add them in a new package named "admin" and then to delete and modify some files ? It seems complicated...or is there just some minimal files and configurations to do ?)
Thanks you,
It's quite easy...
check this link: https://developers.google.com/appengine/docs/java/config/webxml#Security_and_Authentication
You need two entry points.
First for Normal-Mode
Second for Admin-Mode
Everything for admin mode is unter the path /admin/...
In the web.xml you configure now the security constraints in web.xml:
<security-constraint>
<web-resource-collection>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
For the user registration and login control you can use the USERS-Api from Google:
https://developers.google.com/appengine/docs/java/users/overview

references to SystemProperties in web.xml and jboss-web.xml works in JBoss5 but not in JBoss7

Under JBoss 5.1 we used to "stage" values in the web.xml and the jboss-web.xml by using SystemProperties. In the web.xml that looked like this:
<web-app [...]>
[...]
<auth-constraint>
<role-name>${myRole}</role-name>
</auth-constraint>
[...]
<login-config>
<auth-method>${myAuthMethod}</auth-method>
</login-config>
<security-role>
<role-name>${myRole}</role-name>
</security-role>
</web-app>
Additionally we did the same thing for the jboss-web.xml and the security-domain. Not adding the concrete values is crutial because the WAR-modules we did that are generated by our code generator.
JBoss 7 does not replace these values any more - which is correct according to the spec but in our case quite uncomfortable.
Any ideas how one could:
do some kind of replacement at runtime?
refreign having to replace those values at runtime?
... ?
See https://issues.jboss.org/browse/AS7-3816.
The fix for system property substitution for ejb-jar.xml is going to JBoss AS 7.1.2.
You can check the source or contact the assignee to ensure that is also going to be also fixed for web.xml. Even if it's not yet, it should be possible to convince Bartosz Baranowski to fix it too.
Update
https://issues.jboss.org/browse/AS7-4479 - we've been heard :)
Definitely not my forté, but you might want to look at the migration guide. There also might be some useful information in the authentication documentation.
polemoser - according to which specs? Im waiting for issue to be merged into master before fixing any other related.

Jetspeed null PortletDefinition

I am running a jetspeed portal which contains various portlet applications and have come across an issue after a recent reinstall where some of the portlets will return
Cannot pass a null PortletDefinition
to a PortletEntity
Any idea what is causing this issue? I investigated a bit and it seems that jetspeed runs a process when new portlets are added where it creates mappings in its DB (derby in my case). If this does not complete it seems to cause this problem. Is my assumption correct? If yes, how can I restart this process?
Many thanks
This exception can be caused by having a mismatched portlet name on on your page. This often happens when the portlet application is deployed with one name, but then the page fragment references another name, for example, on your page you have:
<fragment id="1234" type="portlet" name="myApp::myPortlet">
and when you deploy your war file, it is named for example myApp-1.0-SNAPSHOT.war
The fragment's name attribute should have the value "${portlet.war.name}::${portlet.name}. The first part (${portlet.war.name}) is the name of the portlet war file, minus the .war. The second part comes from the value of the tag in the portlet.xml file.
You can either rename your war file, or change your page definition to include the version. I don't recommend putting the version number in the fragment though, as it can change.
A third solution is to actually change the name of the portlet app in your web.xml by setting an init param named contextName on the Jetspeed Container servlet. In the example below its set to "myApp":
<servlet>
<description>MVC Servlet for Jetspeed Portlet Applications</description>
<display-name>Jetspeed Container</display-name>
<servlet-name>JetspeedContainer</servlet-name>
<servlet-class>
org.apache.jetspeed.container.JetspeedContainerServlet</servlet-class>
<init-param>
<param-name>contextName</param-name>
<param-value>myApp</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>