0

我正在尝试使用 CDI (PAX-CDI) 设置 Apache Karaf 4.0.3,以便将其与 JSF / Primefaces 一起使用。我已经用 Apache OpenWebBeans 和 JBoss Weld 尝试过,但每次尝试都以异常告终(见下文)。

我目前的设置:

一般的

src/main/webapp/WEB-INF/web.xml(剥离)

   <?xml version="1.0" encoding="UTF-8"?>
   <web-app version="3.0"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    ...

    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
        <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
    </resource-env-ref>

    ...
   </web-app>

pom.xml(剥离)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    ...

    <dependencies>
        <!-- OSGi -->
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- JSF -->
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.2.6</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <version>2.2.6</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <!-- CDI -->
        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-bundleutils</artifactId>
            <version>4.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-atinject_1.0_spec</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.ops4j.pax.cdi</groupId>
            <artifactId>pax-cdi-api</artifactId>
            <version>0.13.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.ops4j.pax.web</groupId>
            <artifactId>pax-web-jetty</artifactId>
            <version>4.2.3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.2.10.v20150310</version>
            <scope>provided</scope>
        </dependency>

        <!-- servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
...
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <archive>
                            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        </archive>
                        <attachClasses>true</attachClasses>
                        <classesClassifier>classes</classesClassifier>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <extensions>true</extensions>
                    <configuration>
                        <supportedProjectTypes>
                            <supportedProjectType>jar</supportedProjectType>
                            <supportedProjectType>bundle</supportedProjectType>
                            <supportedProjectType>war</supportedProjectType>
                        </supportedProjectTypes>

                        <instructions>
                            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Bundle-Activator>de.essendi.platform.ui.Activator</Bundle-Activator>
                            <Import-Package>
                                javax.el,
                                javax.annotation,
                                javax.faces.webapp,
                                javax.servlet.jsp;version="[2.2.0,3.0.0)",
                                javax.servlet.jsp.jstl.core;version="1.2",
                                javax.servlet.jsp.jstl.fmt;version="1.2",
                                javax.servlet.jsp.jstl.tlv;version="1.2",
                                javax.servlet;version="[2.6.0,4.0.0)",
                                javax.servlet.http;version="[2.6.0,4.0.0)",
                                org.apache.taglibs.standard.resources;version="1.1.2",
                                org.apache.taglibs.standard.tag.common.core;version="1.1.2",
                                org.apache.taglibs.standard.tag.rt.core;version="1.1.2",
                                org.apache.taglibs.standard.tei;version="1.1.2",
                                org.apache.taglibs.standard.tlv;version="1.1.2",
                                org.eclipse.jetty.cdi,
                                javax.faces.*,
                                javax.el.*,
                                org.apache.xbean.osgi.bundle.util.*,
                                org.apache.myfaces.webapp,
                                org.apache.myfaces.config,
                                org.apache.myfaces.config.impl,
                                org.apache.myfaces.config.impl.digester,
                                org.apache.myfaces.config.impl.digester.elements,
                                javassist.*,
                                org.eclipse.jetty.*,
                                org.primefaces.*,
                                org.osgi.framework,
                                org.slf4j; version="[1.7.0,1.8.0)"; provider=paxlogging
                            </Import-Package>
                            <Export-Package>!*</Export-Package>
                            <_wab>src/main/webapp/</_wab>
                            <Web-ContextPath>cert</Web-ContextPath>
                            <Webapp-Context>cert</Webapp-Context>
                            <Bundle-Classpath>WEB-INF/classes</Bundle-Classpath>
                            <Require-Bundle>
                                org.primefaces;visibility:=reexport
                            </Require-Bundle>
                            <Require-Capability>
                                org.ops4j.pax.cdi.extension; filter:="(&amp;(extension=pax-cdi-extension)(version&gt;=${version;==;${pax.cdi.osgi.version.clean}})(!(version&gt;=${version;=+;${pax.cdi.osgi.version.clean}})))",
                                osgi.extender; filter:="(osgi.extender=pax.cdi)"
                            </Require-Capability>
                            <Require-TldBundle>
                                org.primefaces,
                                org.ops4j.pax.cdi.jetty
                            </Require-TldBundle>
                            <_removeheaders>
                                Include-Resource,
                                Private-Package,
                                Embed-Dependency,
                                Embed-Transitive
                            </_removeheaders>
                        </instructions>
                    </configuration>
                    <executions>
                        <execution>
                            <id>versions</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>cleanVersions</goal>
                            </goals>
                            <configuration>
                                <versions>
                                    <pax.cdi.osgi.version.clean>0.13.0</pax.cdi.osgi.version.clean>
                                </versions>
                            </configuration>
                        </execution>
                        <execution>
                            <id>generate-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>

一般 CDI 功能/捆绑包

