PAX-CDI Sample4 JSF not working inside of Karaf

179 views
Skip to first unread message

Paul Spencer

unread,
Dec 20, 2014, 8:49:39 AM12/20/14
to op...@googlegroups.com
PAX-CDI 0.8.0 and 0.9.0
Karaf 3.0.2

I am having trouble getting the PAX-CDI Sample4 JSF to working inside of Karaf.  I do have the PAX-WEB War JSF Primefaces Sample working.  In both cases I change the required bundle to org.apache.myfaces.core.bundle.  Looking in the Karaf log, I noticed the httpService and httpContext are both null for PAX-CDI Sample4.  In the case of the PAX-WEB sample, both httpService and httpContext have not null values.  

2014-12-19 14:29:34,153 | DEBUG | l for user karaf | WebEventDispatcher               | 123 - org.ops4j.pax.web.pax-web-extender-war - 4.0.0 | Sending web event WebEvent [replay=false, type=DEPLOYING, bundle=pax-cdi-sample4-jsf [225], extenderBundle=org.ops4j.pax.web.pax-web-extender-war [123], cause=null, timestamp=1419017374153, contextPath=/sample4, collisionIds=null, httpService=null, httpContext=null] for bundle pax-cdi-sample4-jsf

I built pax-cdi-sample4-jsf with "mvn  clean package" and placed the jar files in Karaf's deploy directory.

***
* Below are the bundles and features installed:
***
karaf@root()> list
START LEVEL 100 , List Threshold: 50
ID | State     | Lvl | Version        | Name                                                                    
------------------------------------------------------------------------------------------------------------------
65 | Active    |  80 | 5.1.0          | primefaces                                                              
66 | Active    |  80 | 2.2.6          | Apache MyFaces JSF-2.2 Core OSGi Bundle                                 
161 | Active    |  80 | 1.3.0.5        | Apache ServiceMix :: Bundles :: commons-codec                           
162 | Active    |  80 | 1.8.0.4        | Apache ServiceMix :: Bundles :: commons-digester                        
163 | Active    |  80 | 1.0            | Apache Geronimo Java Contexts and Dependency Injection (JSR-299) Spec API
164 | Active    |  80 | 1.0            | Apache Geronimo JSR-330 Spec API                                        
165 | Active    |  80 | 1.0            | Interceptor 1.1                                                         
166 | Active    |  80 | 1.0.3          | Apache Geronimo Expression Language Spec 2.2                            
167 | Active    |  80 | 1.7.1          | OPS4J Pax Swissbox :: Tracker                                           
168 | Active    |  80 | 1.7.1          | OPS4J Pax Swissbox :: Lifecycle                                         
169 | Active    |  80 | 1.7.1          | OPS4J Pax Swissbox :: Extender                                          
170 | Active    |  80 | 1.7.1          | OPS4J Pax Swissbox :: OSGi Core                                         
171 | Active    |  80 | 1.4.0          | OPS4J Base - Service Provider Access                                    
172 | Active    |  80 | 1.4.0          | OPS4J Base - Lang                                                       
173 | Active    |  80 | 3.18.0         | Apache XBean OSGI Bundle Utilities                                      
182 | Resolved  |  80 | 1.8.3.2        | Apache ServiceMix :: Bundles :: commons-beanutils                       
183 | Resolved  |  80 | 3.2.1.3        | Apache ServiceMix :: Bundles :: commons-collections                     
184 | Active    |  80 | 9.2.3.410      | iijdbc                                                                  
185 | Active    |  80 | 0.0.0          | mikon-ds.xml                                                            
188 | Active    |  80 | 1.6.0          | Commons Pool                                                            
189 | Active    |  80 | 1.4            | Commons DBCP                                                            
190 | Active    |  80 | 3.0.2          | Apache Karaf :: JDBC :: Core                                            
191 | Active    |  80 | 3.0.2          | Apache Karaf :: JDBC :: Command                                         
192 | Active    |  80 | 4.0.1.SNAPSHOT | OPS4J Pax Web - Samples - WAR Extender - JSF                            
202 | Installed |  80 | 1.2.6          | OSGi plugin                                                             
215 | Resolved  |  80 | 1.1            | Apache Geronimo JSR-303 Bean Validation Spec API                        
216 | Active    |  80 | 1.8.0          | OPS4J Pax Swissbox :: Tracker                                           
217 | Active    |  80 | 1.8.0          | OPS4J Pax Swissbox :: Lifecycle                                         
218 | Active    |  80 | 1.8.0          | OPS4J Pax Swissbox :: Extender                                          
219 | Active    |  80 | 1.8.0          | OPS4J Pax Swissbox :: OSGi Core                                         
220 | Active    |  80 | 1.5.0          | OPS4J Base - All                                                        
221 | Active    |  80 | 0.9.0          | OPS4J Pax CDI Bean Bundle API                                           
222 | Active    |  80 | 0.9.0          | OPS4J Pax CDI Service Provider Interface                                
223 | Active    |  80 | 0.9.0          | OPS4J Pax CDI Portable Extension for OSGi                               
224 | Active    |  80 | 0.9.0          | OPS4J Pax CDI Extender for Bean Bundles                                 
225 | Active    |  80 | 0.9.0          | OPS4J Pax CDI Sample4 JSF WAB                                           
karaf@root()> feature:list -i
Name                 | Version         | Installed | Repository              | Description                                 
---------------------------------------------------------------------------------------------------------------------------------
transaction          | 1.1.0           | x         | enterprise-3.0.2        | OSGi Transaction Manager                    
jdbc                 | 3.0.2           | x         | enterprise-3.0.2        | JDBC service and commands                   
openwebbeans         | 1.2.6           | x         | enterprise-3.0.2        | Apache OpenWebBeans CDI container support   
standard             | 3.0.2           | x         | standard-3.0.2          | Karaf standard feature                      
config               | 3.0.2           | x         | standard-3.0.2          | Provide OSGi ConfigAdmin support            
region               | 3.0.2           | x         | standard-3.0.2          | Provide Region Support                      
package              | 3.0.2           | x         | standard-3.0.2          | Package commands and mbeans                 
http                 | 3.0.2           | x         | standard-3.0.2          | Implementation of the OSGI HTTP Service     
kar                  | 3.0.2           | x         | standard-3.0.2          | Provide KAR (KARaf archive) support         
ssh                  | 3.0.2           | x         | standard-3.0.2          | Provide a SSHd server on Karaf              
management           | 3.0.2           | x         | standard-3.0.2          | Provide a JMX MBeanServer and a set of MBeans in K
scr                  | 3.0.2           | x         | standard-3.0.2          | Declarative Service support                 
cxf-specs            | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-core             | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-wsdl             | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-http             | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-bindings-soap    | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-jaxws            | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
cxf-databinding-jaxb | 3.1.0-SNAPSHOT  | x         | cxf-3.1.0-SNAPSHOT      |                                             
pax-cdi              | 0.9.0           | x         | org.ops4j.pax.cdi-0.9.0 | Provide CDI support                         
pax-jetty            | 9.0.7.v20131107 | x         | org.ops4j.pax.web-4.0.0 | Provide Jetty engine support                
pax-http             | 4.0.0           | x         | org.ops4j.pax.web-4.0.0 | Implementation of the OSGI HTTP Service     
pax-http-whiteboard  | 4.0.0           | x         | org.ops4j.pax.web-4.0.0 | Provide HTTP Whiteboard pattern support     
pax-war              | 4.0.0           | x         | org.ops4j.pax.web-4.0.0 | Provide support of a full WebContainer      
karaf@root()>


