[JBossWS] - using collections and complex types in web services
by santhoshitha
i am trying to use jax-ws for my web service. i have to invoke a remote method that accepts a java.uitl.List(SecurityAttr is a user defined class) as one of the parameters. i would like guidance in this regard.
1) is it possible to use jax ws for this purpose? if so, how should the complex types and collection classes be serialised?
2) i dint find much guidance or tutorials in this regard. i would be really happy if i could be directed to some documents/samples.
3) as of now i have deployed the server side of the service and i try to connect using a jax rpc client. running wstools from the client, for wsdl to java generation, gives me a class called list along with the SEI and mapping files. i dont know how to use this. i am using the servicefactoryimpl class provided by jbossws to use the jaxrpc-mapping file, but the list class doesnt accept any parameters. hence if i connect from the client and try to pass a List, it doesnt help.
Kindly guide me. Any help is much appreciated. Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016215#4016215
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016215
19Â years, 2Â months
[JBoss jBPM] - Rollback of a process using JTA inside jBPM - help
by mrudulam
The situation I am breaking my head over is this - Assume there is a simple 3 node process. Each node has its own action handler. In the second action handler, I have an update to another database (other than the jbpm). In the 3rd action handler, there is an exception. I am trying to combine nodes 2 and 3 as part of one transaction. [I am **not** having code to leave the nodes withing action handler for testing purposes]
I am using a servlet/stand alone program to instantiate the process, and using the javax.transaction.UserTransaction.begin() and commit() to demarcate transaction as show below and I am testing this out in WSAD.
The transaction is managed beautifully - commits to jbpm database and the external database works fine, if there is no exception. However, if there is an exception (in the third actionhandler), the rollback of hte jbpm process takes place only by one node. It does not seem to conform to the begin/commit demarcations. The other rollback is fine.
Can anyone tell me what is wrong with the code? Is there a wrong usage of save jbpmContext or close or anything else?
Thanks for all your help
package com.excercise.jbpm;
|
| public class JBPMTestServlet extends HttpServlet implements Servlet {
| private static JbpmConfiguration jbpmConfiguration =
| JbpmConfiguration.getInstance();
| private static final String USER_TRANSACTION_JNDI_NAME = "UserTransaction";
| private static long pid = 0L;
| private PrintWriter out = null;
| private Context ctx = null;
| private DataSource ds = null;
| private UserTransaction utx= null;
|
| public void doPost(HttpServletRequest req, HttpServletResponse resp)
| throws ServletException, IOException {
|
| resp.setContentType("text/html");
| out = resp.getWriter();
| ProcessInstance pInstance = null;
| ProcessDefinition pmpd = null;
| Token token = null;
| try {
| ctx = new InitialContext();
| } catch (NamingException e) {
| out.println("ERROR! Could not get Initial Context.");
| out.println("<br>" + e.getMessage() + "<br><pre>");
| e.printStackTrace(new PrintWriter(out));
| out.println("</pre>");
| }
|
| try
| {
| utx = (UserTransaction)
| ctx.lookup("java:comp/UserTransaction");
| System.out.println(utx);
| }
| catch (NamingException e) {
| out.println("ERROR! Could not get UserTransaction");
| out.println("<br>" + e.getMessage() + "<br><pre>");
| e.printStackTrace(new PrintWriter(out));
| out.println("</pre>");
| }
| if (ctx != null) {
| try {
| ds = (DataSource) ctx.lookup("jdbc/jbpm");
| } catch (NamingException e) {
| out.println("ERROR! Could not find DSN.");
| out.println("<br>" + e.getMessage() + "<br><pre>");
| e.printStackTrace(new PrintWriter(out));
| out.println("</pre>");
| }
| }
|
| // **************************** Creating Process Instance and signalling to node1 **************************** //
| JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
| Connection conn = null;
| try {
| utx.begin();
| conn = ds.getConnection();
| conn.setAutoCommit(true);
| jbpmContext.setConnection(conn);
| pmpd =
| jbpmContext.getGraphSession().findLatestProcessDefinition(
| "JustNodesProcess");
| pInstance = new ProcessInstance(pmpd);
| pid = pInstance.getId();
| token = pInstance.getRootToken();
| out.println(
| "Before signalling, the token is now at " + token.getNode() + "\n");
| token.signal();
| out.println(
| "After signalling, the token is now at " + token.getNode() + "\n");
| jbpmContext.save(pInstance);
| out.println("After saving...\n");
| utx.commit();
| } catch (Exception e) {
| e.printStackTrace();
| out.println(e.getMessage());
| try
| {
| utx.rollback();
| }
| catch (Exception ex)
| {
| ex.printStackTrace();
| }
| } finally {
| jbpmContext.getSession().flush();
| out.println("After flushin...\n");
| jbpmContext.close();
| out.println("After closing...\n");
|
| }
| // **************************** Signalling to node2 and node3 **************************** //
| /**
| * Note that node2 and node3 have been combined into one transaction.
| * Here we can give an exception in node3 and check if it rolls back to node2
| */
| jbpmContext = jbpmConfiguration.createJbpmContext();
| try {
| utx.begin();
| conn = ds.getConnection();
| jbpmContext.setConnection(conn);
| conn.setAutoCommit(true);
| GraphSession graphSession = jbpmContext.getGraphSession();
| pInstance = graphSession.loadProcessInstance(pid);
| pInstance.signal();
| pInstance.signal();
| jbpmContext.save(pInstance);
| utx.commit();
| } catch (Exception e) {
| e.printStackTrace();
| out.println(e.getMessage());
| try
| {
| utx.rollback();
| }
| catch (Exception ex)
| {
| ex.printStackTrace();
| }
| out.println("pInstance.hasEnded()" + pInstance.hasEnded());
| List list = pInstance.findAllTokens();
| out.println(
| "pInstance tokens size is "
| + list.size()
| + " token is "
| + ((Token) list.get(0)).getNode());
| return;
| } finally {
| jbpmContext.getSession().flush();
| jbpmContext.close();
| }
| // **************************** Signalling to End state **************************** //
| jbpmContext = jbpmConfiguration.createJbpmContext();
| try {
| utx.begin();
| conn = ds.getConnection();
| conn.setAutoCommit(true);
| jbpmContext.setConnection(conn);
| GraphSession graphSession = jbpmContext.getGraphSession();
| pInstance = graphSession.loadProcessInstance(pid);
| pInstance.signal();
| jbpmContext.save(pInstance);
| utx.commit();
| } catch (Exception e) {
| e.printStackTrace();
| out.println(e.getMessage());
| try
| {
| utx.rollback();
| }
| catch (Exception ex)
| {
| ex.printStackTrace();
| }
| return;
| } finally {
| jbpmContext.getSession().flush();
| jbpmContext.close();
| }
| return;
| }
| }
|
And the jbpm configuration is as shown below
<jbpm-configuration>
|
| <jbpm-context>
| <!-- <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" /> -->
| <service name="persistence">
| <factory>
| <bean name="org.jbpm.persistence.db.DbPersistenceServiceFactory" class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
| <field name="isTransactionEnabled"><false /></field>
| </bean>
| </factory>
| </service>
| <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
| <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
| <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
| <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
| </jbpm-context>
|
| <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
| <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />
| <!-- <string name="resource.hibernate.properties" value="hibernate.properties" /> -->
| <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
| <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
| <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
| <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
| <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
| <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
| <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
|
| <bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
| <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
| <long name="jbpm.msg.wait.timout" value="5000" singleton="true" />
|
| </jbpm-configuration>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016212#4016212
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016212
19Â years, 2Â months
[JBoss Seam] - Re: Please Help (multiple row operations in a data table)
by ask4saif
Thanx gavin for your reply, its very nice to see you helping all the people. thank you very much.
here is the code:
| public class SecretQuestionsAction implements SecretQuestionsLocal{
|
|
| @PersistenceContext(unitName="Database")
| protected EntityManager em;
|
| @In(required=false,value="SecretQuestions")
| @Out(required=false,value="SecretQuestions")
| private SecretQuestions secretQuestions;
|
| @DataModel
| private List <SecretQuestions> allSecretQuestionsList;
|
| @DataModelSelection(value="allSecretQuestionsList")
| private SecretQuestions selectedSecretQuestion;
|
| @In
| private Context sessionContext;
|
| @In(create=true)
| FacesMessages facesMessages;
|
| String acknowledge = null;
|
| @Out(scope=ScopeType.CONVERSATION,required=false)
| Map<SecretQuestions, Boolean> secQuestionSelections;
|
|
| /*--------------------------------------------------------------------*/
| public String deleteSelection(){
| System.out.println("In the delete selection method.");
| for (SecretQuestions item: allSecretQuestionsList) {
| Boolean selected = secQuestionSelections.get(item);
| if (selected!=null && selected) {
| secQuestionSelections.put(item, false);
| System.out.println(item.toString());
| // delete(item);
|
| }
| }
|
| return null;
| }
| /*--------------------------------------------------------------------*/
|
|
This was the method i want to call from my xhtml page. And now this is the jsf code in my xhtml page.
|
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:c="http://java.sun.com/jstl/core"
| xmlns:t="http://myfaces.apache.org/tomahawk" >
| <html>
| <head>
| <title>:: Secret Questions List </title>
| />
|
| </head>
| <body>
| <f:view>
| <ui:include src="../menus/setupmenu.xhtml"/>
|
| <f:subview id="allSecretQuestionsList" rendered="#{!empty(allSecretQuestionsList)}">
|
| <table align="center">
| <tr>
| <td align="center">
| <f:verbatim>
| <p><h4>Secret Questions List</h4></p>
| </f:verbatim>
| </td>
| </tr>
| <tr>
| <td align="center">
| <h:form>
| <h:dataTable id="secquestionslist" rows="5" value="#{allSecretQuestionsList}" var="SecretQuestions" >
| <h:column>
| <f:facet name="header">
| <h:outputText value="Select" />
| </f:facet>
| <h:selectBooleanCheckbox value="#{secQuestionSelections[SecretQuestions]}"/>
| </h:column>
|
| <h:column>
| <f:facet name="header">
| <h:outputText value="Question"/>
| </f:facet>
| <h:outputText value="#{SecretQuestions.secretQuestion}"/>
| </h:column>
|
| <h:column>
| <f:facet name="header">
| <h:outputText value="Action" />
| </f:facet>
| <h:commandButton value="Details" action="#{SecretQuestionsAction.showSecretQuestionDetails}"
| <c:if test="${CustomerLoginAction.update}">
| <h:commandButton value="Update" action="#{SecretQuestionsAction.loadSecretQuestion}"
| </c:if>
|
| </h:column>
| </h:dataTable>
|
| <h:commandButton action="#{SecretQuestionsAction.deleteSelection}" value="Delete Selected"/>
|
| <h:panelGrid columns="1" align="center">
| <t:dataScroller id="scroll_1"
| for="secquestionslist"
| fastStep="5"
| pageCountVar="pageCount"
| pageIndexVar="pageIndex"
| styleClass="scroller"
| paginator="true"
| paginatorMaxPages="5"
| paginatorTableClass="paginator"
| paginatorActiveColumnStyle="font-weight:bold;"
| immediate="true" >
| <f:facet name="first" >
| <t:graphicImage url="../images/arrow-first.gif" border="1" />
| </f:facet>
| <f:facet name="last">
| <t:graphicImage url="../images/arrow-last.gif" border="1" />
| </f:facet>
| <f:facet name="previous" >
| <t:graphicImage url="../images/arrow-previous.gif" border="1" />
| </f:facet>
| <f:facet name="next">
| <t:graphicImage url="../images/arrow-next.gif" border="1" />
| </f:facet>
| <f:facet name="fastforward">
| <t:graphicImage url="../images/arrow-ff.gif" border="1" />
| </f:facet>
| <f:facet name="fastrewind">
| <t:graphicImage url="../images/arrow-fr.gif" border="1" />
| </f:facet>
| </t:dataScroller>
| </h:panelGrid>
| </h:form>
| </td>
| </tr>
|
| <tr>
| <td colspan="5" align="left">
| <c:if test="${CustomerLoginAction.create}">
| <h:form id="navigform">
| <h:commandButton id="newsecretquestion" value="Add Secret Qustion" action="#{SecretQuestionsAction.toCreateForm}" />
| </h:form>
| </c:if>
| </td>
| </tr>
| </table>
| </f:subview>
| </f:view>
| </body>
| </html>
|
| </ui:composition>
|
|
Now the problem is whenever i press some command button, it performs no action. And if i remove this part "[SecretQuestions]" from the value attribute of checkbox, the buttons start working. But I can not do multiple deletion. I am really stuck here.
thanx in advance
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016209#4016209
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016209
19Â years, 2Â months