PF5.3.6, Atm 2.4.2: StringIndex out of range using PathParam

UI Components for JSF
Post Reply
loxon
Posts: 1
Joined: 22 Oct 2015, 15:07

08 Feb 2016, 17:58

Hi,

Using Primefaces 5.3.6 with Atmosphere 2.4.2 we have a String out of range exception:

febr. 08, 2016 4:39:02 DU org.atmosphere.config.managed.ManagedServiceInterceptor mapAnnotatedService
WARNING: Unable to create AtmosphereHandler
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1875)
at org.atmosphere.config.managed.ManagedServiceInterceptor.mapAnnotatedService(ManagedServiceInterceptor.java:61)
at org.primefaces.push.impl.PushEndpointInterceptor.mapAnnotatedService(PushEndpointInterceptor.java:37)
at org.atmosphere.config.managed.ServiceInterceptor.mapAnnotatedService(ServiceInterceptor.java:94)

We have a PathParam ("user") and using and endpoint (@PushEndpoint("/app/{user}/")).

The problematic code from ManagedServiceInterceptor.java is:

request.localAttributes().put(Named.class.getName(), path.substring(targetPath.indexOf("{")));
if (ap.pathParams()) {
request.localAttributes().put(PathParam.class.getName(), new String[]{path, targetPath});
}

Debugging the above lines, the path='/app' and targetPath='/app/{user}' which throws an exception....

Do anyone has an idea?
Thank you in advance!
Attila Kardos

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

09 Feb 2016, 18:00

Take a look at the PrimeFaces Push Chat example, and modify your code, accordingly.

See channel="..." below.

Code: Select all

<p:socket onMessage="handleMessage" channel="/{room}" autoConnect="false" widgetVar='subscriber' />
See @PushEndPoint("...") and @PathParam("..."), below.

Code: Select all

@PushEndpoint("/{room}/{user}")
@Singleton
public class ChatResource {
 
    private final Logger logger = LoggerFactory.getLogger(ChatResource.class);
 
    @PathParam("room")
    private String room;
 
    @PathParam("user")
    private String username;
 
You should be doing the same, because the PrimeFaces Push (Atmosphere) implementation is expecting the same (or similar).
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests