Atmosphere can not scan for annotation in a war file

UI Components for JSF
Post Reply
sarahnac
Posts: 3
Joined: 20 Nov 2014, 18:55

20 Nov 2014, 19:02

Hello all,

I'm using atmosphere 2.1.9 with primefaces version 5.0, and wildfly8. Amosphere is provided by my server. (used as wildfly module).
I have a bean NotifyResourceBean which receive some message :

Code: Select all

@PushEndpoint ("/notify")
public class NotifyResourceBean {

  @OnOpen
  public void onOpen(RemoteEndpoint r, EventBus eventBus) {
  }

  @OnClose
  public void onClose(RemoteEndpoint r, EventBus eventBus) {
  }



  @OnMessage(encoders = {JSONEncoder.class})
  public FacesMessage onMessage(FacesMessage message) {  
    return message;
  }

An other bean send those messages :

Code: Select all

          EventBus eventBus = EventBusFactory.getDefault().eventBus();
          eventBus.publish("/notify", "test"));

Everything works well when i start my application by eclipse. I have a folder called nameApp.war in the standalone folder of wildfly. NotifyResourceBean receive all the message.


When i package my app in a war file (via maven), atmosphere can't find the annotation @PushEndPoint in my WEBINF/classe folder. I have the following error : "No Annotated class using @PushEndpoint found. Push will not work"
The architectury of my folders and file is exactly the same as before, except that is now packaging. (I unzip the war file to compare).


The configuration for atmophere in 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>
		<init-param>
			<param-name>org.atmosphere.annotation.packages</param-name>
			<param-value>org.primefaces.push</param-value>
		</init-param>
		<init-param>
			<param-name>org.atmosphere.cpr.packages</param-name>
			<param-value>package_off_my_app</param-value>
		</init-param>
		<load-on-startup>0</load-on-startup>
		<async-supported>true</async-supported>
	</servlet>
	<servlet-mapping>
		<servlet-name>Push Servlet</servlet-name>
		<url-pattern>/primepush/*</url-pattern>
	</servlet-mapping>

Do you have any idea?

Many thanks,

Sarah

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

30 Nov 2014, 07:32

what happens when you remove the following?

Code: Select all

      <init-param>
         <param-name>org.atmosphere.annotation.packages</param-name>
         <param-value>org.primefaces.push</param-value>
      </init-param>
      <init-param>
         <param-name>org.atmosphere.cpr.packages</param-name>
         <param-value>package_off_my_app</param-value>
      </init-param>
or make the following change:

Code: Select all

      <init-param>
         <param-name>org.atmosphere.annotation.packages</param-name>
         <param-value>org.primefaces.push.annotation</param-value>
      </init-param>
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

sarahnac
Posts: 3
Joined: 20 Nov 2014, 18:55

04 Dec 2014, 16:14

Hello!
Thanks for your answer.

I have exactly the same error as before. But if i don't put this code

Code: Select all

      <init-param>
         <param-name>org.atmosphere.cpr.packages</param-name>
         <param-value>package_off_my_app</param-value>
      </init-param>
the push is not working, even if i have my war unzipped.

For the moment, i found a temporary a solution by unziped the war in the standalone folder, but i don't like this :)

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

04 Dec 2014, 22:59

sarahnac wrote:I'm using atmosphere 2.1.9 with primefaces version 5.0, and wildfly8. Amosphere is provided by my server. (used as wildfly module).
hmmm, so atmosphere 2.1.9 (and primefaces 5.0) is bundled with wildfly8. First of all, i don't think atmosphere 2.1.9 is compatible with primefaces 5.x. I recommend atmosphere 2.2.3 with primefaces 5.x, and if possible, remove atmosphere 2.1.9 from your wildfly bundle.
sarahnac wrote:For the moment, i found a temporary a solution by unziped the war in the standalone folder, but i don't like this :)
interesting
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

sarahnac
Posts: 3
Joined: 20 Nov 2014, 18:55

05 Dec 2014, 08:37

Try Atmosphere 2.2.2, and atmosphere 2.2.3.
Still the same error when i package the application : 'No Annotated class using @PushEndpoint found. Push will not work.'
Everything works fine when i unzip the war file.
...

thazarik
Posts: 2
Joined: 25 Feb 2014, 23:20

30 Mar 2015, 23:48

sarahnac wrote: Everything works well when i start my application by eclipse.
Same issue here. I'm using atmosphere 2.26 + tomcat 7 + compat + PrimeFaces 5.

So far I've tried removing the compat libraries and various init parameters to push.PushServlet. Was this ever resolved ?

rmacedo
Posts: 1
Joined: 04 Sep 2013, 16:56

10 Aug 2016, 18:44

Hi guys,
I'm using atmosphere 2.3.8 + tomcat 7.0.52 + spring-security 4.0.4.RELEASE + PrimeFaces 5.2
I had the same problem and solved with the following configuration

Configuration on 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.packages</param-name>
            <param-value>com.senfio.monitore.push</param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
        <async-supported>true</async-supported>
</servlet>
spring-security configuration

Code: Select all

<filter>
		<filter-name>springSecurityFilterChain</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
		<async-supported>true</async-supported>
</filter>

<filter-mapping>
		<filter-name>springSecurityFilterChain</filter-name>
		<url-pattern>/*</url-pattern>
</filter-mapping>
Class that implement the service.

Code: Select all

package com.senfio.monitore.push;

import org.atmosphere.config.service.AtmosphereService;
import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;

@AtmosphereService
@PushEndpoint("/update")
public class AlertCatcher {
	
	@OnMessage(encoders = {JSONEncoder.class})
    public String onMessage(String message) {
        return message;
    }

}
Page that receive the pushed message

Code: Select all

<p:socket onMessage="updatePanelFromPush" channel="/update" />

jeanse7en
Posts: 4
Joined: 24 Aug 2017, 02:56

30 Aug 2017, 18:27

Hello. I face the same problem. I put one more servlet config is AtmosphereServlet. The purpose is to inject directly when starting the application. Because when you deploy with war file on Production (I'm using Apache Geronimo 3.0.1), the Geronimo Tomat can not load the annotation in with Push Servlet. So that you inject your annotation to AtmosphereServlet. And set the order is loading AtmosphereServlet first and the next one is Push Servlet

Code: Select all

     <servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.annotation.packages</param-name>
            <param-value>org.primefaces.push</param-value>
        </init-param>
         <init-param>
            <param-name>org.atmosphere.cpr.packages</param-name>
            <param-value>com.crif.baseservices.web.push</param-value>
        </init-param>
        <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>
        <description>AtmosphereServlet</description>
        <servlet-name>AtmosphereServlet</servlet-name>
        <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.cpr.packages</param-name>
            <param-value>com.crif.baseservices.web.push</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
            <param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
     <servlet-mapping>
        <servlet-name>Push Servlet</servlet-name>
        <url-pattern>/primepush/*</url-pattern>
    </servlet-mapping>

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

03 Sep 2017, 14:50

I don't know if its related but I reported this issue: https://github.com/Atmosphere/atmosphere/issues/2289

It seems Atmosphere only scans WEB-INF/Classes so if your code is packaged up in a JAR inside WEB-INF/lib/ it will never find it. Maybe its somehow related to this issue you are having of it not being able to find it except if you explode the war in standalone mode.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

jeanse7en
Posts: 4
Joined: 24 Aug 2017, 02:56

09 Sep 2017, 10:12

Sorry but I don't use web-fragment in my project. Maybe having something strange in my Geronimo Tomcat. But anyway, we can try with it

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests