primepush on Tomcat 7 not working - tomcat7

I am new to primepush and have a question.
The whole project is based on maven and the server is Tomcat 7.0.27, so I add the dependence into pom.xml file as following:
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-annotations</artifactId>
<version>1.0.1</version>
</dependency>
The web.xml is like following:
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.HeaderBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterClass</param-name>
<param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
<param-value>org.atmosphere.client.TrackMessageSizeFilter</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.sessionSupport</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.useWebSocket</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
I grab the code of chat from primefaces showcase, but somehow the IllegalStateException of AtomsphereFramework is always thrown.
09:33:38.322 ERROR o.atmosphere.cpr.AtmosphereFramework - AtmosphereFramework exception
java.lang.IllegalStateException: Not supported.
at org.apache.catalina.connector.Request.startAsync(Request.java:1609) ~[catalina.jar:7.0.12]
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1031) ~[catalina.jar:7.0.12]
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:379) ~[servlet-api.jar:3.0.FR]
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:379) ~[servlet-api.jar:3.0.FR]
at org.atmosphere.cpr.AtmosphereRequest.startAsync(AtmosphereRequest.java:556) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:137) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:103) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1293) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:293) [atmosphere-runtime-1.0.1.jar:1.0.1]
at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:279) [atmosphere-runtime-1.0.1.jar:1.0.1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [servlet-api.jar:na]
I debug the source code of Atomsphere Framework and find out the problem is the following line in the Servlet30CometSupport.class:
AsyncContext asyncContext = req.startAsync(req, res);
It throws an IllegalStateException afterwards.
How can I solve that problem?
Thanks for any help

Tomcat version 7.0.27 supports WebSockets.
So param setting in your web.xml should be
<init-param>
<param-name>org.atmosphere.useWebSocket</param-name>
<param-value>true</param-value>
</init-param>
or omit entire param setting cause websockets are used by default.
Also you will need to add dependencies for atmosphere-compat-tomcat-1.0.1.jar and atmosphere-compat-tomcat7-1.0.1.jar

Related

LoggingFilter not invoked - gives HTTP 404 - Not Found error

I am using Jersey 2.3.1, Tomcat 7.0, maven.
I have a simple jersey servlet:
#Path("/myresource")
public class JerseyResource {
#GET
#Produces(MediaType.APPLICATION_JSON)
public List <SecurityControlDTO> getControls() throws HibernateException {
SecurityControlDTOManager manager = new SecurityControlDTOManager();
return manager.getControls();
}
}
And want to add a LoggingFilter.
This is my web.xml:
<!-- Jersey Mapping -->
<servlet>
<servlet-name>jersey-servlet</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.rbs.wisexec.controlservice.rest;</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>jersey-auth</filter-name>
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
<init-param>
<param-name>javax.ws.rs.container.ContainerRequestFilter</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>jersey-auth</filter-name>
<url-pattern>/rest/*</url-pattern>
<servlet-name>jersey-servlet</servlet-name>
</filter-mapping>
When I run the tomcat server, the server starts up but then when I try to access the URL I get a "HTTP Status 404 - not found" error. I have debug breakpoints in filter class so I can see that it never gets invoked.
I have tried various different ways of configuring the loggingFilter in the web.xml i.e. putting the:
<init-param>
<param-name>javax.ws.rs.container.ContainerRequestFilter</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter</param-value>
</init-param>
Inside of the servlet tag - this runs the server and the resource is shown but again the filters are not invoked.
If you want to configure your application via web.xml and not by using subclass of javax.ws.rs.core.Application, you can modify your web descriptor in this way:
<!-- Jersey Mapping -->
<servlet>
<servlet-name>jersey-servlet</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.rbs.wisexec.controlservice.rest;</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
The important thing is the second init-param which states that LoggingFilter should be added to the list of JAX-RS providers in your application. Parameter is taken from ServerProperties class where you can find description of this parameter (ServerProperties.PROVIDER_CLASSNAMES) as well as other possibilities to configure your Jersey application.

Freemarker template (FTL) not working in struts2

I am working with Struts2 and ftl. Instead of jsp I want to use ftl, but when I define welcome file in web.xml as login.ftl it is not working. It just shown as text. The entire code is shown in the browser, but if it is jsp everything works.
I just paste my web.xml below.
<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>*.action</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>login.ftl</welcome-file>
</welcome-file-list>
How can I configure ftl in Struts2? If I use that same page as output page of an action it is working. How can I solve this? Is there any problem with my web.xml configuration?? Please help me. Thank you in advance.
Maybe this help you(extract of a web.xml):
<servlet>
<servlet-name>freemarker</servlet-name>
<servlet-class>com.thoughtequity.video.web.servlet.SiteFreemarkerServlet</servlet-class>
<!-- FreemarkerServlet settings: -->
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/</param-value>
</init-param>
<init-param>
<param-name>NoCache</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>ContentType</param-name>
<param-value>text/html</param-value>
</init-param>
<!-- FreeMarker settings: -->
<init-param>
<param-name>template_update_delay</param-name>
<param-value>0</param-value> <!-- 0 is for development only! Use higher value otherwise. -->
</init-param>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>number_format</param-name>
<param-value>0.##########</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/te.js</url-pattern>
</servlet-mapping>
<!-- Map *.ftl files to Freemarker-->
<servlet-mapping>
<servlet-name>freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.vm</welcome-file>
</welcome-file-list>
FreeMarker template files need to be processed in order to generate textual pages that shows your data. You cannot just put them in welcome-file-list. For example in Struts2 you can redirect to your action and there use your template.
Also read this http://wiki.metawerx.net/wiki/HowToUseAServletAsYourMainWebPage.

Tomcat migration to WebLogic12

all
Recently I migrate a webapp from tomcat7 to Weblogic12, the jdk version is 1.6.0.30. After I deploy the project war completed, open the login page(/login.htm), ie throw such an exception:
Error 404--Not Found From RFC 2068 Hypertext Transfer Protocol --
HTTP/1.1:
10.4.5 404 Not Found The server has not found anything matching the Request-URI. No indication is given of whether the condition is
temporary or permanent.
If the server does not wish to make this information available to the
client, the status code 403 (Forbidden) can be used instead. The 410
(Gone) status code SHOULD be used if the server knows, through some
internally configurable mechanism, that an old resource is permanently
unavailable and has no forwarding address
.
Here is My Web.xml File:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>sys</display-name>
<description>JSP application</description>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/framework-data.xml,
classpath:spring/framework-common.xml,
classpath:spring/framework-query.xml
</param-value>
</context-param>
<!--encoding-->
<filter>
<filter-name>sessionFilter</filter-name>
<filter-class>com.wri.hy.framework.application.framework.security.controller.SessionFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<param-name>isCheck</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>sessionFilter</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.wri.hy.framework.application.framework.security.controller.SessionListener</listener-class>
</listener>
<!--spring-->
<servlet>
<servlet-name>framework</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/framework-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--surpport WebApplicationContextUtils-->
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--Watcher-->
<servlet>
<servlet-name>watcher</servlet-name>
<servlet-class>com.wri.hy.framework.application.framework.util.Watcher</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/displayChart</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>framework</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>240</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--error-page>
<error-code>404</error-code>
<location>/fileNotFound.html</location>
</error-page-->
</web-app>
What can I do for this problem? Here is an active place for puzzles,any response is apprieated. Thanks.
problem resolvered, It sourced by load-on-startup tag value, defined web.xml. Must be different on weblogic.
<servlet>
<servlet-name>framework</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/framework-servlet.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!--surpport WebApplicationContextUtils-->
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Thanks.

Apache Server File Permission

I am using Apache Server 6.0 and I am trying to update a file using ajax put request but the server is giving me error 405 Method Not Allowed. I am working this out on windows.
Can anybody help me out if that.
Thanks in Advance.
Vinay
I'm assuming you are using apache tomcat (because you have mentioned version 6.0)
In that case add this to your webapp's web.xml:
<servlet>
<servlet-name>myDefault</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value> <!-- this will enable PUT for your app -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myDefault</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Then you can test this like so, to upload the file (You need the curl program to test)
curl -T somefile.txt http://localhot:8080/<yourapp>/
If you want to enable this globally, you can make the same change in /conf/web.xml (for default servlet)

Error 500: Filter [Spring OpenEntityManagerInViewFilter]: could not be loaded

I am trying to deploy a Spring application on WAS 6.0 (JDK 1.4.2). Day back I was getting tons of (Unsupported major.minor version 49.0) errors. I replaced most of the jar files and now I am left with only one error on:
org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter (Unsupported major.minor version 49.0)
what jar file do I need to replace for this? Also when I am running my URL in the browser I am getting the error:
Error 500: Filter [Spring OpenEntityManagerInViewFilter]: could not be loaded
Can you please guide me ,where exactly I am doing wrong. Attached is my Web.xml.
Your help is highly appreciated.
enter code here
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
analytics
Roo generated analytics application
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>analytics.root</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<context-param>
log4jConfigLocation
classpath:log4j.properties
org.springframework.web.util.Log4jConfigListener
org.springframework.web.context.ContextLoaderListener
<servlet>
<servlet-name>analytics</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Serves static resource content from .jar files such as spring-js.jar -->
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>analytics</servlet-name>
<url-pattern>/*.html</url-pattern>
</servlet-mapping>
<!-- Map all /resources requests to the Resource Servlet for handling -->
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<servlet-name>analytics</servlet-name>
</filter-mapping>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
Spring OpenEntityManagerInViewFilter
/*
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/jsp/uncaughtException.jsp</location>
</error-page>
The "Unsupported major.minor version" errors are caused by your using JAR files compiled for a higher version of java than you're running.
I think class file version 49.0 is Java 5, and you're running 1.4. That means you must be using a library that's Java 5 only, and the only version of Spring thats java 5 only is Spring 3.0. If that's the case, then downgrade your Spring to 2.5.6.

Resources