<bundle>mvn:org.apache.xbean/xbean-bundleutils/4.1</bundle>
<feature>pax-cdi</feature>

JBoss 焊接

附加依赖项

<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-core</artifactId>
    <version>1.2.0.Beta1</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.jboss.weld.servlet</groupId>
    <artifactId>weld-servlet-core</artifactId>
    <version>1.2.0.Beta1</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-cdi</artifactId>
    <version>9.2.10.v20150310</version>
    <scope>provided</scope>
</dependency>

额外的导入包

org.jboss.weld.environment.servlet.jsf,
org.jboss.weld.environment.servlet,
org.jboss.weld.environment.jetty,
org.jboss.weld.exceptions,
org.jboss.weld.bootstrap,
org.jboss.weld.resources,
org.jboss.weld.context,
org.jboss.weld.servlet,
org.jboss.weld.jsf,
org.jboss.weld.el,
org.jboss.weld.*,
javassist.*,
org.eclipse.jetty.cdi

src/main/webapp/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource name="BeanManager"
              auth="Container"
              type="javax.enterprise.inject.spi.BeanManager"
              factory="org.jboss.weld.resources.ManagerObjectFactory"/>
</Context>

CDI 功能/捆绑包

<bundle>wrap:mvn:org.javassist/javassist/3.14.0-GA</bundle>
<feature>pax-cdi-web-weld</feature>
<bundle>wrap:mvn:org.eclipse.jetty/jetty-cdi/9.2.10.v20150310</bundle>
<bundle>wrap:mvn:org.jboss.weld/weld-core/1.2.0.Beta1</bundle>
<bundle>wrap:mvn:org.jboss.weld.servlet/weld-servlet-core/1.2.0.Beta1</bundle>

OpenWebBeans

附加依赖项

没有任何

额外的导入包

org.apache.webbeans.servlet

src/main/webapp/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource name="BeanManager"
              auth="Container"
              type="javax.enterprise.inject.spi.BeanManager"
              factory="org.apache.webbeans.container.ManagerObjectFactory"/>
</Context>

CDI 功能/捆绑包

<feature>pax-cdi-openwebbeans</feature>
<feature>pax-cdi-web-openwebbeans</feature>
<bundle>mvn:org.apache.openwebbeans/openwebbeans-jsf/1.2.6</bundle>
<bundle>mvn:org.apache.openwebbeans/openwebbeans-el22/1.2.6</bundle>
<bundle>mvn:org.apache.openwebbeans/openwebbeans-web/1.2.6</bundle>

我对这些设置的问题

JBoss 焊接

使用 JBoss Weld,我目前遇到了 NoClassDefFoundError:

2016-01-14 15:53:15,418 | ERROR | pool-44-thread-1 | ClassUtils                       | 131 - org.apache.myfaces.core.impl - 2.2.6 | Class : org.jboss.weld.jsf.WeldPhaseListener not found.
java.lang.NoClassDefFoundError: org/jboss/weld/context/ConversationContext
        at java.lang.Class.getDeclaredConstructors0(Native Method)[:1.8.0_65]
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)[:1.8.0_65]
        at java.lang.Class.getConstructor0(Class.java:3075)[:1.8.0_65]
        at java.lang.Class.newInstance(Class.java:412)[:1.8.0_65]
        at org.apache.myfaces.shared.util.ClassUtils.newInstance(ClassUtils.java:411)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.shared.util.ClassUtils.newInstance(ClassUtils.java:403)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.shared.util.ClassUtils.newInstance(ClassUtils.java:379)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.config.FacesConfigurator.configureLifecycle(FacesConfigurator.java:1249)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:487)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:416)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:172)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:119)[131:org.apache.myfaces.core.impl:2.2.6]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$3.call(HttpServiceContext.java:338)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$3.call(HttpServiceContext.java:334)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.ops4j.pax.swissbox.core.ContextClassLoaderUtils.doWithClassLoader(ContextClassLoaderUtils.java:60)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.callContextInitialized(HttpServiceContext.java:333)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)[168:org.eclipse.jetty.server:9.2.10.v20150310]
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)[169:org.eclipse.jetty.servlet:9.2.10.v20150310]
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)[168:org.eclipse.jetty.server:9.2.10.v20150310]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:245)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)[171:org.eclipse.jetty.util:9.2.10.v20150310]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:258)[207:org.ops4j.pax.web.pax-web-jetty:4.2.3]
        at org.ops4j.pax.web.service.internal.HttpServiceStarted.end(HttpServiceStarted.java:1047)[209:org.ops4j.pax.web.pax-web-runtime:4.2.3]
        at org.ops4j.pax.web.service.internal.HttpServiceProxy.end(HttpServiceProxy.java:413)[209:org.ops4j.pax.web.pax-web-runtime:4.2.3]
        at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.end(RegisterWebAppVisitorWC.java:380)[205:org.ops4j.pax.web.pax-web-extender-war:4.2.3]
        at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:692)[205:org.ops4j.pax.web.pax-web-extender-war:4.2.3]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:237)[205:org.ops4j.pax.web.pax-web-extender-war:4.2.3]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:182)[205:org.ops4j.pax.web.pax-web-extender-war:4.2.3]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:135)[205:org.ops4j.pax.web.pax-web-extender-war:4.2.3]
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.Felix.registerService(Felix.java:3549)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:355)[org.apache.felix.framework-5.4.0.jar:]
        at org.ops4j.pax.cdi.web.CdiWebAppDependencyManager.register(CdiWebAppDependencyManager.java:63)[195:org.ops4j.pax.cdi.web:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.web.CdiWebAppDependencyManager.postCreate(CdiWebAppDependencyManager.java:88)[195:org.ops4j.pax.cdi.web:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.openwebbeans.impl.OpenWebBeansCdiContainerFactory.createContainer(OpenWebBeansCdiContainerFactory.java:66)[193:org.ops4j.pax.cdi.openwebbeans:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.extender.impl.CdiExtender.doCreateContainer(CdiExtender.java:144)[191:org.ops4j.pax.cdi.extender:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.extender.impl.CdiExtender.createContainer(CdiExtender.java:124)[191:org.ops4j.pax.cdi.extender:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.extender.impl.CdiExtender.addingBundle(CdiExtender.java:86)[191:org.ops4j.pax.cdi.extender:0.13.0.SNAPSHOT]
        at org.ops4j.pax.cdi.extender.impl.CdiExtender.addingBundle(CdiExtender.java:44)[191:org.ops4j.pax.cdi.extender:0.13.0.SNAPSHOT]
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)[org.osgi.core-6.0.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:916)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:835)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:517)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1189)[9:org.apache.karaf.features.core:4.0.3]
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:836)[9:org.apache.karaf.features.core:4.0.3]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.lang.ClassNotFoundException: org.jboss.weld.context.ConversationContext not found by wrap_file__D__mvn-repo_org_jboss_weld_weld-core_1.2.0.Beta1_weld-core-1.2.0.Beta1.jar [230]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)[org.apache.felix.framework-5.4.0.jar:]
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_65]
        ... 69 more

