[JCA/JBoss] - Re: Passing current user identity to the back-end database
by adrianï¼ jboss.org
I'm going to bounce you around. ;-)
The problem you have is really a Seam problem.
That's because you already solved the problem you were trying to solve.
JCA SIDE
The configuration you have looks correct to me,
provided you are running in a context where somebody has logged in.
You don't have a default user/password so the datasource will be unusable in
other contexts.
That means your JCA issue is resolved.
SEAM SIDE
You don't use the testDBRealm within Seam, you need to provide a real
mechanism to validate users and passwords.
The JCA policy is for the question "what user/password should I use to access the
database?". Your answer is "use the subject established on the thread".
The Seam policy is for the question "how do I know the user/password typed in
by the user is correct?". Your answer such be a real validation mechanism
NOT "use what is already established on thread" which is most likely nothing. :-)
This real policy will establish the subject on the thread.
WHY THIS IS REALLY A SEAM/HIBERNATE/EJB3 QUESTION
Your real problem is that there is some initialization
during deployment. This runs on the deployment thread.
There has been no login on that thread.
You don't have a default user/password for such contexts so it is going to fail.
If you don't want to specify a default then you need some hook or configuration
where you can say "during deployment I want you to login as this user/password".
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063694#4063694
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4063694
19Â years
[Tomcat, HTTPD, Servlets & JSP] - Re: Cookies lost when included JSP file used
by weisinger
"jfrederic.clere(a)jboss.com" wrote : The cookies in the included JSP pages are ignored.
You're right. I see that under the JSP spec description for the include directive:
http://sdlc-esd.sun.com/ESD24/JSCDL/jsp/2.1-fr/jsp-2_1-fr-spec.pdf?AuthPa...
anonymous wrote : An included page cannot change the response status code or set headers. This precludes invoking methods like setCookie.
| Attempts to invoke these methods will be ignored.
| The constraint is equivalent to the one imposed on the include method of the RequestDispatcher class.
The workaround seems to be to have the base jsp file create the cookies.
But doing that also seems to fail. Flipping around the example files I used above, the following also fails to create the cookie. Just including the file seemed to cause it to fail to create the cookie.
jsptest.jsp
<%@ page contentType="text/html" %>
|
| <jsp:include page="./cookietest.jsp" flush="true"/>
|
| <jsp:directive.page import="javax.servlet.http.Cookie"/>
| <jsp:scriptlet><![CDATA[
| Cookie c = new Cookie("NewCookie","Data for Cooki");
| out.println(c.getName()+": "+c.getValue()+"<br/>");
| response.addCookie(c);
| ]]></jsp:scriptlet>
|
| <html><body>
| <center><b>JSP Test</b></center>
| </body></html>
cookietest.jsp
<%@ page contentType="text/html" %>
| <html><body>
| <p>
| Hello from included page.
| </p>
| </body></html>
After commenting out the include, the cookies show up.
Is this what I should expect? Is there something else that I need to do?
<!-- jsp:include page="./cookietest.jsp" flush="true"/ -->
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063691#4063691
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4063691
19Â years
[JBoss Seam] - Re: StaleStateException from entity activation
by matt.drees
Ok, I've reproduced this situation in a simple test:
| public class PassivatedEntityInParentConversationTest extends SeamTest {
|
| @Test
| public void test() throws Exception {
| String cid = new FacesRequest("/page.xhtml") {
| @Override
| protected void invokeApplication() throws Exception {
| Bar bar = new Bar();
| bar.setName("bar1");
| EntityManager entityManager = (EntityManager) getValue("#{entityManager}");
| entityManager.persist(bar);
| Contexts.getConversationContext().set("bar", bar );
| Manager.instance().beginConversation();
| }
| }.run();
|
| //bar is not passivated, because it was just added
|
| cid = new FacesRequest("/page.xhtml", cid) {
| }.run();
|
| //bar is now passivated
|
| cid = new FacesRequest("/page2.xhtml", cid) {
| @Override
| protected void invokeApplication() throws Exception {
| Manager.instance().beginNestedConversation();
| }
| }.run();
|
| cid = new FacesRequest("/page.xhtml", cid) {
| @Override
| protected void invokeApplication() throws Exception {
| Bar bar = (Bar) Contexts.getConversationContext().get("bar");
| bar.setName("bar2");
| EntityManager entityManager = (EntityManager) getValue("#{entityManager}");
| entityManager.flush();
| }
| }.run();
|
| //bar is not passivated, because it is not in the current conversation, so its wrapper still holds the old version
|
| cid = new FacesRequest("/page.xhtml", cid) {
| @Override
| protected void invokeApplication() throws Exception {
| Manager.instance().endConversation(false);
| }
| }.run();
|
| cid = new FacesRequest("/page.xhtml", cid) {
| }.run(); //exception occurs here at ConversationContext.unflush
| }
| }
|
Exception:
| org.hibernate.StaleStateException: current database version number does not match passivated version number
| at org.jboss.seam.persistence.HibernatePersistenceProvider.checkVersion(HibernatePersistenceProvider.java:174)
| at org.jboss.seam.persistence.HibernatePersistenceProvider.checkVersion(HibernatePersistenceProvider.java:134)
| at org.jboss.seam.contexts.PassivatedEntity.checkVersion(PassivatedEntity.java:133)
| at org.jboss.seam.contexts.PassivatedEntity.getEntityFromEntityManager(PassivatedEntity.java:118)
| at org.jboss.seam.contexts.PassivatedEntity.toEntityReference(PassivatedEntity.java:73)
| at org.jboss.seam.contexts.EntityBean.activate(EntityBean.java:67)
| at org.jboss.seam.contexts.ServerConversationContext.unflush(ServerConversationContext.java:234)
| at org.jboss.seam.contexts.FacesLifecycle.resumeConversation(FacesLifecycle.java:129)
| at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:373)
| at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:211)
| at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184)
| at org.jboss.seam.mock.BaseSeamTest$Request.restoreViewPhase(BaseSeamTest.java:706)
| at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:544)
| at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:487)
| at org.uscm.crs.PassivatedEntityInParentConversationTest.test(PassivatedEntityInParentConversationTest.java:59)
| 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:585)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:645)
| at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:479)
| at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:715)
| at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
| at org.testng.TestRunner.runWorkers(TestRunner.java:673)
| at org.testng.TestRunner.privateRun(TestRunner.java:620)
| at org.testng.TestRunner.run(TestRunner.java:480)
| at org.testng.SuiteRunner.runTest(SuiteRunner.java:278)
| at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:273)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:253)
| at org.testng.SuiteRunner.run(SuiteRunner.java:168)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
| at org.testng.TestNG.run(TestNG.java:719)
| at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
| at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
|
I created a jira issue.
http://jira.jboss.com/jira/browse/JBSEAM-1656
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063690#4063690
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4063690
19Â years