Using flows in webfragments - cdi

I'm trying to build a webapp that includes a webfragment which contains a flow.
I started building a standalone version of the webapp I want to use as a webfragment. That's working. After that I converted it to this structure:
flow-webfragment\src\main\java\javaclasses..
flow-webfragment\src\main\resources\META-INF\beans.xml
flow-webfragment\src\main\resources\META-INF\faces-config.xml
flow-webfragment\src\main\resources\META-INF\web-fragment.xml
flow-webfragment\src\main\resources\META-INF\resources\META-INF\context.xml
flow-webfragment\src\main\resources\META-INF\resources\META-INF\myflowdir
flow-webfragment\src\main\resources\META-INF\resources\META-INF\webfragment-start.xhtml
I'm not sure about the structure.. If there is a better one or a convention please tell me.
The webfragment is set up correctly and my webapp recognizes it. I can go to the "webfragment-start.xhtml" page, but when I try to enter my flow, I get a NullPointerException:
java.lang.NullPointerException
at com.sun.faces.flow.FlowCDIContext.flowEntered(FlowCDIContext.java:332)
at com.sun.faces.flow.FlowHandlerImpl.pushFlow(FlowHandlerImpl.java:385)
at com.sun.faces.flow.FlowHandlerImpl.transition(FlowHandlerImpl.java:280)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:239)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:182)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:132)
I think CDI is not correctly available, because on another project, where I'm also using JSF 2.2 and Omnifaces, I get this message
org.omnifaces.ApplicationInitializer checkCDIAvailable
see http://omnifaces.org/cdi/
I also followed BalusC's instruction on how to install CDI in tomcat and it works as standalone webapp, but not as a webfragment.
I didn't find good and understandable tutorials on how to build webfragment. If you know one, you're welcome to tell me.
Every help is highly appreciated!
Kind regards,
Mischa

I just forgot to add
<Context>
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory" />
</Context>
to the context.xml.

Related

Netbeans 12 Hot Deployment to Wildfly 16

I'm having a lot of issues getting Netbeans 12 to hot deploy a JavaEE project (using Ant) to Wildfly. Surprisingly, any changes to my Java code hot deploys as usual upon save, but any changes to my web markup (.xhtml) will only show up after a fresh deployment.
Here's a list of what I've done and my current settings:
Settings:
Copy Static Resources on Save
Compile on Save
In my web.xml:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
What I've tried:
Reviewed the following questions and applied changes where applicable (most was not applicable given my version of Wildfly)
How do I enable on-the-fly compilation of JSPs in Wildfly 9?
https://developer.jboss.org/thread/237954
Netbeans 8.2 + wildfly 11 hot deploy not working [I've had this issue in NetBeans 8.2 instances too! No resolution]
Wildfly system Property:
<system-properties>
<property name="java.net.preferIPv4Stack" value="true"/>
<property name="org.jboss.as.web.deployment.DELETE_WORK_DIR_ONCONTEXTDESTROY" value="true"/>
</system-properties>
Wildfly Deployment Scanner:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir"
scan-interval="100"
auto-deploy-exploded="true"
untime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
In addition to the above, I've also modified the Ant script to copy the required files over to the appropriate directories. This DOES work, but each time I do this, I lose any session state with the app that I had prior to the save.
What I'm hoping to achieve is to be able to modify either my backing Java code or my front-end markup and upon saving the file (or clicking the hot deploy button, doesn't really matter to me) have the changes reflected on my application server.
I've worked on other projects that used WebLogic as the application server with no issues. Netbeans (8) simply "works" when you attach the debugger and modify a file (using WebLogic). The changes are immediately reflected in the browser upon a refresh without loss of state. I'm hoping that I'm missing something really small and it's easy to do with Netbeans 12 + Wildfly as well.
Thank you!! Hopefully I'm just missing something small!

Log4j Class missing on Weblogic

