eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
385 stars 144 forks source link

Conversational Beans not working #11000

Closed glassfishrobot closed 14 years ago

glassfishrobot commented 15 years ago

This issue is documented at http://www.seamframework.org/Community/ConversationScopeNotWorking . However, the original post was a separate issue, and my issue starts around the 6th post down til the end. The specifics are included below.

I am using Glassfish build 71, with Netbeans Dev Build 200911091156. I am also using the latest Weld version

I have duplicated this problem with my own test project and also with the weld number guess examples. The gist of the problem is that it appears that conversations are not being propagated across JSF postbacks. Even when a conversation has been started, a new instance of the conversation is used for each postback. Non-Conversational Weld apps or apps that just use session or request beans work fine. I think the problem may be that there is no ConversationAwareViewHandler defined for weld deployments. I can provide a war file that works on JBoss 5.2 beta but has this problem on Glassfish if you need it.

Test Case

As a test, I have a bean that is conversationally scoped, and has a conversation injected into it :

@ConversationScoped @Named("myBean") public class MyBean implements Serializable {

@Inject private Conversation conversation;

public void startConversation()

{ conversation.begin(); }

public void dummy() {

}

public boolean isTransient()

{ return conversation.isTransient(); }

}

In my page, I show the conversation instance and have a button that calls the startConversation() method. I also have a dummy button that does nothing but post back to the page.


Is Transient : # {myBean.transient}
Conversation = # {javax.enterprise.context.conversation}
I load the page up, and click dummy a few times, the conversation Id is incrementing and transient is true which is correct as I have not yet started a conversation. I click the start conversation button to call the begin method on the conversation instance through myBean. The transient value of the conversation becomes false, but after that, when the page is posted by clicking the dummy button, I get a new conversation instance with a new conversation id which has a transient value of true. It is like the conversation is not propagated from one page to the next. I took a look through my intallation and noticed you have some integration code for weld. It has a reference to a faces config with a glassfish WeldApplicationFactory and a Weld phase listener, but not a COnversationAwareViewHandler instance like the JBoss deployer does. I tried to include my own ConversationAwareView handler in my faces-config, but got ClassNotFound errors (the same for when I tried to add my own WeldPhaseListener). I'm more than happy to provide an example, or more information as needed, Cheers, Andy Gibson #### Environment Operating System: Windows XP Platform: PC URL: [http://www.seamframework.org/Community/ConversationScopeNotWorking](http://www.seamframework.org/Community/ConversationScopeNotWorking) #### Affected Versions [V3]
glassfishrobot commented 6 years ago
glassfishrobot commented 15 years ago

@glassfishrobot Commented rogerk said: Hi Andy -

Please provide the war (and source) that works on jboss?

Thanks, Roger.

glassfishrobot commented 15 years ago

@glassfishrobot Commented agibson77 said: Created an attachment (id=3884) War file of web app working in JBOss 5.2 beta, and not in Glassfish b71

glassfishrobot commented 15 years ago

@glassfishrobot Commented rogerk said: Hi Andy -

Do you have source? Also may be provide your ConverstionAwareViewHandler?

glassfishrobot commented 15 years ago

@glassfishrobot Commented agibson77 said: Created an attachment (id=3885) Sources for attached war file

glassfishrobot commented 15 years ago

@glassfishrobot Commented agibson77 said: I didn't include them originally as I wanted to verify that they worked as I was claiming (works in JBoss, not in Glassfish).

I've attached a war file and the source for the war. It was built from the weld examples which uses common properties, scripts and libraries to build the examples so I don't have a simple project for the war file to build from without include the whole examples directory structure.

glassfishrobot commented 15 years ago

@glassfishrobot Commented agibson77 said: The ConversationAwareViewHandler is in the weld distribution located in the weld-osgi-bundle.jar file. It is even in the original version distributed with Glassfish build 71 as well as the latest version.

The full name is :

org.jboss.weld.jsf.ConversationAwareViewHandler

Cheers,

Andy

glassfishrobot commented 14 years ago

@glassfishrobot Commented rogerk said: Hi Andy -

The war example (weld-numberguess.war) does not have the buttons you outline in your instructions for this post. It is the traditional weld numberguess app with "guess" and "reset" buttons and one additional "long" button. How should I test with this?

glassfishrobot commented 14 years ago

@glassfishrobot Commented agibson77 said: My apologies Roger for not including a test plan, I meant to but had some other things going on.

To test the problem, start the war, put in a number and click guess (and hope you don't get the right number first time!). Keep putting in guesses, and the conversation instance displayed on the page should keep changing, the id will increment as you use a new conversation each time. However, when you click the long button, it should turn the conversation into a long running one, and now each time you click guess, the same conversation instance should be displayed as the same conversation is used each time. Transient should also be false each time since it is a long running conversation.

What is happening now is that even when you click to make the conversation long running, it is still using a new conversation each time (the conversation id number keeps incrementing and transient is still true).

Cheers,

Andy

glassfishrobot commented 14 years ago

@glassfishrobot Commented rogerk said: The fix for this was:

1. export org.jboss.weld.jsf package in weld osgi bundle pom 2. add ConversationAwareViewHandler in weld integration faces-config.xml (this was not documented in weld ref doc).

I've verified with the poster that the fix works:

"Hey Roger, Success! Thanks for getting back to me on this, the solution you gave me with the new osgi bundle and integration files works just fine. Sorry I left out the test plan, I had some other things going on yesterday so I didn't get to document it as I had planned. I have gone ahead and documented the test plan anyway just for future reference. Thanks again, Cheers,

Andy Gibson "

This fix sill have to go into the next integration.

glassfishrobot commented 15 years ago

@glassfishrobot Commented File: weld-numberguess-sources.jar Attached By: agibson77

glassfishrobot commented 15 years ago

@glassfishrobot Commented File: weld-numberguess.war Attached By: agibson77

glassfishrobot commented 15 years ago

@glassfishrobot Commented Was assigned to rogerk

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-11000

glassfishrobot commented 15 years ago

@glassfishrobot Commented Reported by agibson77

glassfishrobot commented 14 years ago

@glassfishrobot Commented Marked as fixed on Friday, November 13th 2009, 1:33:20 am