SessionContext in JSF Controller class

Hello,
I want to access a EJB session bean from a JSF managed bean. I wrote this code for the JSF managed bean:
public class MyController {
@Resource
private SessionContext sc;
Unfortunately, the SessionContext is always null, when I deploy this to Glassfish. How should this be done?
Many thanks in advance,
Ulrich

I know this thread is old, but I'm having the same problem. Actually, I get an error when the container attempts to inject the SessionContext. Is this possible? I need to do this because I have to include a class in the current JTA
pService = sessionCTX.getBusinessObject(MyClass.class);Here is the error:
JSF1001: Managedbean DPRAdminController could not be created.
executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@75b962) threw exception
javax.faces.FacesException: javax.faces.FacesException: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:1553)
        at com.sun.faces.renderkit.RenderKitUtils.renderXHTMLStyleBooleanAttributes(RenderKitUtils.java:530)
        at com.sun.faces.renderkit.RenderKitUtils.renderXHTMLStyleBooleanAttributes(RenderKitUtils.java:492)
        at com.sun.faces.renderkit.html_basic.ButtonRenderer.encodeBegin(ButtonRenderer.java:177)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
        at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
        at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:245)
        at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:176)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
        at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:361)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: javax.faces.FacesException: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:519)
        at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
        at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
        at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:86)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:127)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
        at javax.faces.component.html.HtmlCommandButton.isDisabled(HtmlCommandButton.java:161)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:1545)
        ... 47 more
Caused by: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:340)
        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:509)
        ... 59 more
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
        at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
        at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
        at com.sun.faces.vendor.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:79)
        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:298)
        ... 60 more
Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/com.mypack.dpr.jsf.DPRAdminController/sessionCTX [Root exception is java.lang.IllegalStateException: Illegal invocation type for EJB Context : 0]
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:287)
        ... 64 more
Caused by: java.lang.IllegalStateException: Illegal invocation type for EJB Context : 0
        at com.sun.ejb.containers.ContainerFactoryImpl.getEJBContextObject(ContainerFactoryImpl.java:836)
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:965)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
        ... 67 more
StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:519)
        at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
        at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
        at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:86)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:127)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
        at javax.faces.component.html.HtmlCommandButton.isDisabled(HtmlCommandButton.java:161)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:1545)
        at com.sun.faces.renderkit.RenderKitUtils.renderXHTMLStyleBooleanAttributes(RenderKitUtils.java:530)
        at com.sun.faces.renderkit.RenderKitUtils.renderXHTMLStyleBooleanAttributes(RenderKitUtils.java:492)
        at com.sun.faces.renderkit.html_basic.ButtonRenderer.encodeBegin(ButtonRenderer.java:177)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
        at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
        at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:245)
        at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:176)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
        at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:361)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:340)
        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:509)
        ... 59 more
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: com.mypack.dpr.jsf.DPRAdminController/sessionCTX@Field-Injectable Resource. Class name = com.mypack.dpr.jsf.DPRAdminController Field [email protected]@com.mypack.dpr.jsf.DPRAdminController/sessionCTX@@ into class com.mypack.dpr.jsf.DPRAdminController
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
        at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
        at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
        at com.sun.faces.vendor.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:79)
        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:298)
        ... 60 more
Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/com.mypack.dpr.jsf.DPRAdminController/sessionCTX [Root exception is java.lang.IllegalStateException: Illegal invocation type for EJB Context : 0]
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:287)
        ... 64 more
Caused by: java.lang.IllegalStateException: Illegal invocation type for EJB Context : 0
        at com.sun.ejb.containers.ContainerFactoryImpl.getEJBContextObject(ContainerFactoryImpl.java:836)
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:965)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
        ... 67 more

Similar Messages

  • Invoking a WLI 9.2 business process from JSF Controller class

    I want to call a WLI business process from a java class, which will run in the same JVM as the WLI. I have read that JPD Proxy can be used for this purpose. I am concerned with the overhead of RMI calls. Any insight into this would be helpful .

    Hi Raj
    You have to use JPDproxy to call a business process from a java class. This is what BEA also recommends at http://e-docs.bea.com/workshop/docs81/doc/en/integration/howdoI/howProxyJavaClient.html as this is the only way to call a JPD from plain java class.
    Many customers use this and even if there is, the overhead should not be substantial.
    You may also want to try posting in the WLI newsgroup at http://forums.bea.com/bea/forum.jspa?forumID=2047
    Vimala-

  • Controller Class: Search functionality.

    Hello,
    Here is a snapshot of the Controller class what NetBeans have created by default which interacts with the entity class. I need to add a search functionality to this bean which a JSF search form can utilize. Can anyone help me out to add without breaking it's structure.
    public class ProductController {
        private Product product = null;
        private List<Product> products = null;
        @Resource
        private UserTransaction utx = null;
        @PersistenceUnit(unitName = "ExApp")
        private EntityManagerFactory emf = null;
        public EntityManager getEntityManager() {
            return emf.createEntityManager();
        public int batchSize = 15;
        private int firstItem = 0;
        private int itemCount = -1;
        public SelectItem[] getProductsAvailableSelectMany() {
            return getProductsAvailable(false);
        public SelectItem[] getProductsAvailableSelectOne() {
            return getProductsAvailable(true);
        private SelectItem[] getProductsAvailable(boolean one) {
            List<Product> allProducts = getProducts(true);
            int size = one ? allProducts.size() + 1 : allProducts.size();
            SelectItem[] items = new SelectItem[size];
            int i = 0;
            if (one) {
                items[0] = new SelectItem("", "---");
                i++;
            for (Product x : allProducts) {
                items[i++] = new SelectItem(x, x.toString());
            return items;
        public Product getProduct() {
            if (product == null) {
                product = getProductFromRequest();
            if (product == null) {
                product = new Product();
            return product;
        public String listSetup() {
            reset(true);
            return "product_list";
        public String createSetup() {
            reset(false);
            product = new Product();
            return "product_create";
        public String searchSetup() {
            reset(false);
            product = new Product();
            return "product_search";
        public String create() {
            EntityManager em = getEntityManager();
            try {
                utx.begin();
                em.persist(product);
                utx.commit();
                addSuccessMessage("Product was successfully created.");
            } catch (Exception ex) {
                try {
                    if (findProduct(product.getId()) != null) {
                        addErrorMessage("Product " + product + " already exists.");
                    } else {
                        ensureAddErrorMessage(ex, "A persistence error occurred.");
                    utx.rollback();
                } catch (Exception e) {
                    ensureAddErrorMessage(e, "An error occurred attempting to roll back the transaction.");
                return null;
            } finally {
                em.close();
            return listSetup();
        public String detailSetup() {
            return scalarSetup("product_detail");
        public String editSetup() {
            return scalarSetup("product_edit");
        private String scalarSetup(String destination) {
            reset(false);
            product = getProductFromRequest();
            if (product == null) {
                String requestProductString = getRequestParameter("jsfcrud.currentProduct");
                addErrorMessage("The product with id " + requestProductString + " no longer exists.");
                String relatedControllerOutcome = relatedControllerOutcome();
                if (relatedControllerOutcome != null) {
                    return relatedControllerOutcome;
                return listSetup();
            return destination;
      private Product getProductFromRequest() {
            String theId = getRequestParameter("jsfcrud.currentProduct");
            return (Product) new ProductConverter().getAsObject(FacesContext.getCurrentInstance(), null, theId);
        private String getRequestParameter(String key) {
            return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(key);
        public List<Product> getProducts() {
            if (products == null) {
                products = getProducts(false);
            return products;
        public List<Product> getProducts(boolean all) {
            EntityManager em = getEntityManager();
            try {
                Query q = em.createQuery("select object(o) from Product as o");
                if (!all) {
                    q.setMaxResults(batchSize);
                    q.setFirstResult(getFirstItem());
                return q.getResultList();
            } finally {
                em.close();
        private void ensureAddErrorMessage(Exception ex, String defaultMsg) {
            String msg = ex.getLocalizedMessage();
            if (msg != null && msg.length() > 0) {
                addErrorMessage(msg);
            } else {
                addErrorMessage(defaultMsg);
        public static void addErrorMessage(String msg) {
            FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
            FacesContext.getCurrentInstance().addMessage(null, facesMsg);
        public static void addSuccessMessage(String msg) {
            FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
            FacesContext.getCurrentInstance().addMessage("successInfo", facesMsg);
        public Product findProduct(Integer id) {
            EntityManager em = getEntityManager();
            try {
                Product o = (Product) em.find(Product.class, id);
                return o;
            } finally {
                em.close();
        public int getItemCount() {
            if (itemCount == -1) {
                EntityManager em = getEntityManager();
                try {
                    itemCount = ((Long) em.createQuery("select count(o) from Product as o").getSingleResult()).intValue();
                } finally {
                    em.close();
            return itemCount;
        public int getFirstItem() {
            getItemCount();
            if (firstItem >= itemCount) {
                if (itemCount == 0) {
                    firstItem = 0;
                } else {
                    int zeroBasedItemCount = itemCount - 1;
                    double pageDouble = zeroBasedItemCount / batchSize;
                    int page = (int) Math.floor(pageDouble);
                    firstItem = page * batchSize;
            return firstItem;
        public int getLastItem() {
            getFirstItem();
            return firstItem + batchSize > itemCount ? itemCount : firstItem + batchSize;
        public int getBatchSize() {
            return batchSize;
        public String next() {
            reset(false);
            getFirstItem();
            if (firstItem + batchSize < itemCount) {
                firstItem += batchSize;
            return "product_list";
        public String prev() {
            reset(false);
            getFirstItem();
            firstItem -= batchSize;
            if (firstItem < 0) {
                firstItem = 0;
            return "product_list";
        private String relatedControllerOutcome() {
            String relatedControllerString = getRequestParameter("jsfcrud.relatedController");
            String relatedControllerTypeString = getRequestParameter("jsfcrud.relatedControllerType");
            if (relatedControllerString != null && relatedControllerTypeString != null) {
                FacesContext context = FacesContext.getCurrentInstance();
                Object relatedController = context.getApplication().getELResolver().getValue(context.getELContext(), null, relatedControllerString);
                try {
                    Class<?> relatedControllerType = Class.forName(relatedControllerTypeString);
                    Method detailSetupMethod = relatedControllerType.getMethod("detailSetup");
                    return (String) detailSetupMethod.invoke(relatedController);
                } catch (ClassNotFoundException e) {
                    throw new FacesException(e);
                } catch (NoSuchMethodException e) {
                    throw new FacesException(e);
                } catch (IllegalAccessException e) {
                    throw new FacesException(e);
                } catch (InvocationTargetException e) {
                    throw new FacesException(e);
            return null;
        private void reset(boolean resetFirstItem) {
            product = null;
            products = null;
            itemCount = -1;
            if (resetFirstItem) {
                firstItem = 0;
        private Map<Object, String> asString = null;
        public Map<Object, String> getAsString() {
            if (asString == null) {
                asString = new HashMap<Object, String>() {
                    @Override
                    public String get(Object key) {
                        if (key instanceof Object[]) {
                            Object[] keyAsArray = (Object[]) key;
                            if (keyAsArray.length == 0) {
                                return "(No Items)";
                            StringBuffer sb = new StringBuffer();
                            for (int i = 0; i < keyAsArray.length; i++) {
                                if (i > 0) {
                                    sb.append("<br />");
                                sb.append(keyAsArray);
    return sb.toString();
    return new ProductConverter().getAsString(FacesContext.getCurrentInstance(), null, (Product) key);
    return asString;
    Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Can you tell us what "not working" means? Can you give us some more detail to try and narrow down the problem? Also you say the search works on your local machine. Have you tried running the help from the generated / published location yourself?

  • Error while extending controller: class name is wrong or not included

    Hi All,
    I am getting this error while I port my extended controller class to the custom top and assign this controller to the page. I have made sure its the class file that is copied. The directory is correct, the permissions were given using chmod 775. There exists a soft link betwen the custom top and the oracle top as well. What else am I missing here?
    Error: oracle.apps.fnd.framework.OAException: Could not create Java class: (oracle.apps.ap.oie.entry.webui.XXEntryFlowPageCO) associated with region: (GeneralInformationPG). This is probably because the class name is wrong or not included in project.

    :( Started out with that Gyan. If i do give the path with xx. appended to it, it lets me save and when i log back in and there are no changes to the page. I go to the personalise option to find the modification has been overwritten. I was told that this is so because Oracle doesnt recognise the xx.path and since there exists a soft link already the standard path with the new controller name should work.
    i have really tried both of these options and am not sure what could be wrong. thanks for all your attempts to help. anything else i can try?

  • How to get the parent window in sub-child controller class in javafx?

    how to get the parent window in sub-child controller class in javafx?

    You can get the window in which a node is contained with
    Window window = node.getScene().getWindow();Depending when this is invoked, you might want to check the Scene is not null before calling getWindow().
    If the window is a stage that is owned by another window, you can get the "parent" or "owner" window with
    Window owner = null ;
    if (window instanceof Stage) {
      Stage stage = (Stage) window ;
      owner = stage.getOwner();
    }

  • How to retrieve content from DAO Class and process in Controller Class?

    Hello
    This is for the experts.
    What is the best approach to passing a large set of data from Class A to Class B? I have a DAO Class that connects to a database to retrieve data. I tried saving the data in a collection (map) and passing the collection to Class B. The problem here is that the data is may be too large for a collection without increasing the heap size, it could cause out of memory exception. Instead I'd like to pass the data (row by row) on to the "Controller" Class where which will process each row. I am not sure how to do this without using a collection or some sort. Some tips will be much appreciated.
    Note: MVC Rules dictates that Controller cannot call the DAO Class directly, it has to go through the Model which talks directly with the DAO Class.
    Thanks
    Edited by: 875864 on 30-Oct-2011 15:05

    875864 wrote:
    Hello
    This is for the experts.
    What is the best approach to passing a large set of data from Class A to Class B? I have a DAO Class that connects to a database to retrieve data. I tried saving the data in a collection (map) and passing the collection to Class B. The problem here is that the data is may be too large for a collection without increasing the heap size, it could cause out of memory exception. Instead I'd like to pass the data (row by row) on to the "Controller" Class where which will process each row. I am not sure how to do this without using a collection or some sort. Some tips will be much appreciated.
    Note: MVC Rules dictates that Controller cannot call the DAO Class directly, it has to go through the Model which talks directly with the DAO Class.
    Thanks
    Edited by: 875864 on 30-Oct-2011 15:05if its a large set of data, and is fetched from DB and you are sure that it is too large and chances of getting out of memory exception then why you are passing it over request.
    If the data is fetched based on some filter criteria, then just pass the filter criteria from class A to class B, and fetch the data from DB based on the filter criteria in class B.

  • How to get the function name in controller class

    Hi experts ,
    I am new to the OAF framework.
    i have created the two functions and bot he the function have the same controller class .i want to capture the function name or function id in the controller class.
    can you please let me know how to get the function id or function name in the controller class.

    Hi apurba,
    Thanks for the quick reply.
    i am trying to get the function name from the FunctionSecurity class,
    However in FunctionSecurity class there is no such method defined as getFunctionName();
    my requirement is ,i have two functions functionA and functionB defined.
    both the function has the same controller class.in controller class ,i need to get the function name ,based on the function name
    i will redirect the page to respective page.
    looking forward for you response.
    appreciate your help
    Thanks,
    KT

  • How to Find Controller class of  BSP application for particular Iview

    Hi  All,
    Any one please  help me  to find a Controlller class of BSP for an  I view.
    http://Host Name :Port No/sap/bc/gui/sap/its/wosm-cr-->this is for sap retail,
    My requirement  is to change some source code in that particular iview.
    i goine with SE80 Tcode
    with package called WOSM>ITS service>Topic 90-->which contain Mime Objects,Html Templates.
    but i dint find any
    Point will be given!!!

    Hi All,
    My question is where should i find Controller class ?
    i gone with Tcode  SE80>packages>WOST>ITS service>WOSM>Topic90>which contain Mime Objects,HTML Templates.
    i dint find any controller class.
    regards
    Naresh

  • Deploying the extended controller class file on server

    Hi OAF Experts,
    I am working on the already extended controller file.
    I have made the changes and was able to comiple the controller class file.
    I have one uestion for you. Now to put the class file on the server i am following the below steps:
    1) Putting the new class file on the server where it is already present. This is done using Unix commands
    2) Bouncing the server.
    I hope this will reflect the new changes. Is there any thing else i need to do?
    Thanks,
    Samarth

    Hi,
    Yes. These are only required steps to reflect the changes.
    --Sushant                                                                                                                                                                                   

  • How to Use JavaScript in Controller Class...

    Hi All,
    Can any one tell me how to use JavaScript in Controller Class.
    Requirement is:
    I have
    Radio Group(RG1),
    Two Radio Buttons(RB1,RB2),
    Two messageTextInput(MTI1,MTI2),
    if i click RB1 i should Prompt to the end user to "Enter value for MTI1" or
    If i click RB2 i should prompt "Enter value for MTI2" while submitting page.
    Please let me know the steps to use JavaScript and the above client validation...
    Regards
    Alem...

    Using javascript is against the standard. I can tell you a workaround instead of you setting the javascript, check if that would be acceptable.
    You can use PPR and set the required property on the messageTextInput on clicking of the radio button. By doing this you will let UIX generate the javascript for you to handle the client side validation. But the validation will happen only on click of the submit button. The visual indicator is good enough to tell that the value has to be entered to the item.

  • Custom page controller class

    Hello,
    I'm trying to implement what is explained in the article *"Two Ideas to Handle JBO-35007 'Row Currency Changed' Exception"* (http://blogs.oracle.com/smuenchadf/examples/). This example illustrates how to use a custom page controller class to override the handleError() method to conditionally handle the JBO-35007 exception ('Row currency has changed since the user interface was rendered.') in a way that might be more useful to the end-user.
    So I've defined a custom page controller class in a JSP of my application, but I don't know why the application flow is not passing through the handleError method when a JBO-35007 exception occurs.
    I've defined well in the pagedef the attribute "ControllerClass", and I use the "back button" to produce the JBO-35007 exception. But I don't know why the method handleError is not executed, although the the JBO-35007 exception is displayed.
    Thank you very much.

    Hi,
    you are on JDeveloper 11g ? The article you follow was written for 10.1.3. In 11g the error handling is configured in DataBindings.cpx page. Select the DataBindings.cpx page in the Application Navigator and select its root node in the Structure Window. Then open the Property Inspector to configure your version of the Error Handler class
    Frank

  • How do i set the contentStyle of textbox in my controller class on pageload

    Hi All,
    I have a requirement where i need to set the contentStyle of a textbox as well as the border of textbox as per condition on page load.
    I am trying this code but unable to set it properly.
    *public void onLoad() {*
    FacesContext context = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks =
    Service.getRenderKitService(context, ExtendedRenderKitService.class);
    erks.addScript(context,"AdfPage.PAGE.findComponent('it15').setProperty('ContentStyle',background-color:#00C0C0);");
    Am i missing something ??
    Is there any other method to achieve my requirement ?
    Please suggest!!
    Thanks!!

    Hi Accadsoft,
    I have tried with this but nothing happens :-
    I have used this code in my controller class :-
    FacesContext context = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks =
    Service.getRenderKitService(context, ExtendedRenderKitService.class);
    erks.addScript(context,"AdfPage.PAGE.findComponentByAbsoluteId('it3').setProperty('ContentStyle',background-color:#00C0C0);");
    Please find the below Jspx code snippet as well...:-
    <af:form id="f1"
    binding="#{backingBeanScope.backing_TimeCostedInvoices.f1}">
    <af:panelFormLayout binding="#{backingBeanScope.backing_TimeCostedInvoices.pfl1}"
    id="pfl1" maxColumns="3" rows="1">
    <af:inputText value="#{bindings.Totalamount.inputValue}"
    label="#{bindings.Totalamount.hints.label}"
    required="#{bindings.Totalamount.hints.mandatory}"
    columns="#{bindings.Totalamount.hints.displayWidth}"
    maximumLength="#{bindings.Totalamount.hints.precision}"
    shortDesc="#{bindings.Totalamount.hints.tooltip}"
    binding="#{backingBeanScope.backing_TimeCostedInvoices.it3}"
    id="it3">
    <f:validator binding="#{bindings.Totalamount.validator}"/>
    <af:convertNumber groupingUsed="false"
    pattern="#{bindings.Totalamount.format}"/>
    </af:inputText>
    <af:selectOneChoice value="#{bindings.Doctypedesc.inputValue}"
    label="#{bindings.Doctypedesc.label}"
    required="#{bindings.Doctypedesc.hints.mandatory}"
    shortDesc="#{bindings.Doctypedesc.hints.tooltip}"
    binding="#{backingBeanScope.backing_TimeCostedInvoices.soc1}"
    id="soc1"
    valueChangeListener="#{backingBeanScope.backing_TimeCostedInvoices.getValue}"
    autoSubmit="true">
    <f:selectItems value="#{bindings.Doctypedesc.items}"
    binding="#{backingBeanScope.backing_TimeCostedInvoices.si1}"
    id="si1"/>
    </af:selectOneChoice>
    </af:panelFormLayout>
    </af:form>
    I am just thinking whether the syntax is appropriate on this line :-
    erks.addScript(context,"AdfPage.PAGE.findComponentByAbsoluteId('it3').setProperty('ContentStyle',background-color:#00C0C0);");
    Please suggest!!!

  • How to access servlet objects from OA page controller class

    Hi everybody!
    I need to put some value into servlet attribute in OA page controller class to read it from ordinary servlet later.
    How can i do it? Is it possible to get HttpServletRequest and HttpServletResponse objects from page controller?
    Thank you.

    I have a servlet which receives uploaded files with special attributes (something like tags for file) using POST request.
    This attributes created when user open page in standard OAF page via page controller.
    On client side I have an applet which uploads user selected file to my servlet and passes this file attributes.
    Now this attributes passes as plain text. I want to encrypt this attributes to hide attribute details from user. To do this I need to share some information between OAF page and my servlet.
    I know that OAF supports URL encryption, but to decrypt it I should use standard pageContext object.
    But in ordinary servlet I can't use it.

  • Java.lang.ClassCastException in Controller Class

    Hi All,
    I am getting ClassCastException in one of my Controller class where initiating OABreadCrumbsBean object.
    The code is as below.
    OABreadCrumbsBean oabreadcrumbsbean = (OABreadCrumbsBean)((OAPageLayoutBean)oawebbean).getBreadCrumbsLocator();
    This I am using processRequest() method in that controller class.
    Please let me know what can be the possible reason of this.
    Thanks
    Debashree

    You are presuming that the first indexed child can be cast as OAMessageChoiceBean. If you do System.out.println of the object, it will tell you what the type is. It sounds like the order of the children may have changed and the type of object you think you have referenced is a different type.
    Comment out the uiNde0 cast and do this:
    System.out.println(reasonDff.getIndexedChild((OARenderingContext)pageContext.getRenderingContext(),
    1));
    Kristofer

  • Getting appmod reference in UIX controller class

    Hi,
    I tried using ServletBindingUtils.getApplicationModule(BajaContext) method in a static method in UIX controller class to get the reference of application module defined in UIX page. But i am getting null. How can i get the reference of view and appmod in UIX controller class
    regards,
    srivatsan

    Your event handler has to be within a <bc4j:findRootAppModule> element.

Maybe you are looking for