[JBoss Portal] - PROBLEM: Cannot find FacesContext while accessing the page w
by pawel.j.radecki@gmail.com
Hi there,
When I hit my JSF application (URL: http://localhost:8080/myapp/index.jsf) deployed to Jboss-portal I get Exception below.
My environment:
+ jboss-portal-2.6.2.GA
+ jdk1.6.0_03
+ Windows XP
2008-01-01 12:51:30,703 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/myapp].[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.RuntimeException: Cannot find FacesContext
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1796)
My faces-config.xml:
------------------------
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>SampleBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>bean2</managed-bean-name>
<managed-bean-class>SampleBean2</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
My web.xml:
--------------
<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>a4jEchoText</display-name>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
REQUEST
FORWARD
INCLUDE
</filter-mapping>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
<!-- Faces Servlet -->
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>-1</load-on-startup>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
Any ideas why is this exception thrown...?
Looking forward to any answer.
Thanks in advance!
--
Pawe? Radecki
e: pawel.j.radecki(a)gmail.com
w: http://radeckimarch.blogspot.com/
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116287#4116287
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116287
17 years, 2 months
[JBoss/Spring Integration] - Re: Jboss 5 Beta 3 and Spring Deployer
by ragavgomatam
Thanks Ales...That explains it....So then I have my EAR file with ejb3.jar (ejb3 module) and spring-inject.jar (spring module) and ejb3.war (web-module) .
I also have my ejb 3 as :-
package com.ejb3.beans;
|
| import static javax.ejb.TransactionAttributeType.REQUIRED;
|
| import javax.ejb.Stateful;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.EJB;
| import javax.annotation.PostConstruct;
| import javax.annotation.Resource;
| import javax.interceptor.ExcludeDefaultInterceptors;
| import javax.sql.DataSource;
| import javax.annotation.PreDestroy;
|
| import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
| import org.jboss.annotation.spring.Spring;
|
| import com.ejb3.domain.IPerson;
| import com.ejb3.interfaces.Calculator;
| import com.ejb3.interfaces.SayHello;
|
| /**
| * @author Ragav
| *
| */
|
| @Stateful
| @TransactionAttribute(REQUIRED)
| @ExcludeDefaultInterceptors
| public class SayHelloBean extends SimpleJdbcDaoSupport implements SayHello {
|
| @Resource(name = "jdbc/TestDs", type = DataSource.class, shareable = true, mappedName = "java:jdbc/OracleDS")
| private DataSource ds;
|
| @EJB(beanName = "CalculatorBean")
| private Calculator calculator;
|
| @Resource(name = "sqlForEjb")
| private String sql;
|
| @Spring(jndiName = "spring-inject", bean = "person")
| private IPerson p;
|
| public String sayHelloWithEjb3DI() {
| return "Testing ejb3 DI & your age is "
| + getSimpleJdbcTemplate().queryForInt(sql);
| }
|
| public double calulate() {
| return calculator.calculate(2, 3);
| }
|
| @PostConstruct
| public void init() {
| setDataSource(ds);
| }
|
| @PreDestroy
| public void callThis() {
| System.out.println("Invoking method: preDestroy()");
| }
|
| public IPerson getPerson() {
| return this.p;
| }
|
| }
|
But it appears that annotation @Spring(jndiName = "spring-inject", bean = "person") does not work since the jndiName "spring-inject" is not bound.
This is the error I get :
20:13:40,609 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [/home,ejbLocalIntf]; root of BeanFactory hierarchy]
20:13:40,844 ERROR [STDERR] java.lang.RuntimeException: javax.naming.NameNotFoundException: spring-inject not bound
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:727)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.createBeanContext(StatefulContainer.java:103)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.pool.AbstractPool.createBeanContext(AbstractPool.java:130)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:79)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:58)
20:13:40,844 ERROR [STDERR] at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:113)
If you see, it says that the name "spring-inject" (name of my spring archive within my EAR ) is not bound to jndi.
My application.xml is as follows :-
<application xmlns="http://java.sun.com/xml/ns/javaee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
| http://java.sun.com/xml/ns/javaee/application_5.xsd"
| version="5">
| <description>Test ejb3 j2ee 5 application</description>
| <display-name>Ejb3</display-name>
| <module>
| <web>
| <web-uri>Ejb3.war</web-uri>
| <context-root>ejb3</context-root>
| </web>
| </module>
| <module>
| <ejb>Ejb3.jar</ejb>
| </module>
| <module>
| <java>spring-inject.jar</java>
| </module>
| </application>
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116282#4116282
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116282
17 years, 2 months