PrimePush ClassNotFoundException

若如初见. 提交于 2019-12-13 06:08:23

问题


I have been trying to get PrimePush working on my web application that runs on Tomcat 7. I have spent the whole day searching threads and StackOverFlow but have not yet came across a solution! Some of these include, this and this aswell as several others! Any help would be appreciated!

I followed the PrimeFaces User Guide on setting up PrimePush. My setup is Tomcat7, PrimeFaces 3.5, Atmosphere 1.0.0.RC1 , GlassFish 2.1.17 / WEB 2.2.

As such, I have the following dependencies;

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.5</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.1.17</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>el-impl</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-runtime</artifactId>
        <version>1.0.0.RC1</version>
        <scope>compile</scope>
    </dependency>

My web.xml is:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

I have been attemping the Push examples from the PrimeFaces showcase. Whenever I attempt to push from my managedbean;

PushContext p = PushContextFactory.getDefault().getPushContext();
p.push("/counter", String.valueOf(count));

I get the following error:

org.eclipse.virgo.kernel.osgi.framework.ExtendedNoClassDefFoundError: org/atmosphere/cpr/AsyncSupportListenerAdapter in KernelBundleClassLoader: [bundle=org.primefaces_3.5.0] in KernelBundleClassLoader: [bundle=org.primefaces_3.5.0] 
...
...
...
Caused by: java.lang.ClassNotFoundException: org.atmosphere.cpr.AsyncSupportListenerAdapter

Please ask if any more info/details are required. Thanks in advance.


回答1:


So due to my error,

    Caused by: java.lang.ClassNotFoundException: 
org.atmosphere.cpr.AsyncSupportListenerAdapter

and since I had the correct dependencies (according to the PF manual), I thought it might be related to my pom.xml file. Due to my set up, I include several Import-Packages. So I added the following package,

<Import-Package>org.atmosphere.cpr</Import-Package>

This resulted in my ClassNotFoundException being resolved, however, I came across another issue when trying to deploy my webapp.

    The bundle "atmosphere-runtime-1.0.0.RC1.jar" could not be resolved. 
Reason: Missing Constraint: Import-Package: com.sun.enterprise.web.connector.grizzly.comet

This confused me, according to the PF manual, I don't require any more dependencies than I have already included. So anyway, to try and resolve the issue I went about finding the correct dependency and included that. However, the list of Missing Constraint's grew larger and larger.

Now, I didn't want to include any dependencies that I don't require and will not use. So I removed all of the dependencies I added, except from Atmosphere. When looking at the maven repo for atmosphere-runtime, I noticed that the version given in the PF user guide, is now quite outdated. So I changed to use the most recent:

    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-runtime</artifactId>
        <version>2.0.1</version>
    </dependency>

And bingo - it now builds and deploys successfully(Though I am having trouble receiving a 'push' from my client JSF page - but that's a different question!). Why I had this issue and not others, still confuses me. But I hope this helps anyone with a similar issue.



来源:https://stackoverflow.com/questions/19166402/primepush-classnotfoundexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!