Paul Spencer

Paul Spencer

unread,
Dec 20, 2014, 12:30:57 PM12/20/14
to op...@googlegroups.com
I have made some progress.  Pages are now displayed, but the CDI beans are not working. Specifically the line "Your choice: " is not displayed after clicking "Vote"

Summary of changes in the attached patch:
- Change packing to "war" and added <supportedProjectType>
- Added <Pax-ManagedBeans>
- Added various Import-Packages
- Changed Require-Bundle to include MyFaces and Primefaces
- Added Bundle-Classpath
- Remove Require-TldBundle and Require-Capability
- Added maven-war-plugin manifest configuration
- Uncommented the servlet configuration in web.xml and added MyFaces startup listener.

With all of the above changes, it does not appear that #{framework.name} is changed when "Vote" is clicked.  Why?

Paul Spencer
patch.txt

Paul Spencer

unread,
Dec 21, 2014, 11:45:32 PM12/21/14
to op...@googlegroups.com
I am making progress
- Enabled the webbeans listener in web.xml
- Added openwebbeans to the Required-Bundle.  See a diff of pom.xml below.

Now getting "javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread" when opening page /sample4/poll.jsf.  Stack trace is below.

Any idea why I am getting the error?

***
* Stack Trace
***
2014-12-21 23:35:50,699 | WARN  | sample4/poll.jsf | ServletHandler                   | 105 - org.eclipse.jetty.util - 9.0.7.v20131107 |
javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:230)[66:org.apache.myfaces.core.bundle:2.2.6]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:696)[103:org.eclipse.jetty.servlet:9.0.7.v20131107]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:521)[103:org.eclipse.jetty.servlet:9.0.7.v20131107]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:69)[119:org.ops4j.pax.web.pax-web-jetty:4.0.0]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)[101:org.eclipse.jetty.security:9.0.7.v20131107]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1097)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:239)[119:org.ops4j.pax.web.pax-web-jetty:4.0.0]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:448)[103:org.eclipse.jetty.servlet:9.0.7.v20131107]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1031)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[119:org.ops4j.pax.web.pax-web-jetty:4.0.0]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.Server.handle(Server.java:446)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:271)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:246)[102:org.eclipse.jetty.server:9.0.7.v20131107]
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)[95:org.eclipse.jetty.io:9.0.7.v20131107]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)[105:org.eclipse.jetty.util:9.0.7.v20131107]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)[105:org.eclipse.jetty.util:9.0.7.v20131107]
    at java.lang.Thread.run(Thread.java:724)[:1.7.0_25]
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
    at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:330)[235:openwebbeans-impl:1.2.6]
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88)[235:openwebbeans-impl:1.2.6]
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)[235:openwebbeans-impl:1.2.6]
    at org.apache.webbeans.conversation.ConversationImpl$$OwbNormalScopeProxy0.isTransient(org/apache/webbeans/conversation/ConversationImpl.java)[235:openwebbeans-impl:1.2.6]
    at org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:108)[243:openwebbeans-jsf:1.2.6]
    at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77)[66:org.apache.myfaces.core.bundle:2.2.6]
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:184)[66:org.apache.myfaces.core.bundle:2.2.6]
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)[66:org.apache.myfaces.core.bundle:2.2.6]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)[66:org.apache.myfaces.core.bundle:2.2.6]
    ... 21 more

***
* Diff of pom.xml
***
diff --git a/pax-cdi-samples/pax-cdi-sample4-jsf/pom.xml b/pax-cdi-samples/pax-cdi-sample4-jsf/pom.xml
index 9759ed8..4ab3990 100644
--- a/pax-cdi-samples/pax-cdi-sample4-jsf/pom.xml
+++ b/pax-cdi-samples/pax-cdi-sample4-jsf/pom.xml
@@ -7,7 +7,7 @@
     </parent>
     <groupId>org.ops4j.pax.cdi.samples</groupId>
     <artifactId>pax-cdi-sample4-jsf</artifactId>
-    <packaging>bundle</packaging>
+    <packaging>war</packaging>
 
     <name>OPS4J Pax CDI Sample4 JSF WAB</name>
 
@@ -60,23 +60,42 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
                 <configuration>
+                   <supportedProjectTypes>
+                        <supportedProjectType>jar</supportedProjectType>
+                        <supportedProjectType>bundle</supportedProjectType>
+                        <supportedProjectType>war</supportedProjectType>
+                    </supportedProjectTypes>
                     <instructions>
-                        <_wab>src/main/webapp/</_wab>
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                         <Bundle-Version>${project.version}</Bundle-Version>
                         <Web-ContextPath>/sample4</Web-ContextPath>
+                        <Pax-ManagedBeans>WEB-INF/beans.xml</Pax-ManagedBeans>
                         <Import-Package>
                             javax.annotation,
-                            javax.servlet;version="[3.0,4.0)",
+                            javax.servlet;version="[3.0,4.0)",
                             *
                         </Import-Package>
                         <Require-Bundle>
-                            org.glassfish.javax.faces
+                            openwebbeans-spi,
+                            openwebbeans-impl,
+                            openwebbeans-web,
+                            openwebbeans-jsf,
+                            openwebbeans-el22,
+                            org.ops4j.pax.cdi.openwebbeans,
+                            org.ops4j.pax.cdi.web,
+                            org.ops4j.pax.cdi.web.openwebbeans,
+                            org.apache.myfaces.core.bundle,
+                            org.primefaces;visibility:=reexport
                         </Require-Bundle>
                         <Require-TldBundle>org.primefaces, org.ops4j.pax.cdi.jetty</Require-TldBundle>
                         <Require-Capability>
-                            org.ops4j.pax.cdi.extension; filter:="(&amp;(extension=pax-cdi-extension)(version&gt;=${version;==;${
+                            org.ops4j.pax.cdi.extension;extension=pax-cdi-extension;version:version=0.9.0,
+                            osgi.extender;osgi.extender=pax.cdi;version:version=0.9.0,
+                            org.ops4j.pax.cdi.extension;extension=deltaspike-core-impl
+<!--
+                            org.ops4j.pax.cdi.extension; filter:="(&amp;(extension=pax-cdi-extension)(version&gt;=${version;==;${
                             osgi.extender; filter:="(osgi.extender=pax.cdi)"
+-->
                         </Require-Capability>
                     </instructions>
                 </configuration>
@@ -102,6 +121,14 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+                    </archive>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>

Paul Spencer


Reply all
Reply to author
Forward
0 new messages