但是它正在寻找的类应该存在:

karaf@root()> package:exports | grep -i org.jboss.weld.context
...
org.jboss.weld.context    | 0.0.0            | 230 | wrap_file__D__mvn-repo_org_jboss_weld_weld-core_1.2.0.Beta1_weld-core-1.2.0.Beta1.jar
org.jboss.weld.context    | 1.0.0            | 184 | org.jboss.weld.osgi-bundle

它不冲突有点奇怪,因为两个库都导出了该包,但我不确定这是否是问题以及如何解决它是否应该是问题,因为在运行时似乎需要这两个库.

OpenWebBeans

使用 OpenWebBeans,我必须修补 PAX-CDI 的当前开发分支 (0.x)!让它运行,因为旧的 Jetty 版本(JettyDecorator 实现了旧式接口)。现在一切正常,但是一旦 JSF Page 试图访问 Bean,我就会得到这个异常:

2016-01-14 16:42:44,118 | WARN  | tp2011804352-187 | ServletHandler                   | 175 - org.eclipse.jetty.util - 9.2.10.v20150310 |
javax.servlet.ServletException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'loginController' resolved to null
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:230)[133:org.apache.myfaces.core.api:2.2.6]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)[173:org.eclipse.jetty.servlet:9.2.10.v20150310]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)[173:org.eclipse.jetty.servlet:9.2.10.v20150310]
        at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)[213:org.primefaces:5.3.0]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)[173:org.eclipse.jetty.servlet:9.2.10.v20150310]
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)[148:org.apache.shiro.web:1.2.4]
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112)[148:org.apache.shiro.web:1.2.4]
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)[148:org.apache.shiro.web:1.2.4]
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)[148:org.apache.shiro.web:1.2.4]...

我的豆子

...
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
...


@Named("loginController")
@RequestScoped
public class LoginController implements Serializable
{
    ...
}

所以问题是:

有人知道我的配置是否有问题吗?有人用 JSF 运行 Apache Karaf / CDI 设置吗?Karaf 和 (PAX-)CDI 是否存在任何已知问题?

我真的很感激任何帮助!

在此先感谢和亲切的问候法比安

4

1 回答 1

1

有针对 Pax-Web 与 JSF 和 CDI 的集成测试,因此理论上它应该可以工作。从堆栈跟踪看起来更像是 myfaces 包没有导入相关类。如果您可以创建一个用于测试的示例,那就太好了,因此可以将其添加到 Pax-Web 的集成测试中。实际上,带着这样的问题来到ops4jkaraf邮件列表要好得多。

于 2016-01-15T07:11:22.793 回答