[Beginners Corner] - JBoss 4.2.2 with myfaces - java.lang.RuntimeException: Canno
by javatwo
Everything is runing well in JBoss 4.0.5GA with myfaces.
For JBoss 4.2.2GA, I uses myfaces jars bundled in web-inf/lib and add the following in web.xml, and remove all libs under jsf-libs.
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
I got the following exception: Thanks for help.
java.lang.RuntimeException: Cannot find FacesContext
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1835)
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1652)
at org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:124)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:93)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119534#4119534
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119534
18 years, 6 months
[Persistence, JBoss/CMP, Hibernate, Database] - lock when commit to multiple database
by coolin
lock occured in ejb transaction when commit to 2 different databases simultaneously.
as result: both database (data1 and data 2 are locked)
but separately or not in transaction is ok.
jboss 4.2.Hibernarte 3.2.5.ga
| ...
| @Stateless
| @Local(value = ProcessingLocal.class)
| public class ProcessingBean implements ProcessingLocal
| {
| @EJB(beanName = "Data1Bean", beanInterface = Data1Local.class)
| private Data1Local data1;
| @EJB(beanName = "Data2Bean", beanInterface = Data2Local.class)
| private Data2Local data2;
|
| public void test() throws Exception
| {
| Entity1 e1 = new Entity1();
| data1.merge(e1);
|
| Entity2 e2 = new Entity2();
| data2.merge(e2);
| }
| }
|
|
data-ds.xml
| <datasources>
|
| <xa-datasource>
| <jndi-name>data1</jndi-name>
| <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>
| <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>
| <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
| <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
| <xa-datasource-property name="DatabaseName">data1</xa-datasource-property>
| <xa-datasource-property name="ServerName">main</xa-datasource-property>
| <xa-datasource-property name="User">informix</xa-datasource-property>
| <xa-datasource-property name="Password">informix</xa-datasource-property>
| <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
|
| <min-pool-size>5</min-pool-size>
| <max-pool-size>1000</max-pool-size>
|
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
| </exception-sorter-class-name>
|
| <metadata>
| <type-mapping>InformixDB</type-mapping>
| </metadata>
|
| </xa-datasource>
|
| <xa-datasource>
| <jndi-name>data2</jndi-name>
| <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>
| <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>
| <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
| <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
| <xa-datasource-property name="DatabaseName">data2</xa-datasource-property>
| <xa-datasource-property name="ServerName">main</xa-datasource-property>
| <xa-datasource-property name="User">informix</xa-datasource-property>
| <xa-datasource-property name="Password">informix</xa-datasource-property>
| <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
|
| <min-pool-size>5</min-pool-size>
| <max-pool-size>1000</max-pool-size>
|
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
| </exception-sorter-class-name>
|
| <metadata>
| <type-mapping>InformixDB</type-mapping>
| </metadata>
|
| </xa-datasource>
|
| </datasources>
|
in unit 1
persistence.xml
|
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
| http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="data1" transaction-type="JTA">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/data1</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="false"/>
| <property name="hibernate.format_sql" value="true"/>
| <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
| <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| </properties>
| </persistence-unit>
|
| </persistence>
|
|
in unit 2
persistence.xml
|
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
| http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="data2" transaction-type="JTA">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/data2</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="false"/>
| <property name="hibernate.format_sql" value="true"/>
| <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
| <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| </properties>
| </persistence-unit>
|
| </persistence>
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119529#4119529
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119529
18 years, 6 months
[JBoss Seam] - Inc. hot deployment classloader blues
by nickarls
I start out in JBoss Tools Seam Module by creating a new seam project (WAR), add an entity, and a backing bean method that inserts an entity and a button that calls that method => everything is inserted fine.
Then I add a dependency from the model to the action (all this domain-driven-rich-model-stuff, you know) => NoClassDefFounderror for the action. Not surprising, since the WEB-INF/dev has it's own classloader, so I try to put everything under /dev (the entities are POJOs anyway so I would like to have them there). Edit the output folder for the model. Now I get a "java.lang.IllegalArgumentException: Unknown entity: org.domain.Concept.model.Foo".
How come? The classes are there, the persistence.xml is there, seam.properties is there. How can you get the entire source tree available for incremental hot deployment?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119518#4119518
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119518
18 years, 6 months
[JBoss Seam] - Re: Error Rendering View[/home.xhtml]
by keeve
Here it is:
@Name("CalcBean")
| @Scope(ScopeType.CONVERSATION)
| public class CalculatorController {
|
| /** Creates a new instance of CalculatorController */
|
| public CalculatorController() {
| }
|
| private Calculator cal = new Calculator();
| private int num1 = 0;
| private int result = 0;
| private int num2 = 0;
|
| @Create
| @Begin(pageflow="CalcBean")
|
| public void setCalculator(Calculator aCal){
| this.cal = aCal;
| }
|
|
| public void setnum1(int num_1){
| this.num1 = num_1;
| }
|
| public int getnum1(){
| return num1;
| }
|
| public int getResult(){
| return result;
| }
| public void setnum2(int num_2){
| this.num2 = num_2;
| }
|
| public int getnum2(){
| return num2;
| }
|
| public void add(){
| result = cal.add(num1, num2);
|
| }
|
| public void multiply(){
| result = cal.multiply(num1, num2);
|
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119491#4119491
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119491
18 years, 6 months
[EJB/JBoss] - Re: What is wrong with my local ejb JNDI lookup code (or the
by sairndain
Apparently, jboss.xml, jboss-web.xml, jboss-application.xml are not required... at least in this simple "enterprise" project I created.
What is not clear is whether the jboss*.xml configuration files allow JBoss to provide some other benefit -- other than short JNDI names.
Anyway this is the code for those interested I've included the code in this post (see below)...
If anyone knows what other benefits the "jboss*.xml" provide, please post it... -Thanks in advance!
sd
environment:
Windows XP
NetBeans 6.0 ide
JBoss4.0.4GA
EJB 2.1
J2EE 1.4.x
----------EAR----------
application.xml configuration file
| <?xml version="1.0" encoding="UTF-8"?>
| <application version="1.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/application_1_4.xsd">
| <display-name>jjjEAR</display-name>
| <module>
| <web>
| <web-uri>jjjEAR-war.war</web-uri>
| <context-root>/jjjEAR-war</context-root>
| </web>
| </module>
| <module>
| <ejb>jjjEAR-ejb.jar</ejb>
| </module>
| </application>
|
----------EJB Module----------
jjj.ejb.JjjEJBBean stateless session bean (I'm not including the remote and local interface files here because they are standard fare)
| package jjj.ejb;
|
| import javax.ejb.SessionBean;
| import javax.ejb.SessionContext;
|
| public class JjjEJBBean implements SessionBean {
|
| private SessionContext context;
|
| // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">;
|
| // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
| // TODO Add business methods or web service operations
|
| /**
| * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
| */
| public void setSessionContext(SessionContext aContext) {
| context = aContext;
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbActivate()
| */
| public void ejbActivate() {
|
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbPassivate()
| */
| public void ejbPassivate() {
|
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbRemove()
| */
| public void ejbRemove() {
|
| }
|
| public void ejbCreate() {
| }
|
| private String field1 = "...value of field1 in jjj.ejb.JjjEJBBean (in EJB module)...";
| public String getField1() {
| return this.field1;
| }
| }
|
ejb-jar.xml configuration file
| <?xml version="1.0" encoding="UTF-8"?>
| <ejb-jar version="2.1" 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/ejb-jar_2_1.xsd">
| <enterprise-beans>
| <session>
| <display-name>JjjEJBSB</display-name>
| <ejb-name>JjjEJBBean</ejb-name>
| <home>jjj.ejb.JjjEJBRemoteHome</home>
| <remote>jjj.ejb.JjjEJBRemote</remote>
| <local-home>jjj.ejb.JjjEJBLocalHome</local-home>
| <local>jjj.ejb.JjjEJBLocal</local>
| <ejb-class>jjj.ejb.JjjEJBBean</ejb-class>
| <session-type>Stateless</session-type>
| <transaction-type>Container</transaction-type>
| </session>
|
| <ejb-ref>
| <ejb-ref-name>JjjEJBBean</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <home>jjj.ejb.JjjEJBRemoteHome</home>
| <remote>jjj.ejb.JjjEJBRemote</remote>
| <ejb-link>jjjEAR-ejb.jar#JjjEJBBean</ejb-link>
| </ejb-ref>
| <ejb-local-ref>
| <ejb-ref-name>JjjEJBLocalHome</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <local-home>jjj.ejb.JjjEJBLocalHome</local-home>
| <local>jjj.ejb.JjjEJBLocal</local>
| <ejb-link>jjjEAR-ejb.jar#JjjEJBBean</ejb-link>
| </ejb-local-ref>
|
| </enterprise-beans>
| <assembly-descriptor>
| <container-transaction>
| <method>
| <ejb-name>JjjEJBBean</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>Required</trans-attribute>
| </container-transaction>
| </assembly-descriptor>
| </ejb-jar>
|
----------WEB Module----------
jjj.web.JjjBean POJO
| package jjj.web;
|
| import java.rmi.RemoteException;
| import javax.ejb.CreateException;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import jjj.ejb.JjjEJBLocal;
| import jjj.ejb.JjjEJBLocalHome;
| import jjj.ejb.JjjEJBRemote;
| import jjj.ejb.JjjEJBRemoteHome;
|
| public class JjjBean {
|
| private String field1RemoteLookup = "...value of field1LocalLookup in jjj.web.JjjBean in WEB module...";
| public String getField1RemoteLookup() throws RemoteException
| {
| JjjEJBRemote remoteRef = this.lookupJjjEJBRemote();
| return remoteRef.getField1() + this.field1RemoteLookup;
| }
|
| private String field1LocalLookup = "...value of field1LocalLookup in jjj.web.JjjBean...";
| public String getField1LocalLookup()
| {
| JjjEJBLocal localRef = this.lookupJjjEJBLocal();
| return localRef.getField1() + this.field1LocalLookup;
| }
|
|
| private JjjEJBLocal lookupJjjEJBLocal() {
| try {
| Context c = new InitialContext();
| JjjEJBLocalHome rv = (JjjEJBLocalHome) c.lookup("java:comp/env/JjjEJBLocalHome");
| return rv.create();
| } catch (NamingException ne) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
| throw new RuntimeException(ne);
| } catch (CreateException ce) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
| throw new RuntimeException(ce);
| }
| }
|
| private JjjEJBRemote lookupJjjEJBRemote() {
| try {
| Context c = new InitialContext();
| Object remote = c.lookup("java:comp/env/JjjEJBBean");
| JjjEJBRemoteHome rv = (JjjEJBRemoteHome) javax.rmi.PortableRemoteObject.narrow(remote, jjj.ejb.JjjEJBRemoteHome.class);
| return rv.create();
| } catch (NamingException ne) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
| throw new RuntimeException(ne);
| } catch (CreateException ce) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
| throw new RuntimeException(ce);
| } catch (RemoteException re) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", re);
| throw new RuntimeException(re);
| }
| }
| }
|
index.jsp web page
| <%@page contentType="text/html"%>
| <%@page pageEncoding="UTF-8"%>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
| <html>
| <head>
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
| <title>JSP Page</title>
| </head>
| <body>
| <jsp:useBean id="jjjBean" class="jjj.web.JjjBean" scope="request" />
|
| <h1>value of field1 - remote lookup...</h1>
| <jsp:getProperty name="jjjBean" property="field1RemoteLookup" />
|
| <h1>value of field1 - local lookup...</h1>
| <jsp:getProperty name="jjjBean" property="field1LocalLookup" />
|
| </body>
| </html>
|
web.xml configuration file
| <?xml version="1.0" encoding="UTF-8"?>
| <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">
| <session-config>
| <session-timeout>
| 30
| </session-timeout>
| </session-config>
| <welcome-file-list>
| <welcome-file>index.jsp</welcome-file>
| </welcome-file-list>
| <ejb-ref>
| <ejb-ref-name>JjjEJBBean</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <home>jjj.ejb.JjjEJBRemoteHome</home>
| <remote>jjj.ejb.JjjEJBRemote</remote>
| <ejb-link>jjjEAR-ejb.jar#JjjEJBBean</ejb-link>
| </ejb-ref>
| <ejb-local-ref>
| <ejb-ref-name>JjjEJBLocalHome</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <local-home>jjj.ejb.JjjEJBLocalHome</local-home>
| <local>jjj.ejb.JjjEJBLocal</local>
| <ejb-link>jjjEAR-ejb.jar#JjjEJBBean</ejb-link>
| </ejb-local-ref>
| </web-app>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119490#4119490
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119490
18 years, 6 months
[JBoss Seam] - Servlets in long running conversations
by burtoncarl
I'm trying to access objects from a long running conversation from withing a servlet. I haven't had much sucess though. So I've created a very simple servlet to simply access a conversation. Throughout my app seam adds "cid" for the conversation id in the parameters list. although for my testing I have been adding both cid and conversationId to the request.
I've tried adding
<web:context-filter url-pattern="/servlet/*" />
to components.xml and/or
| <filter>
| <filter-name>Seam Servlet Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>Seam Servlet Filter</filter-name>
| <url-pattern>/servlet/*</url-pattern>
| </filter-mapping>
|
to the web.xml, both met with failure. I am able to access objects with Component.getInstance("someName"), but not within my conversation.
Here are the bits of code I am able to share.
web.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <web-app 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/web-app_2_5.xsd"
| version="2.5">
| <!-- Ajax4jsf setup -->
|
| <filter>
| <display-name>RichFaces Filter</display-name>
| <filter-name>richfaces</filter-name>
| <filter-class>org.ajax4jsf.Filter</filter-class>
| </filter>
|
|
| <filter-mapping>
| <filter-name>richfaces</filter-name>
| <servlet-name>Faces Servlet</servlet-name>
| <dispatcher>REQUEST</dispatcher>
| <dispatcher>FORWARD</dispatcher>
| <dispatcher>INCLUDE</dispatcher>
| </filter-mapping>
|
| <context-param>
| <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
| <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
| </context-param>
|
| <context-param>
| <param-name>javax.faces.CONFIG_FILES</param-name>
| <param-value>/WEB-INF/navigation.xml</param-value>
| </context-param>
|
| <listener>
| <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
| </listener>
|
| <context-param>
| <param-name>org.richfaces.SKIN</param-name>
| <param-value>csc2</param-value>
| </context-param>
|
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>client</param-value>
| </context-param>
|
| <context-param>
| <param-name>facelets.DEVELOPMENT</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <context-param>
| <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
| <param-value>.xhtml</param-value>
| </context-param>
|
| <context-param>
| <param-name>facelets.SKIP_COMMENTS</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <filter>
| <filter-name>Seam Filter</filter-name>
| <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <!--
| <filter>
| <filter-name>Seam Context Filter</filter-name>
| <filter-class>org.jboss.seam.web.ContextFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>Seam Context Filter</filter-name>
| <url-pattern>/servlet/*</url-pattern>
| </filter-mapping>
|
| <filter>
| <filter-name>Seam Multipart Filter</filter-name>
| <filter-class>org.jboss.seam.web.MultipartFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Multipart Filter</filter-name>
| <url-pattern>*.xhtml</url-pattern>
| </filter-mapping>
| -->
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.htm</url-pattern>
| </servlet-mapping>
|
| <!--
| <filter>
| <filter-name>Seam Servlet Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>Seam Servlet Filter</filter-name>
| <url-pattern>/servlet/*</url-pattern>
| </filter-mapping>
| -->
|
|
| <servlet>
| <description>For testing conversations within servlet</description>
| <display-name>ConversationTestServlet</display-name>
| <servlet-name>ConversationTestServlet</servlet-name>
| <servlet-class>com.gdi.csc.servlet.ConversationTestServlet</servlet-class>
| <load-on-startup>3</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>ConversationTestServlet</servlet-name>
| <url-pattern>/servlet/conversation</url-pattern>
| </servlet-mapping>
|
| <security-constraint> <!-- This stops the user from replacing the .htm extensino with .xhtml to read the source files... -->
| <display-name>Restrict XHTML Documents</display-name>
| <web-resource-collection>
| <web-resource-name>XHTML</web-resource-name>
| <url-pattern>*.xhtml</url-pattern>
| </web-resource-collection>
| <auth-constraint>
| <role-name>NONE</role-name>
| </auth-constraint>
| </security-constraint>
|
| <session-config>
| <session-timeout>30</session-timeout>
| </session-config>
|
| <!--
| <error-page>
| <error-code>404</error-code>
| <location>/home.htm</location>
| </error-page>
| -->
| </web-app>
|
components.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:security="http://jboss.com/products/seam/security"
| xmlns:framework="http://jboss.com/products/seam/framework"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xmlns:web="http://jboss.com/products/seam/web"
| xmlns:mail="http://jboss.com/products/seam/mail"
| xsi:schemaLocation=
| "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.2.xsd
| http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.2.xsd
| http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-1.2.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.2.xsd
| http://jboss.com/products/seam/web http://jboss.com/products/seam/web-1.2.xsd"
| >
|
| <core:init debug="true" jndi-pattern="#{ejbName}/local"/>
|
| <!-- 120 second conversation timeout -->
| <core:manager conversation-timeout="120000"
| concurrent-request-timeout="1000"
| conversation-id-parameter="cid"
| conversation-is-long-running-parameter="clr"/>
|
| <!--
| <core:jbpm>
| <core:process-definitions>
| <value>ordermanagement1.jpdl.xml</value>
| </core:process-definitions>
| <core:pageflow-definitions>
| <value>checkout.jpdl.xml</value>
| <value>newuser.jpdl.xml</value>
| </core:pageflow-definitions>
| </core:jbpm>
| -->
| <core:ejb installed="true"/>
|
| <!-- <core:microcontainer installed="true"/> -->
|
| <security:identity authenticate-method="#{csc2authenticator.authenticate}"/>
| <event type="org.jboss.seam.notLoggedIn">
| <action expression="#{redirect.captureCurrentView}"/>
| </event>
|
| <event type="org.jboss.seam.postAuthenticate">
| <action expression="#{redirect.returnToCapturedView}"/>
| </event>
|
|
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/myEntityFactory" />
|
| <!--factory for "session" property used to have an ability
| to inject Hibernate session object directly in the
| @In Session session;-->
| <factory name="session" auto-create="true" scope="STATELESS"
| value="#{entityManager.delegate}"/>
|
| <!-- Conversation propagation with redirects -->
| <web:redirect-filter url-pattern="*.htm"/>
|
| <!-- Context management for custom servlets -->
| <web:context-filter url-pattern="/servlet/*" />
|
|
| <!--To enable file upload capability
| max-request-size - maximum file size in bytes
| -->
| <web:multipart-filter auto-create="true"
| class="org.jboss.seam.web.MultipartFilter" max-request-size="4000000"
| url-pattern="*.htm"/>
|
| <!-- Mail session component-->
| <mail:mail-session scope="application"
| host="#{applicationProperties.smtpHost}"
| port="#{applicationProperties.smtpPort}"
| username="#{applicationProperties.smtpUserName}"
| password="#{applicationProperties.smtpPassword}"/>
| <!--
| <component class="org.jboss.seam.web.MultipartFilter">
| <property name="maxRequestSize">4000000</property>
| </component>
| -->
| </components>
|
ConversationTestServlet.java
| /**
| * Copyright 2008 CoActive Marketing Group
| */
| package com.gdi.csc.servlet;
|
| import java.io.IOException;
| import java.util.ArrayList;
| import java.util.Enumeration;
|
| import javax.faces.event.PhaseId;
| import javax.servlet.ServletException;
| import javax.servlet.http.HttpServlet;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
| import javax.servlet.http.HttpSession;
|
| import org.apache.log4j.Logger;
| import org.jboss.seam.Component;
| import org.jboss.seam.contexts.ContextAdaptor;
| import org.jboss.seam.contexts.Lifecycle;
| import org.jboss.seam.core.Conversation;
| import org.jboss.seam.core.Manager;
|
| /**
| * @author Burton Hodges
| *
| */
| @SuppressWarnings("serial")
| public class ConversationTestServlet extends HttpServlet {
| private static Logger logger = Logger.getLogger(ThumbServlet.class);
|
| @Override
| protected void doGet(HttpServletRequest request, HttpServletResponse resp)
| throws ServletException, IOException {
| debugRequestParameters(request);
| debugConversation(request);
| }
|
| private void debugConversation(HttpServletRequest request){
| try{
| // HttpSession session = request .getSession(true);
| // Lifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
| // Lifecycle.setServletRequest(request);
| // Lifecycle.beginRequest(getServletContext(), session, request);
| // Manager.instance().restoreConversation(request.getParameterMap());
| // Lifecycle.resumeConversation(session);
| // Manager.instance().handleConversationPropagation(request.getParameterMap());
|
| {
| logger.info("debugConversation: trying Component.getInstance(\"conversation\")");
| Object o = Component.getInstance("conversation");
| if(o==null){
| logger.info("debugConversation: Component.getInstance(\"conversation\") returned null");
| }else{
| logger.info("debugConversation: object is instance of "+o.getClass().getName());
| debugConversation(Conversation.class.cast(o));
| }
| }
|
| logger.info("debugConversation: trying Conversation.instance()");
| debugConversation(Conversation.instance());
|
| // Manager.instance().endRequest(ContextAdaptor.getSession(session));
| // Lifecycle.endRequest(session);
|
| }catch (Exception e){
| logger.info("debugConversation: Error occured debuging seam conversation", e);
| }
| }
|
| private void debugConversation(Conversation conversation){
| if(conversation==null){
| logger.info("debugConversation: conversation is null");
| return;
| }
| logger.info("debugConversation: "+conversation);
| logger.info("debugConversation: "+conversation.getId());
| logger.info("debugConversation: "+conversation.getParentId());
| logger.info("debugConversation: "+conversation.getRootId());
| logger.info("debugConversation: "+conversation.getViewId());
| }
|
| @SuppressWarnings("unchecked")
| private void debugRequestParameters(HttpServletRequest request){
| logger.info("debugRequestParameters: Debugging request parameters");
|
| ArrayList<String> keys = new ArrayList<String>();
| Enumeration e = request.getParameterNames();
| while(e.hasMoreElements())
| keys.add(e.nextElement().toString());
| for(String key: keys)
| logger.info("debugRequestParameters: "+key+"="+request.getParameter(key));
| }
|
| }
|
and an excerpt from my log file:
| 2008-01-13 21:18:33,828 [http-8080-Processor25] INFO - debugRequestParameters: Debugging request parameters
| 2008-01-13 21:18:33,828 [http-8080-Processor25] INFO - debugRequestParameters: conversationId=1
| 2008-01-13 21:18:33,828 [http-8080-Processor25] INFO - debugRequestParameters: cid=1
| 2008-01-13 21:18:33,828 [http-8080-Processor25] INFO - debugConversation: trying Component.getInstance("conversation")
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: object is instance of org.jboss.seam.core.Conversation
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: org.jboss.seam.core.Conversation@2eb6e9
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: 2
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: null
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: 2
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: null
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: trying Conversation.instance()
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: org.jboss.seam.core.Conversation@2eb6e9
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: 2
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: null
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: 2
| 2008-01-13 21:18:33,843 [http-8080-Processor25] INFO - debugConversation: null
|
Any help would be appreciated!
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119486#4119486
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119486
18 years, 6 months
[EJB 3.0] - Re: problems with optimistic locking/persistence data in EJB
by wiggy
I'm thinking the same way - but dont know how to fix it!
the delete action updates the version number from the previous transaction.
----------
---- | ----- |
| | ---> | | | |
----- | ------ |
----------
client AS server and EJB server code
| ... container based delete action that updates the DB and increments the version i'ds on the DB . Server code ...
|
| @TransactionAttribute (TransactionAttributeType.REQUIRED)
| public boolean removeLink (Node fromNode, Node remoteNode)
| {
|
| List<Link> qres;
| Logger log = Logger.getLogger("NodeEAOBean");
| log.setLevel(org.apache.log4j.Level.DEBUG);
|
| if (fromNode == null || remoteNode == null)
| {
| log.error("was passed a null reference");
| return false;
| }
|
| fromNode = em.merge(fromNode);
| remoteNode = em.merge(remoteNode);
| Query q = em.createNamedQuery("findLinksBetweenNodes");
| q.setParameter("toNode", remoteNode);
| q.setParameter("fromNode", fromNode);
|
| log.debug("to node details " + remoteNode.getNodeName() + "\n");
|
| qres = (List<Link>)q.getResultList();
| if (qres != null && qres.size () == 1)
| {
| Link link = qres.get(0);
| remoteNode.deleteLinkFrom(link);
| fromNode.deleteLinkTo(link);
| em.remove(link);
| //fix?
| em.flush();
| return true;
| }
| else
| {return false;}
|
| }
|
however despite the merge actions and the end of the transaction completing ( i even put the flush in and it made no difference). These changes dont get synced back to the application client (outside the container).
so how are you supposed to get the client back in sync ? I tried a resync operation from the client like this
| ... client code - calls the remove link then tries to resynch with server
| after the the above code has ompleted...
|
| //local if (removeLink(uNode, zNode))
| if (nodeEAO.removeLink(uNode, zNode))
| {
|
| System.out.println ("deleted link : \n");
| }
|
| //update to latest version number
| yNode = nodeEAO.refresh(uNode);
|
and this errors with the same optimistic lock exception
on the EJB server side the refresh is implemented as
| ... generic EAO class code ...
|
| public T refresh (T entity)
| {
| entity = em.merge(entity);
| em.refresh (entity);
| return entity;
| }
|
I thought this was going to be enough to resync the client local copy to the extant version on the DB. but the error still occurs.
How is this supposed to work ???
do i have to do a complete new findByID call and get a new reference from the client ? seems a bit weird - surely there is a way to update a disconnected client copy with the changes on the EJB server?
should version managment be avoided (doesnt seem right). If not just how the heck is this supposed to work.
thanks in advance if you can help
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119468#4119468
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119468
18 years, 6 months