-
1. Re: Stateless session bean and mod-proxy-ajp
keithnaas Mar 3, 2008 9:42 PM (in response to haim)How close is your setup to the instructions on UsingMod_proxyWithJBoss?
-
2. Re: Stateless session bean and mod-proxy-ajp
haim Mar 3, 2008 10:39 PM (in response to haim)
Keith Naas wrote on Mar 03, 2008 09:42 PM:
How close is your setup to the instructions on UsingMod_proxyWithJBoss?Well. not so close, since I'm not using any form of load balancing stuff. there's only one jboss and one apache, so (I think) there's no need for the sticky sessions and other load balancing stuff. The only setting I have is the one I've showed in the post.
Thanks.
Haim
-
3. Re: Stateless session bean and mod-proxy-ajp
haim Mar 4, 2008 11:27 AM (in response to haim)Hi
I've create a simple project to demonstrate this problem.
To use it do the following:
- download http://www.babysnakes.org/project.zip and open it.
- install maven 2.0.8 from http://maven.apache.org/
- cd into the project folder and run
mvn package
. - deploy ear/target/statetest.ear (on linux) or ear\target\statetest.ear (on windows) to jboss.
- go to http://localhost:8080/statetest/request.seam
- Fill your name and press
sayHello
. you should see usualThe result was: hello, name
. - Configure apache with
ProxyPass /statetest ajp://localhost:8009/statetest
- Now go to http://localhost/statetest/request.seam and you'll get only
The result was:
(withouthello, name
).
Any Ideas?
Thanks
Haim
-
4. Re: Stateless session bean and mod-proxy-ajp
modoc Feb 13, 2009 11:35 PM (in response to haim)I'm having what may be a related issue.
I am using Seam 2.1.1 GA, and JBoss 4.2.3.GA (same on JBoss 4.2.2.GA).
My application has PAGE scoped action class that handles a form submission. It creates a Job entity and persists it. I am using FlushModeType.MANUAL and flushing the entitymanager. It then raises an asynchronous Seam event, which passes the Job.id. A conversation (although I've played with other scopes) scoped Seam Component Observes that event, and then uses entityManager.find(Job.class,jobId) to load up the Job, and then processes the job (something that takes several minutes).
When I hit JBoss directly, this works perfectly 100% of the time. However, if Apache is in front of JBoss, the entityManager.find returns null. This is true regardless if I'm using mod_proxy http or mod_proxy_ajp. All other parts of my application work as expected.
Any ideas on how to fix this and/or work around it?
-
5. Re: Stateless session bean and mod-proxy-ajp
modoc Feb 13, 2009 11:41 PM (in response to haim)Relevant code:
@SuppressWarnings("unchecked") @Begin(nested = true, flushMode = FlushModeType.MANUAL) public String createJob() { this.mLog.info("Starting createJob method."); // Add null/empty validations if (StringUtils.isBlank(this.mNewCouponJob.getName())) { this.facesMessages.add("Please enter a name for the new Coupon Job"); return null; } if (this.currentCampaign == null) { this.facesMessages.add("Please go back and select a campaign again."); return null; } final List<Campaign> existing = this.entityManager.createQuery( "select j.name from couponJob j where j.name=:name").setParameter("name", this.mNewCouponJob.getName()) .getResultList(); if (existing.size() == 0) { ((Session)this.entityManager.getDelegate()).setFlushMode(FlushMode.MANUAL); this.mNewCouponJob.setDate(new Date()); this.mNewCouponJob.setUser(user); this.mNewCouponJob.setCampaign(currentCampaign); this.mNewCouponJob.setComplete(false); this.mNewCouponJob.setGenerated(0); this.entityManager.persist(this.mNewCouponJob); this.entityManager.flush(); this.entityManager.refresh(currentCampaign); this.entityManager.clear(); Events.instance().raiseAsynchronousEvent("newCouponJobCreated", mNewCouponJob.getId()); setLastCreatedJobId(mNewCouponJob.getId()); this.facesMessages.add("You have successfully created Job #0", this.mNewCouponJob.getName()); setNewCouponJob(new CouponJob()); return "couponJobCreated"; } else { this.facesMessages.add("Coupon Job name #0 already exists, please pick another", this.mNewCouponJob .getName()); return null; } }
@Transactional @Observer("newCouponJobCreated") @End public void handleNewCouponJob(final int pCouponJobId) { this.mLog.info("handleNewCouponJob was called with job id: #0.", pCouponJobId); long startTime = System.currentTimeMillis(); entityManager.joinTransaction(); ((Session) this.entityManager.getDelegate()).clear(); ((Session) this.entityManager.getDelegate()).setFlushMode(FlushMode.MANUAL); entityManager.flush(); entityManager.clear(); final CouponJob job = this.entityManager.find(CouponJob.class, pCouponJobId);
pages.xml
<page view-id="/coupon/campaign.xhtml" login-required="true"> <rewrite pattern="/campaign/{campaignId}" /> <rewrite pattern="/campaign" /> <param name="campaignId" value="#{campaignDetail.selectedCampaignId}" /> <navigation from-action="#{campaignFormHandler.createJob}"> <rule if-outcome="couponJobCreated"> <redirect include-page-params="true" view-id="/coupon/job.xhtml"> <param name="jobId" value="#{campaignFormHandler.lastCreatedJobId}" /> </redirect> </rule> </navigation> </page> <page view-id="/coupon/job.xhtml" login-required="true"> <rewrite pattern="/job/{jobId}" /> <rewrite pattern="/job" /> <param name="jobId" value="#{jobDetail.selectedJobId}" /> </page>
-
6. Re: Stateless session bean and mod-proxy-ajp
modoc Feb 14, 2009 12:28 AM (in response to haim)Nevermind, this appears to be related to timing between the event being picked up and the redirect finishing allowing the conversation to end, and the db commit taking place.