Servlet started and eventBus is null

UI Components for JSF
Post Reply
delafere
Posts: 4
Joined: 01 Mar 2015, 12:48

22 Oct 2015, 11:14

I've tried to make push working on my app (PF 5.3), and finally servlet is starting

log

Code: Select all

1040 [http-nio-8080-exec-4] WARN org.atmosphere.cpr.AtmosphereFramework - org.primefaces.push.impl.PushEndpointMapper is not a framework service that could be installed
1062 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere is using org.atmosphere.cpr.DefaultAnnotationProcessor for processing annotation
1062 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.DefaultAnnotationProcessor - AnnotationProcessor class org.atmosphere.cpr.DefaultAnnotationProcessor$ServletContainerInitializerAnnotationProcessor being used
1063 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AnnotationHandler - Found Annotation in class org.primefaces.push.impl.PushEndpointProcessor being scanned: interface org.atmosphere.config.AtmosphereAnnotation
1063 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AnnotationHandler - Found Annotation in class org.primefaces.push.impl.PushEndpointMapper being scanned: interface org.atmosphere.config.service.EndpointMapperService
1063 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AnnotationHandler - Found Annotation in class org.primefaces.push.impl.PushEndpointInterceptor being scanned: interface org.atmosphere.config.service.AtmosphereInterceptorService
1077 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AnnotationHandler - Found Annotation in class pl.apptrend.consolia.client.impor.NotifyResource being scanned: interface org.primefaces.push.annotation.PushEndpoint
1092 [http-nio-8080-exec-4] INFO org.atmosphere.util.ForkJoinPool - Using ForkJoinPool  java.util.concurrent.ForkJoinPool. Set the org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads to -1 to fully use its power.
1098 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy mapped to context-path /notify and Broadcaster Class org.atmosphere.cpr.DefaultBroadcaster
1098 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor [@PushEndpoint Interceptor] mapped to AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy
1104 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Auto detecting WebSocketHandler in /WEB-INF/classes/
1116 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol 
1120 [http-nio-8080-exec-4] INFO org.atmosphere.container.JSR356AsyncSupport - JSR 356 Mapping path /primepush
1122 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installing Default AtmosphereInterceptors
1123 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.CorsInterceptor : CORS Interceptor Support
1123 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.CacheHeadersInterceptor : Default Response's Headers Interceptor
1123 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support
1123 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support
1124 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.HeartbeatInterceptor : Heartbeat Interceptor Support
1124 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support
1124 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support
1125 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol
1125 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor : org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor
1125 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 	org.atmosphere.interceptor.IdleResourceInterceptor : org.atmosphere.interceptor.IdleResourceInterceptor
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults to disable them.
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Atmosphere LifeCycle with priority AFTER_DEFAULT 
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor  Track Message Size Interceptor using | with priority BEFORE_DEFAULT 
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor @PushEndpoint Interceptor with priority AFTER_DEFAULT 
1126 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor CORS Interceptor Support with priority FIRST_BEFORE_DEFAULT 
1129 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Default Response's Headers Interceptor with priority AFTER_DEFAULT 
1129 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Browser Padding Interceptor Support with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Android Interceptor Support with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.interceptor.HeartbeatInterceptor - HeartbeatInterceptor configured with padding value 'X', client frequency 60 seconds and server frequency 0 seconds
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Heartbeat Interceptor Support with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor SSE Interceptor Support with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor JSONP Interceptor Support with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Atmosphere JavaScript Protocol with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Browser disconnection detection with priority AFTER_DEFAULT 
1130 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor org.atmosphere.interceptor.IdleResourceInterceptor with priority BEFORE_DEFAULT 
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Using EndpointMapper class org.primefaces.push.impl.PushEndpointMapper
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Using BroadcasterCache: org.atmosphere.cache.UUIDBroadcasterCache
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Broadcaster Shared List Resources: false
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Broadcaster Polling Wait Time 100
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Shared ExecutorService supported: true
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Messaging ExecutorService Pool Size unavailable - Not instance of ThreadPoolExecutor
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Async I/O Thread Pool Size: 200
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Using AtmosphereResurceFactory: org.atmosphere.cpr.DefaultAtmosphereResourceFactory
1131 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
1136 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Invoke AtmosphereInterceptor on WebSocket message true
1136 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - HttpSession supported: false
1136 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere is using DefaultAtmosphereObjectFactory for dependency injection and object creation
1136 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: Apache Tomcat/8.0.26 using javax.servlet/3.0 and jsr356/WebSocket API
1137 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere Framework 2.4.0-RC6 started.
1137 [http-nio-8080-exec-4] INFO org.atmosphere.cpr.AtmosphereFramework - 

	For Atmosphere Framework Commercial Support, visit 
	http://www.async-io.org/ or send an email to support@async-io.org
I also checked in debugger, but still eventBus in EventBusFactory is null.
Solutions from other topics didn't solve the problem.

web.xml

Code: Select all

<servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
            <param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>              
    </servlet>
    <servlet-mapping>
        <servlet-name>Push Servlet</servlet-name>
        <url-pattern>/primepush/*</url-pattern>
    </servlet-mapping>
endpoint

Code: Select all

import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;
 
@PushEndpoint("/notify")
public class NotifyResource {
 
    @OnMessage(encoders = {JSONEncoder.class})
    public String onMessage(String count) {
        return count;
    }
} 
socket and js (in index):

Code: Select all

<script type="text/javascript">
                function handleMessage(data) {
                    alert(data);
                    $('#out').html($('#out').html() + '<br/>' + data);
                }
            </script>
            <p:socket onMessage="handleMessage" widgetVar="notifySocket" channel="/notify" autoConnect="false"/>
in ui:composition (i have to move socket to index to solve js missing problem):

Code: Select all

<script>
        $(document).ready(function () {
            PF('notifySocket').cfg.request.trackMessageLength = true;
            PF('notifySocket').connect();
        });
    </script>
eventbus call:

Code: Select all

EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/notify", "Message");
Tomcat 8.0.26
Primefaces 5.3
Atmosphere-runtime 2.4.0-RC6
jvm 1.8.0_60-b27 Oracle

Thanks for any advice.

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

22 Oct 2015, 21:02

delafere wrote:endpoint

Code: Select all

import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;
 
@PushEndpoint("/notify")
public class NotifyResource {
 
    @OnMessage(encoders = {JSONEncoder.class})
    public String onMessage(String count) {
        return count;
    }
} 
My recommendation to you is same as I recommended, here.
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

delafere
Posts: 4
Joined: 01 Mar 2015, 12:48

22 Oct 2015, 23:15

No difference...
Its interesting. When i cloned showcase from github, i also getting NPE.

Any ideas?

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

23 Oct 2015, 13:02

Reply with your endpoint class, so I can verify code changes.
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

delafere
Posts: 4
Joined: 01 Mar 2015, 12:48

26 Oct 2015, 12:06

Code: Select all

import org.primefaces.push.annotation.*;
import org.primefaces.push.impl.JSONEncoder;
 
@PushEndpoint("/notify")
@Singleton
public class NotifyResource {
 
    @OnMessage(encoders = {JSONEncoder.class})
    public String onMessage(String count) {
        return count;
    }
    
    @OnOpen
    public void onOpen(){
    
    }
    
    @OnClose
    public void onClose(){
    
    }
} 
eventBus is called in new Thread, maybe this is the problem?

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

27 Oct 2015, 15:03

Below, is my NotifyResource class. Compare your @OnOpen and @OnClose methods to mine, below, and everytime you make a change, please reply with your code changes and test results.

Code: Select all

import javax.faces.application.FacesMessage;

import org.primefaces.push.EventBus;
import org.primefaces.push.RemoteEndpoint;
import org.primefaces.push.annotation.OnClose;
import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.OnOpen;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.annotation.Singleton;
import org.primefaces.push.impl.JSONEncoder;
 
@PushEndpoint("/{usernameAndSessionId}")
@Singleton
public class NotifyResource {
         
    @OnMessage(encoders = {JSONEncoder.class})
    public FacesMessage onMessage(FacesMessage message) {
        return message;
    }
    
    @OnOpen
    public void onOpen(RemoteEndpoint r, EventBus eventBus) {
    }
 
    @OnClose
    public void onClose(RemoteEndpoint r, EventBus eventBus) {
    }
}
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

delafere
Posts: 4
Joined: 01 Mar 2015, 12:48

27 Oct 2015, 15:07

Tried that also. Finally its works only with primefaces 5.2 and atmosphere 2.3.5. So thats PF 5.3 issue.

darkbauer
Posts: 10
Joined: 19 Nov 2014, 22:09

27 Oct 2015, 16:09

Hello,

I had the same issue, but I fixed it by upgrading atmosphere dependencies to the latest release : 2.4.0-RC6.

After that, all worked fine for me.

Hope it helps,

Thierry
JSF 2.2 / Mojara 2.2.8 / WildFly 9.0.1
Primefaces 5.3 / PE 4.0.0
Java 1.8
JPA 2.1

ptcherniati
Posts: 1
Joined: 04 Jul 2016, 16:53

04 Jul 2016, 17:30

The probleme is the @javax.inject.Inject in EventBusFactory of Primefaces whicj not be included in all server implementation.

You've just to add in your pom
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

Ibrahim Siripe
Posts: 35
Joined: 11 Nov 2016, 13:11

01 Jan 2017, 18:50

ptcherniati wrote:The probleme is the @javax.inject.Inject in EventBusFactory of Primefaces whicj not be included in all server implementation.

You've just to add in your pom
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
Hi ptcherniati,

You save me a lot. With primefaces 6.0, I got nullpointerexception. But after update pom everything work very well. I don't understant why primefaces team didn't put it in documentation.

Anyway thank you again Ptcherniati

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests