【问题标题】:PrimePush ClassNotFoundExceptionPrimePush ClassNotFoundException
【发布时间】:2013-10-10 13:50:58
【问题描述】:

我一直在尝试让 PrimePush 在运行在 Tomcat 7 上的 Web 应用程序上运行。我花了一整天时间搜索线程和 StackOverFlow,但还没有找到解决方案!其中一些包括thisthis 以及其他几个! 任何帮助将不胜感激!

我按照 PrimeFaces 用户指南设置 PrimePush。我的设置是 Tomcat7、PrimeFaces 3.5、Atmosphere 1.0.0.RC1、GlassFish 2.1.17 / WEB 2.2。

因此,我有以下依赖项;

    <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>

我的 web.xml 是:

<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>

我一直在尝试 PrimeFaces 展示中的 Push 示例。每当我尝试从我的 managedbean 推送时;

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

我收到以下错误:

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

请询问是否需要更多信息/详细信息。 提前致谢。

【问题讨论】:

    标签: jsf maven primefaces atmosphere primepush


    【解决方案1】:

    所以由于我的错误,

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

    由于我有正确的依赖项(根据 PF 手册),我认为它可能与我的 pom.xml 文件有关。由于我的设置,我包含了几个 Import-Packages。所以我添加了以下包,

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

    这导致我的 ClassNotFoundException 得到解决,但是,我在尝试部署我的 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
    

    这让我很困惑,根据 PF 手册,我不需要比我已经包含的更多的依赖项。所以无论如何,为了尝试解决这个问题,我去寻找正确的依赖关系并将其包括在内。但是,Missing Constraint 的列表越来越大。

    现在,我不想包含任何我不需要也不会使用的依赖项。所以我删除了我添加的所有依赖项,除了来自 Atmosphere 的依赖项。在查看大气运行时的 maven 存储库时,我注意到 PF 用户指南中给出的版本现在已经过时了。所以我改用最新的:

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

    还有宾果游戏——它现在构建和部署成功(虽然我无法从我的客户端 JSF 页面接收“推送”——但这是一个不同的问题!)。为什么我有这个问题而不是其他问题,仍然让我感到困惑。但我希望这对遇到类似问题的人有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 2023-03-16
      • 2018-12-23
      • 2021-03-22
      • 2014-04-18
      相关资源
      最近更新 更多