[Clustering/JBoss] - Avoid service to start at startup
by rotula
I am running a clustered instance of jboss 4.2.1 GA and deploying a service app.
MyClusterService - which extends ServiceMBeanSupport - is triggered via the scheduler to run periodically.
Here is the jboss-service.xml:
| <server>
| <mbean code="org.jboss.varia.scheduler.ScheduleManager"
| name="jboss:service=ScheduleManagerJSFDemo">
| <attribute name="StartAtStartup">false</attribute>
| </mbean>
|
| <mbean code="com.jsfdemo.mbean.MyClusterService"
| name="com.jsfdemo:service=MyClusterService">
| </mbean>
|
| <mbean code="org.jboss.varia.scheduler.SingleScheduleProvider"
| name="jboss:service=HAImportScheduleProviderJSFDemo">
|
| <depends>jboss:service=ScheduleManagerJSFDemo</depends>
| <depends>com.jsfdemo:service=ImportManager</depends>
|
| <attribute name="ScheduleManagerName">jboss:service=ScheduleManagerJSFDemo</attribute>
| <attribute name="TargetName">com.jsfdemo:service=MyClusterService</attribute>
| <attribute name="TargetMethod">perform( DATE, REPETITIONS )</attribute>
| <attribute name="DateFormat" />
| <attribute name="StartDate">NOW</attribute>
| <attribute name="Period">10000</attribute>
| <attribute name="Repetitions">-1</attribute>
| </mbean>
| </server>
|
According documentation, if attribute "StartAtStartup" of ScheduleManager is set to false, the service should not trigger, which happends regardless the state of the element.
Is this anyway to avoid the service to start at startup in this case?
thank you.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122213#4122213
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122213
18 years, 6 months
[JBoss Portal] - How to access HttpSession Attributes in a portlet.
by dpaterson
I have a simple servlet that captures the login credentials and places them in the Web apps HttpSession then forwards the request to "j_security_check".
| protected void doPost(HttpServletRequest req, HttpServletResponse resp)
| throws ServletException, IOException {
| String username = req.getParameter("username");
| String password = req.getParameter("password");
| if (username != null && password != null) {
| req.getSession().setAttribute("api.username", username);
| req.getSession().setAttribute("api.password", password);
| String url = "j_security_check?j_username=" + username + "&j_password=" + password;
| String redirectUrl = resp.encodeRedirectURL(url);
| resp.sendRedirect(redirectUrl);
| }
|
| }
|
This piece is working fine but the problem is I cannot find a way to access the HttpSession attributes from a portlet. I've tried the following api call to pull these attributes out of the session but I'm only getting nulls .
| public void createContext(RenderRequest request, RenderResponse response, PortletContext pContext) throws Exception{
| PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
| PortalSession ps = context.getSession();
| username = (String)ps.getAttribute(USERNAME_ATTR);
| password = (String)ps.getAttribute(PASSWORD_ATTR);
| }
|
>From what I understand from reading the Portal Wiki is that there are three httpsessions: The portlet session, the portal session and the web app session. My servlet is defined in the portal-server.war/WEB-INF/web.xml:
| <!-- Save the login -->
| <servlet>
| <servlet-name>SaveLogin</servlet-name>
| <servlet-class>....SaveLoginServlet</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>SaveLogin</servlet-name>
| <url-pattern>/auth/portal/default/saveLogin</url-pattern>
| </servlet-mapping>
|
I would have thought this meant my PortalSession object would be wrapping the HttpSession my servlet is populating the attributes in but this does not seem to be the case.
I've spent hours looking into the API and Wiki for a way to hook into the original HttpSession via a portlet but I keep hitting a wall. Should be a simple task but the solution has thusfar eluded me.
<grovel>PLEASE HELP</grovel>
I am using the jboss-portal-2.6.3.GA all-in-one binary distribution.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122211#4122211
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122211
18 years, 6 months
[JBoss Seam] - FAILED CONFIGURATION: @BeforeClass init
by vikramchhetryy
Hi All,
When i try to run a test using ant test it throws an exception:-
| Buildfile: build.xml
|
| compiletest:
|
| copytestclasses:
|
| buildtest:
| [copy] Copying 1 file to /home/vikramc/workspace/Impact/test-build/META-INF
| [copy] Copying 1 file to /home/vikramc/workspace/Impact/test-build
|
| test:
| [testng] [Parser] Running:
| [testng] /home/vikramc/workspace/Impact/test-build/ChangePasswordActionTest.xml
|
| [testng] FAILED CONFIGURATION: @BeforeClass init
| [testng] org.jboss.deployers.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
|
| [testng] *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
|
| [testng] jboss.j2ee:jar=test-build,name=CallCenterAgentAction,service=EJB3
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@1ba5016{name=jboss.j2ee:jar=test-build,name=CallCenterAgentAction,service=EJB3 dependsOn=null whenRequired=Described resolved=false demand=persistence.units:jar=test-build.jar,unitName=Impact} **}
|
| [testng] jboss.j2ee:jar=test-build,name=CallCenterAgentEditAction,service=EJB3
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@19bf996{name=jboss.j2ee:jar=test-build,name=CallCenterAgentEditAction,service=EJB3 dependsOn=null whenRequired=Described resolved=false demand=persistence.units:jar=test-build.jar,unitName=Impact} **}
|
| [testng] jboss.j2ee:jar=test-build,name=CallCenterAgentManageAction,service=EJB3
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@7be687{name=jboss.j2ee:jar=test-build,name=CallCenterAgentManageAction,service=EJB3 dependsOn=null whenRequired=Described resolved=false demand=persistence.units:jar=test-build.jar,unitName=Impact} **}
|
| [testng] jboss.j2ee:jar=test-build,name=ChangePasswordAction,service=EJB3
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@1f39c59{name=jboss.j2ee:jar=test-build,name=ChangePasswordAction,service=EJB3 dependsOn=null whenRequired=Described resolved=false demand=persistence.units:jar=test-build.jar,unitName=Impact} **}
|
| [testng] jboss.j2ee:jar=test-build,name=DatabaseBackedList,service=EJB3
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@121dcac{name=jboss.j2ee:jar=test-build,name=DatabaseBackedList,service=EJB3 dependsOn=null whenRequired=Described resolved=false demand=persistence.units:jar=test-build.jar,unitName=Impact} **}
|
| [testng] persistence.units:jar=test-build.jar,unitName=Impact
| [testng] -> <UNKNOWN>{Described:** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@ba679e{name=persistence.units:jar=test-build.jar,unitName=Impact dependsOn=null whenRequired=Described resolved=false demand=jboss.jca:name=ImpactDatasource,service=DataSourceBinding} **}
|
|
| [testng] *** CONTEXTS IN ERROR: Name -> Error
|
| [testng] <UNKNOWN> -> ** UNRESOLVED AbstractDemandMetaData$DemandDependencyItem@ba679e{name=persistence.units:jar=test-build.jar,unitName=Impact dependsOn=null whenRequired=Described resolved=false demand=jboss.jca:name=ImpactDatasource,service=DataSourceBinding} **
|
|
| [testng] at org.jboss.embedded.DeploymentGroup.checkIncomplete(DeploymentGroup.java:151)
| [testng] at org.jboss.embedded.DeploymentGroup.process(DeploymentGroup.java:129)
| [testng] at org.jboss.embedded.Bootstrap.deployResourceBases(Bootstrap.java:307)
| [testng] at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:14)
| [testng] at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1006)
| [testng] at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:931)
| [testng] at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
| [testng] ... Removed 22 stack frames
| [testng] SKIPPED CONFIGURATION: @BeforeMethod begin
| [testng] SKIPPED CONFIGURATION: @AfterMethod end
| [testng] SKIPPED CONFIGURATION: @AfterClass cleanup
| [testng] SKIPPED: testChangePassword
|
| [testng] ===============================================
| [testng] Change Password Test
| [testng] Tests run: 1, Failures: 0, Skips: 1
| [testng] Configuration Failures: 1, Skips: 3
| [testng] ===============================================
|
|
| [testng] ===============================================
| [testng] Change Password Test
| [testng] Total tests run: 1, Failures: 0, Skips: 1
| [testng] Configuration Failures: 1, Skips: 3
| [testng] ===============================================
|
changePassword.xml
| <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
|
| <suite name="Change Password Test" verbose="2" parallel="false">
| <test name="Change Password Test">
| <classes>
| <class name="com.impact.test.ChangePasswordActionTest"/>
| </classes>
| </test>
| </suite>
build.xml
| <?xml version="1.0"?>
|
| <project name="Impact" default="deploy" basedir=".">
|
| <!-- Give user a chance to override without editing this file or typing -D -->
| <property file="${basedir}/build.properties" />
|
| <property name="profile" value="dev" />
| <property file="build-${profile}.properties" />
|
| <!-- set global properties for this build -->
| <property name="project.name" value="Impact"/>
| <property name="dist.dir" value="dist" />
| <property name="src.model.dir" value="src/model" />
| <property name="src.action.dir" value="src/action" />
| <property name="src.test.dir" value="src/test" />
| <property name="lib.dir" value="lib" />
| <property name="ear.dir" value="exploded-archives/${project.name}.ear" />
| <property name="jar.dir" value="exploded-archives/${project.name}.jar" />
| <property name="war.dir" value="exploded-archives/${project.name}.war" />
| <property name="test.dir" value="test-build" />
| <property name="bootstrap.dir" value="${basedir}/bootstrap" />
| <property name="deploy.dir" value="${jboss.home}/server/default/deploy" />
| <property name="ear.deploy.dir" value="${deploy.dir}/${project.name}.ear" />
| <property name="jar.deploy.dir" value="${ear.deploy.dir}/${project.name}.jar" />
| <property name="war.deploy.dir" value="${ear.deploy.dir}/${project.name}.war" />
| <property name="testng.jar" value="${basedir}/lib/testng.jar" />
| <property name="javac.debug" value="true" />
| <property name="javac.deprecation" value="false" />
| <property name="debug" value="false" />
|
| <!--Properties for validating configuration files -->
| <property name="validate.resources.dir" value="${basedir}/exploded-archives" />
| <property name="schema.dir" value="${basedir}/exploded-archives/schemas" />
| <property name="src.schema.dir" value="${schema.dir}/org/jboss/seam"/>
| <property name="schema.version" value="2.0" />
|
| <fileset id="lib" dir="${lib.dir}">
| <include name="*.jar" />
| </fileset>
|
| <path id="build.classpath">
| <fileset refid="lib" />
| </path>
|
| <target name="init" description="Initialize the build">
| <mkdir dir="${jar.dir}" />
| <mkdir dir="${ear.dir}" />
| <mkdir dir="${war.dir}" />
| <mkdir dir="${dist.dir}" />
| </target>
|
| <target name="compile" depends="init"
| description="Compile the Java source code"
| unless="eclipse.running">
| <javac classpathref="build.classpath"
| destdir="${jar.dir}"
| debug="${javac.debug}"
| deprecation="${javac.deprecation}"
| nowarn="on">
| <src path="${src.model.dir}" />
| <src path="${src.action.dir}" />
| </javac>
| </target>
|
| <target name="copyclasses" depends="init"
| description="Copy the classes that were compiled by eclipse"
| if="eclipse.running">
| <copy todir="${jar.dir}">
| <fileset dir="classes/model">
| <include name="**/*.class"/>
| </fileset>
| <fileset dir="classes/action">
| <include name="**/*.class"/>
| </fileset>
| </copy>
| </target>
|
| <target name="jar" depends="compile,copyclasses"
| description="Build the distribution .jar file">
| <copy todir="${jar.dir}">
| <fileset dir="${basedir}/resources">
| <include name="seam.properties" />
| </fileset>
| </copy>
| <copy todir="${jar.dir}/META-INF">
| <fileset dir="${basedir}/resources/META-INF">
| <include name="ejb-jar.xml" />
| </fileset>
| </copy>
| <copy tofile="${jar.dir}/META-INF/persistence.xml"
| file="${basedir}/resources/META-INF/persistence-${profile}.xml"
| overwrite="true"/>
| <copy tofile="${jar.dir}/import.sql"
| file="${basedir}/resources/import-${profile}.sql"
| overwrite="true"/>
| </target>
|
| <target name="war" depends="compile"
| description="Build the distribution .war file">
| <copy todir="${war.dir}">
| <fileset dir="${basedir}/view" />
| </copy>
| <copy todir="${war.dir}/WEB-INF">
| <fileset dir="${basedir}/resources/WEB-INF">
| <include name="*.*"/>
| <include name="classes/**/*.*"/>
| <exclude name="classes/**/*.class"/>
| </fileset>
| <filterset>
| <filter token="debug" value="${debug}" />
| <filter token="jndiPattern" value="${project.name}/#{ejbName}/local" />
| <filter token="embeddedEjb" value="false" />
| </filterset>
| </copy>
| <copy todir="${war.dir}/WEB-INF">
| <fileset dir="${basedir}/resources/WEB-INF">
| <include name="lib/*.*"/>
| <include name="classes/**/*.class"/>
| </fileset>
| </copy>
| <copy todir="${war.dir}/WEB-INF/lib">
| <fileset dir="${lib.dir}">
| <include name="richfaces-impl*.jar" />
| <include name="richfaces-ui*.jar" />
| <include name="oscache*.jar" />
| <include name="commons-digester.jar" />
| <include name="commons-beanutils.jar" />
| <include name="jsf-facelets.jar" />
| <include name="jboss-seam-*.jar" />
| <exclude name="jboss-seam-gen.jar" />
| </fileset>
| </copy>
| <copy todir="${war.dir}/WEB-INF/classes">
| <fileset dir="${basedir}/resources">
| <include name="messages*.properties"/>
| </fileset>
| </copy>
| </target>
|
| <target name="ear" description="Build the EAR">
| <copy todir="${ear.dir}">
| <fileset dir="${basedir}/resources">
| <include name="*jpdl.xml" />
| <include name="hibernate.cfg.xml" />
| <include name="jbpm.cfg.xml" />
| <include name="*.drl" />
| </fileset>
| <fileset dir="${lib.dir}">
| <include name="jboss-seam.jar" />
| </fileset>
| <fileset dir="${basedir}">
| <include name="lib/jbpm*.jar" />
| <include name="lib/jboss-el.jar" />
| <include name="lib/drools-*.jar"/>
| <include name="lib/janino-*.jar"/>
| <include name="lib/antlr-*.jar"/>
| <include name="lib/mvel*.jar"/>
| <include name="lib/richfaces-api*.jar" />
| </fileset>
| </copy>
| <copy todir="${ear.dir}/META-INF">
| <fileset dir="${basedir}/resources/META-INF">
| <include name="application.xml" />
| <include name="jboss-app.xml" />
| </fileset>
| </copy>
| </target>
|
| <target name="archive" depends="jar,war,ear"
| description="Package the archives">
| <jar jarfile="${dist.dir}/${project.name}.jar" basedir="${jar.dir}"/>
| <jar jarfile="${dist.dir}/${project.name}.war" basedir="${war.dir}"/>
| <jar jarfile="${dist.dir}/${project.name}.ear">
| <fileset dir="${ear.dir}"/>
| <fileset dir="${dist.dir}">
| <include name="${project.name}.jar"/>
| <include name="${project.name}.war"/>
| </fileset>
| </jar>
| </target>
|
| <target name="datasource">
| <fail unless="jboss.home">jboss.home not set</fail>
| <copy todir="${deploy.dir}">
| <fileset dir="${basedir}/resources">
| <include name="${project.name}-${profile}-ds.xml" />
| </fileset>
| </copy>
| </target>
|
| <target name="explode" depends="jar,war,ear,datasource"
| description="Deploy the exploded archive">
| <fail unless="jboss.home">jboss.home not set</fail>
|
| <mkdir dir="${jar.deploy.dir}"/>
| <mkdir dir="${war.deploy.dir}"/>
|
| <copy todir="${jar.deploy.dir}">
| <fileset dir="${jar.dir}"/>
| </copy>
| <copy todir="${war.deploy.dir}">
| <fileset dir="${war.dir}"/>
| </copy>
| <copy todir="${ear.deploy.dir}">
| <fileset dir="${ear.dir}"/>
| </copy>
| </target>
|
| <target name="unexplode" description="Undeploy the exploded archive">
| <delete failonerror="no">
| <fileset dir="${ear.deploy.dir}">
| <exclude name="**/*.jar"/>
| </fileset>
| </delete>
| <delete file="${deploy.dir}/${project.name}-${profile}-ds.xml" failonerror="no"/>
| <delete dir="${ear.deploy.dir}" failonerror="no"/>
| </target>
|
| <target name="restart" depends="explode" description="Restart the exploded archive">
| <touch file="${ear.deploy.dir}/META-INF/application.xml"/>
| </target>
|
| <target name="deploy" depends="archive,datasource" description="Deploy to JBoss AS">
| <fail unless="jboss.home">jboss.home not set</fail>
| <copy todir="${deploy.dir}" file="${dist.dir}/${project.name}.ear" />
| </target>
|
| <target name="undeploy" description="Undeploy the example from JBoss">
| <delete file="${deploy.dir}/${project.name}.ear" />
| <delete file="${deploy.dir}/${project.name}-dev-ds.xml" />
| <delete file="${deploy.dir}/${project.name}-prod-ds.xml" />
| </target>
|
| <target name="clean" description="Cleans up the build directory">
| <delete dir="${dist.dir}"/>
| <delete dir="${ear.dir}"/>
| <delete dir="${war.dir}"/>
| <delete dir="${jar.dir}"/>
| <delete dir="${src.schema.dir}" failonerror="no"/>
| <delete dir="${basedir}/test-report"/>
| <delete dir="${basedir}/test-output"/>
| <delete failonerror="no">
| <fileset dir="${test.dir}">
| <exclude name="**/*.class" if="eclipse.running"/>
| </fileset>
| </delete>
| </target>
|
| <target name="compiletest" unless="eclipse.running" description="Compile the Java source code for the tests">
| <mkdir dir="${test.dir}"/>
| <javac classpathref="build.classpath"
| destdir="${test.dir}"
| debug="${javac.debug}"
| deprecation="${javac.deprecation}"
| nowarn="on">
| <src path="${src.action.dir}" />
| <src path="${src.model.dir}" />
| <src path="${src.test.dir}" />
| </javac>
| </target>
|
| <target name="copytestclasses" if="eclipse.running" description="Copy classes compiled by eclipse to the test dir">
| <mkdir dir="${test.dir}"/>
| <copy todir="${test.dir}">
| <fileset dir="classes/model">
| <include name="**/*.class"/>
| </fileset>
| </copy>
| <copy todir="${test.dir}">
| <fileset dir="classes/action">
| <include name="**/*.class"/>
| </fileset>
| </copy>
| <copy todir="${test.dir}">
| <fileset dir="classes/test">
| <include name="**/*.class"/>
| </fileset>
| </copy>
| </target>
|
| <target name="buildtest" depends="compiletest,copytestclasses" description="Build the tests">
| <copy todir="${test.dir}">
| <fileset dir="${basedir}/resources">
| <exclude name="META-INF/persistence*.xml"/>
| <exclude name="import*.sql"/>
| <exclude name="${project.name}-*-ds.xml"/>
| </fileset>
| </copy>
| <copy tofile="${test.dir}/META-INF/persistence.xml"
| file="${basedir}/resources/META-INF/persistence-test.xml"
| overwrite="true"/>
| <copy tofile="${test.dir}/import.sql"
| file="${basedir}/resources/import-test.sql"
| overwrite="true"/>
| <copy todir="${test.dir}" flatten="true">
| <fileset dir="${src.test.dir}">
| <include name="**/*Test.xml" />
| </fileset>
| </copy>
| </target>
|
| <target name="test" depends="buildtest" description="Run the tests">
| <taskdef resource="testngtasks" classpath="${testng.jar}" />
|
| <path id="test.path">
| <path path="${test.dir}" />
| <fileset dir="${lib.dir}/test">
| <include name="*.jar"/>
| </fileset>
| <path path="${bootstrap.dir}" />
| <path refid="build.classpath" />
| </path>
|
| <testng outputdir="${basedir}/test-report">
| <classpath refid="test.path" />
| <xmlfileset dir="${test.dir}" includes="*Test.xml" />
| </testng>
| </target>
|
| <target name="validateConfiguration" depends="war,ear,jar" description="Validate the xml configuration files">
| <mkdir dir="${schema.dir}"/>
| <unjar src="${lib.dir}/jboss-seam.jar" dest="${schema.dir}">
| <patternset>
| <include name="org/jboss/seam/*.xsd"/>
| <include name="org/jboss/seam/*.dtd"/>
| </patternset>
| </unjar>
| <ant antfile="validate.xml" target="validateConfiguration" />
| </target>
|
| </project>
|
seam-2.0.1.CR1
jboss-4.2.2.GA
Any help would be appreciated.
Thanks in advance,
Vikram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122209#4122209
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122209
18 years, 6 months
[JBoss Seam] - Backing beans and richfaces ui classes
by akovcic
Hi,
I want to use some richfaces classes from richfaces-ui.jar on backing beans.
In my particular case I would like to have richtree component state saved so the state doesn't change on page refresh. To do that it's necessary to have state bound to property of type: org.richfaces.component.state.TreeState
At the same time I have an action (stateful session) bean that handles node selections. If I have a property of type: org.richfaces.component.state.TreeState on SFSB the deployment fails with ClassNotFoundException.
This is because I follow packaging as per Seam doc, and richfaces-ui.jar is only packaged in war within ear. Of course this works fine if the ui jar is placed inside ear's lib directory. I have seen other solution where tomcat's class loader configuration is changed... None of this I liked.
Also I have seen recommendation that classes from ui jar should not be used, but only ones from richfaces-api.jar. So how I save the tree state than?
The same problem I have with rich tabPanel, when I want to change active tab from backing bean's (SFSB) action method (tabPanel component is bound to a property in SFSB).
What is best practice for such cases? Maybe to have seam POJO's that would be responsible only for ui component state mangement (as I seen POJO works fine compared to SFSB), or something else?
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122205#4122205
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122205
18 years, 6 months
[JBoss Seam] - Transaction demarcation problem
by dreuzel
i need to update thousands of independent records in sheduled environment.
For efficiency reasons I need to do that in a big loop ( set of loops)
also because the underlying info is externaly organised like that.
I disabled the seam control over transactions
I'm trying to disable container management over transactions
but so far I realy can not Use transaction control in the environment
there is always something wrong !!
If not seen any effect of a flush and I'm losing all the work done
due to the fact I need to rollback a single item transaction
process
|
| Connect external
| loop
| update record
| if (fails)
| Rollback this ONLY RECORD WITHOUT ANY IMPACT
| ON THE REST OF THE ENVIRONMENT
| handle next
|
It is very important the overall process is not aborted on any individual error.
(this is what is happening in the actual case with a fail rate on 1 on 1000 this means
I never get never nothingthing done !!!!)
at this time I use following code to handle the transaction
as I'm working in a seam environment
I switched to manual transaction handling
and I'm bouncing/fighting against JTA CONTAINER - BEAN managed transactions
code :
|
| @Name("loopscan")
| @TransactionManagement(TransactionManagementType.BEAN) //kill container management
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) //suspend all active container transactions
| public class BatchTransactions
| {
| // @Logger
| private Log log;
| // @In ("#{entityManager}")
| public EntityManager em;//allow for db ACCESS
| Session ses=null;//session indicator
| String env="Init";
| // org.hibernate.Transaction txn=null;//hibernate transaction
| public BatchTransactions() {}
| public void initTransaction()
| {
| }
| public Exception sequence()
| {
| Exception errcod=null;
| org.hibernate.Transaction txn=null;//
| boolean rollback=false;
| //reset timeout
| try { env="Timeout";
| org.jboss.seam.transaction.Transaction.instance().setTransactionTimeout(60*60*10000000);
| } catch (Exception er)
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error(env+" Modifying timeout failed "+ errmsg);
| }
| // seam timeout
| try { env ="seam timeout";
| Transaction.instance().setTransactionTimeout(60*60*10000000);} catch (Exception er)
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error(env+" Modifying Seam timeout failed "+ errmsg);
| }
| //
| //connect to session
| //
| env="setup";
| ses=(Session) em.getDelegate();//get the session
|
| //
| // transaction with own error handling
| //
| try { env="Begin";// Begin the transaction ?
| txn=ses.getTransaction();
| if(!txn.isActive())
| txn.begin();// txn=ses.beginTransaction(); **********************
| // txn.setTimeout(500000);
| } catch (Exception er )
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error(env+" starting transaction failed "+ errmsg);
| }
| try {env="execute "; //ececution process
| errcod=Execute();//do the DB operations
| try {//flush the info to other users
| ses.flush();
| } catch (Exception er )
| {errcod=er;rollback=true;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error("Flush "+env+" Commiting transaction failed "+ errmsg);
| }
|
| try {//commit the information
| txn.commit();
| } catch (Exception er )
| {errcod=er;rollback=true;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| if (errmsg.indexOf("NullPointerException")>-1)
| log.error("Commit "+env+" Commit nullpointer exception failed "+ errmsg,er);
| else log.error(env+" Commiting transaction failed "+ errmsg);
| }
|
| } catch( GenericJDBCException er)
| {String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();rollback=true;
| // if (errmsg.indexOf("Cannot open connection")>-1)
| // { if (!em.isOpen()) log.info("Em session still open !");
| // try {if (ses==null) {ses=(Session) em.getDelegate();}//get the session
| // txn=ses.beginTransaction();
| log.error(env+" Cannot open connection "+ errmsg,er);
| }
| catch (Exception er) {FatalStatus();errcod=er;rollback=true;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| if (errmsg.indexOf("NullPointerException")>-1)
| log.error(env+" nullpointer exception failed "+ errmsg,er);
| else log.error(env+" overall transaction error "+ errmsg);
| }
| if (rollback)
| try {//rollback cover
| txn.rollback();
| } catch (Exception er)
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error("Rollback "+env+" Rollback transaction failed "+ errmsg +" From "+ errmsg);
| }
| //
| // detect losing the session
| //
| if (ses==null)
| { if (!(em.isOpen())) log.info("em session closed !");
| }
| return errcod;
|
| }
| /*
| */
| public void TxnSts(String env) {this.env=env;}
| public Exception Execute() throws Exception {return null;};
| public void FatalStatus() {};
| }
| {
|
As you can see most of the code is error trapping and reporting
It fails at the BEGIN transaction
stating : TransactionException err: Could not register synchronization for container transaction
The default for the bean is set to BEAN transactions
but still it considers it a Container transaction
any suggestions would be more then welcome
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122202#4122202
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122202
18 years, 6 months