I have deployed a war file on Oracle Weblogic. War files contain all the required libraries in WEB-INF/lib. But whenever I am trying to visit my webpage, it gives error of
java.lang.NoClassDefFoundError: org/apache/log4j/Logger.
try adding to weblogic.xml :
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
(Although this may cause secondary issues with JSF jar's.)
The problem is resolved. One of my custom library using log4j, that one was not able to find log4j. So I created the jar including log4j and its working.

Flash scope not working in glassfish with jsf2.1

When I am using flash scope in glassfish it lives longer than one request but works fine with jetty8 and even tried the latest version of glassfish but its not working. The JSF has a jira about it and they have solved it in the next version, I have even tried that version of jars for JSF but still same problem persists in Glassfish but works fine for Jetty8. Facing this problem from many days can anyone throw some light on this??
Jetty as being a barebones servletcontainer doesn't come with any JSF implementation bundled and the one supplied along with the webapp will always be used.
Glassfish as being a fullfledged Java EE applicationserver comes with a JSF implementation bundled and the one supplied along with the webapp will by default always be ignored. If you'd like to upgrade the Glassfish-bundled JSF implementation, then you should be replacing the JAR in /glassfish/modules folder. Or, if you'd like to force Glassfish to use the webapp-supplied JSF implementation, then you should add the following entries to /WEB-INF/glassfish-web.xml (or sun-web.xml, depending on GF version used):
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
I had the same issue. The problem was caused by Mojarra (even 2.1.11) not able to cope with HTTP chunking. By disabling it the flash was emptied as expected.
You can disable it in the admin console
Configurations
server-config
Network Config
Protocols
http-listener-[N]
HTTP tab
Chunking

JSF 1.1 on Websphere 7

I am having an application which was developed using JSF 1.1 components. The tag libraries development team, is not going to support JSF 1.2, and we have to run the application on Webshere 7. As websphere 7, by default comes with JSF 1.2. Initially, i was able to deploy my application, but was unable to access it. Later, I read somewhere to remove "Precompile JSP" option, i did that and i was able to access the application. But i am facing some weird thing, first time i am able to login to application, but if i logout and then tries to login again, it is giving exceptions. The exception is javax.faces.el.EvaluationException: Exception while invoking expression #{login.authenticate}, where login is my bean name and authenticate is the method. Moreover, I want some other way, so that i should keep "Precompile jsp" option selected. I read somewhere about shared libraries, but not aware how to actually implement that. My war file contains jsf-api.jar and jsf-impl.jar of JSF 1.1.
Do you see some errors regarding propertyLoader? I had similar problem, and removed from config file custom propertyLoader (left standart), and it became almost ok.

Richfaces 3.x under weblogic 8.1

I have been developing a small project meant to run under weblogic 8.1.
Richfaces according to documentation states that it supports weblogic 8.1.
Weblogic 8.1 uses servlet specification 2.3 with jsp 1.2
This has been working on my locally installed version of weblogic 8.1 but when deploying to the sparc server, I start running into trouble. I have worked through some of the initial headaches, but then I got an error 500 and couldnt get the details. But after some effort I have come out with this...
javax.servlet.ServletException: javax/servlet/jsp/JspContext
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:344)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6987)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
JspContext is not part of jsp 1.2 it's newer. I am thinking this exception is originally a ClassNotFoundException or something similar considering the message. There is no 'cause' attached to the exception.
Following are the jar files contained in my web-application.
antlr-2.7.6.jar
asm-1.5.3.jar
asm-attrs-1.5.3.jar
cglib-2.1_3.jar
commons-beanutils-1.6.jar
commons-collections-3.2.jar
commons-digester-1.5.jar
commons-lang-2.4.jar
commons-logging-1.0.3.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
hibernate-3.2.4.sp1.jar
jsf-api-1.1_02.jar
jsf-impl-1.1_02.jar
jstl-1.0.jar
jta-1.1.jar
log4j-1.2.15.jar
richfaces-api-3.1.6.SR1.jar
richfaces-impl-3.1.6.SR1.jar
richfaces-ui-3.1.6.SR1.jar
xercesImpl-2.9.1.jar
xml-apis-1.3.04.jar
I'm running out of options, I'll be trying to figure out who has the dependency on the JspContext class... but if someone could give me some insight it would be greatly appreciated. Oh, I cannot make many changes to the production web-logic server. I'd prefer not to make any at all, chances are those changes will be denied
Oh this error occurs when attempting to view the page, so deployment is successful.
Ok, I have solved my problem. Not the way I wanted to but it's working (atleast to what I know right now).
After using google (again) I found a comment with someone mentioning using richfaces 3.0.1.
Now I have seen many people say use version xxx even 3.3.x. After all I did get it working with 3.1.6 but on the windows version of weblogic (which could have possibly been tainted by some other weblogic version I have installed).
So I have modified my pom for maven to depend on:
<groupId>org.richfaces</groupId>
<artifactId>richfaces</artifactId>
<version>3.0.1</version>
This is not optimal, but I geuss it works.
Some taglibrary references needed changing, and packages changed to some extent.
I could post my project configuration for this if anyone ever needs it. Getting this all to work on weblogic 8.1 was not straight forward. But the reference documentation for 3.1.6 is to my knowledge incorrect by saying it support weblogic 8.1
jsp-api-2.1.jar contains the missing class, so you could try using it (either replace it in weblogic, or try in your /lib), but I can't predict what would happen.

Resources