[JBoss Seam] - Transactions in Perstistence Context
by bfo81
Sorry for my late answer :).
Those transactions are independent from each other. But step by step:
During the existence of an Extended Persistence Context there can be multiple Java Transactions (JTA).
And each Java Transaction will encapsulate write accesses to the database in a database transaction, if necessary (but I'm not sure about that). Don't know what about read accesses ;).
Usually (i.e. in a Stateless or Stateful Bean with default transaction stuff) changes to entities get written to the database at the end of a method. And those changes are encapsulated in a transaction (which is created by the EJB framework).
You might even write changes explicitely to the database with em.flush() before a method ends. Then the SQL-Statements are created immediately and submitted to the database, so you can react to exceptions if necessary (e.g. when violating db constraints).
But I must confess, I am not 100% sure at which point in time a transaction starts and ends. My imagination is like this:
- before methode starts: em.getTransaction().start().
- after method ends: em.getTransaction().commit() (or rollback() if setRollbackOnly() was called or a RuntimeException occured).
- and whenever there are Java transactions running, a database transaction is started before the first db access (e.g. set autocommit=0 in MySQL or begin tran in MS SQL). And after writing was finished, a database commit (or rollback) is called.
GAVIN? Could you take as on a ride into the deep misterys of the Java Transaction API and its interactions with the EntityManager here? Only a short comment wether my findings are correct :)
Plus some more questions I have:
- If a rollback was set (setRollbackOnly() or RuntimeException) there won't be any SQL statements sent to the database at the end of a method. If you called em.flush() before, then statements were already created and only then you need a database rollback, right?
- Ist there a SQL commit called at the end of em.flush()? If yes, and if there are e.g. constraints violated, the database rolls back the changed stuff automatically and throws an exception, right?
- How does the EntityManager know which entities changed? Does he hold a copy of every managed entity in memory and compare it to the actual entities, field by field?!? Or are there some interceptors doing some observer stuff on the entity?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990445#3990445
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990445
18 years, 1 month
[JBossWS] - Re: Log4j and Web Service question
by acxjbertr
Here's an example...
The appender I'm using:
| <appender name="SOAP" class="org.jboss.logging.appender.DailyRollingFileAppender">
| <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
| <param name="File" value="${jboss.server.home.dir}/log/soap.log"/>
| <param name="Append" value="true"/>
| <param name="Threshold" value="DEBUG"/>
| <param name="DatePattern" value="yyyy-MM-dd"/>
|
| <layout class="org.apache.log4j.PatternLayout">
| <param name="ConversionPattern" value="[%x] %d{ABSOLUTE} [%c{1}] %m%n"/>
| </layout>
| </appender>
|
The category I am using:
| <!-- set the "priority" to DEBUG to see SOAPMessage output in file "soap.log" -->
| <category name="jbossws.SOAPMessage">
| <priority value="DEBUG"/>
| <appender-ref ref="SOAP"/>
| </category>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990443#3990443
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990443
18 years, 1 month
[JBoss Seam] - Seam-gen generated entity and @Embeddable class problem
by jlemoine
Hi,
I'm a total newbie with Seam/Hibernate, and I encounter a problem as I play with my first Seam-gen generated Entity. (1.1.0CR1 + adequate jbossAS)
I would like to create a Country entity, that has an ISO code, an Int'l spelling name and a local name. Just like "JP, Japan, ??".
Since I plan to have a lot of stuff with this kind of Int'l / local names, I've tuned the Country class like this :
@Entity(country)
| public class Country ... {
| ...
| // private String name;
| private Name name;
| ...
|
| public Name getName(){
| return this.name;
| }
| public void setName(Name name){
| this.name = name;
| }
| }
This seems OK regarding Hibernate's ref. manual.
Then, I wrote the following Name class :
@Embeddable
| public class Name{
| private String local;
| private String intl;
|
| // getters and setters
| ...
| }
I've also adapted the default countryList.xhtml and country.xhtml accordingly.
So far so good. Now I seam-explode my project and start jbossAS.
I access the default countryList page (empty), click "Create", type in the data, and save.
The page redraws and shows beside the 2 names (translated from the French error messages) :
"intl" : error while updating the data
"local" : error while updating the data
So, I manually create a row in the DB (MySQL), and go back to the country list. It displays the new row. Good.
So why can JSF/SEAM/Hibernate access the country.name.local data in countryList.xhtml, but fails to update countryHome.instance.name.local in country.xhtml ?
BTW, there's just no error message in jboss's console.
I have tried without the Name class, and works perfectly. But I'd prefer the @Embeddable class solution.
Any idea ?
Thanks for your help. It would be cool I get it to work before I go on exploring entity associations...
Regards,
Jean
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990440#3990440
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990440
18 years, 1 month
[Security & JAAS/JBoss] - Programmatic Login Advice
by pander
Hi,
I am running JBOSS 4.05GA and using FORM based authentication. Everything in my webapp, including the security/authentication is working fine, however, a new requirement has emerged which means that a windows application which opens up a browser and requests a page within my webapp must be able to login. I have setup a JSP for testing (not a protected resource) that accepts a username and password and attempts a programmatic login and then to redirect to the user's homepage within the webapp.
Here is how I have been trying to get this to work.
| <%
| UsernamePasswordHandler handler = new UsernamePasswordHandler("userxxx","passwordxxx");
| LoginContext lc = null;
|
| try
| {
| lc = new LoginContext("MySecurityRealm", handler);
| lc.login();
| log.info("We're cookin on gas!");
|
| // Everything from here on should automatically be associated with
| // the Subject authenticated by the login
|
| } catch (Exception e) {
| // handle exception
| log.error(e.getMessage());
| }
|
| %>
| <c:redirect url="/homePage.do"/>
|
I have a custom written login module within "MySecurityRealm" which inherits from DatabaseServerLoginModule and performs my webapp logins. I included debug inside the class to see what was happening and the call by lc.login() in the code above correctly calls and executes a user login within my realm (defined in my login-config.xml) and returns without error. I can see in the server logs the database queries to authenticate the user and get their roles etc. and that these all seem fine, however, I think I must be missing some code as I'm guessing that perhaps the login credentials are not being populated somewhere where they are required as the redirect to homePage.do simply sends me straight back to the normal "FORM based" login of my webapp.
Can anyone help me out or point me in the direction of what is missing or perhaps suggest an alternative? I've heard that the Jakarta Commons HttpClient API provides methods for performing a programmatic login.... should I be using this instead?
Any help is greatly appreciated.
Kind Regards,
Paul.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990437#3990437
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990437
18 years, 1 month
[JBoss Seam] - Re: CR1 -> CR2 Problem: PropertyNotFoundException: Property
by bsmithjj
I just moved up to Seam 1.1.0.CR2 - my SeamTest(s) are having the same problem:
| 08:30:54,975 ERROR org.jboss.seam.interceptors.ExceptionInterceptor.(handle:370) - redirecting to debug page
| javax.ejb.EJBException: javax.el.PropertyNotFoundException: Property 'jboss' is not found on type: org.jboss.seam.Namesp
| ace
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
| at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
| at $Proxy95.getMailConfiguration(Unknown Source)
| at com.evergreen.accesscontrol.MailConfigurationEditor$$FastClassByCGLIB$$b5b2a641.invoke(<generated>)
| at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
| at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:69)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
| at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
| at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
| at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:78)
| at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:47)
| at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$66e61836.getMailConfiguration(<generated>)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:102)
| at org.jboss.seam.Component.callComponentMethod(Component.java:1793)
| at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1680)
| at org.jboss.seam.Component.getInstance(Component.java:1617)
| at org.jboss.seam.Component.getInstance(Component.java:1594)
| at org.jboss.seam.Component.getInstance(Component.java:1588)
| at org.jboss.seam.mock.SeamTest.getInstance(SeamTest.java:112)
| at com.evergreen.accesscontrol.MailConfigurationEditorTest.access$000(MailConfigurationEditorTest.java:17)
| at com.evergreen.accesscontrol.MailConfigurationEditorTest$1.updateModelValues(MailConfigurationEditorTest.java:
| 33)
| at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:465)
| at com.evergreen.accesscontrol.MailConfigurationEditorTest.test_saveMailConfiguration(MailConfigurationEditorTes
| t.java:24)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
| at org.testng.internal.Invoker.invokeMethod(Invoker.java:407)
| at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:778)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
| at org.testng.TestRunner.privateRun(TestRunner.java:682)
| at org.testng.TestRunner.run(TestRunner.java:566)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:220)
| at org.testng.SuiteRunner.run(SuiteRunner.java:146)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:713)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:676)
| at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64)
| at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
| at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
| at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
| Caused by: javax.el.PropertyNotFoundException: Property 'jboss' is not found on type: org.jboss.seam.Namespace
| at javax.el.BeanELResolver.getValue(BeanELResolver.java:230)
| at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:135)
| at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
| at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
| at org.jboss.seam.util.UnifiedELValueBinding.getValue(UnifiedELValueBinding.java:34)
| at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:51)
| at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1668)
| at org.jboss.seam.Component.getInstance(Component.java:1617)
| at org.jboss.seam.Component.getInstance(Component.java:1594)
| at org.jboss.seam.Component.getInstanceToInject(Component.java:1844)
| at org.jboss.seam.Component.injectFields(Component.java:1344)
| at org.jboss.seam.Component.inject(Component.java:1114)
| at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:48)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:23)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor
| .java:51)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
| at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
| at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerIntercep
| tor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
| ... 73 more
| Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 13.812 sec <<< FAILURE!
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990436#3990436
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990436
18 years, 1 month