[jBPM] - How To close task from FreeMarker template?
by pektop
Hello,
Assume that this is wide-spread question, but I cannot find the answer nether in documentation or in forum. The problem is that I cannot close the task to pass the transition workflow to the next task. I used taskFormExample and just added new task which uses some "dummy" form with only one button. Now when transition comes to this task from "Start" element it stops there and not going to "verify_request" task.
- What action/element should be used to close task and go to another task if .ftl template is used?
Thanks in advance,
Oleg Ladizhensky
press_the_button.ftl
| <html>
| <body>
| <form action="${form.action}" method="POST" enctype="multipart/form-data">
| <input type="submit" name="Done"/>
| </form>
| </body>
| </html>
|
process.jpdl.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process name="taskformExample_2" xmlns="http://jbpm.org/4.0/jpdl">
| <start form="be/jorambarrez/jbpm4/demo/taskform/request_vacation.ftl" g="262,16,48,48" name="start">
| <transition to="PressTheButton" g="-94,-18"/>
| </start>
| <task g="222,96,129,52" name="PressTheButton" candidate-users="peter,mary" form="be/jorambarrez/jbpm4/demo/taskform/press_the_button.ftl">
| <transition name="to verify_request" to="verify_request" g="-89,-18"/>
| </task>
| <task candidate-users="peter,mary" form="be/jorambarrez/jbpm4/demo/taskform/verify_request.ftl" g="223,180,126,52" name="verify_request">
| <transition g="40,-14" name="accept" to="Send acceptance e-mail"/>
| <transition g="-44,-17" name="reject" to="Send rejection e-mail"/>
| <transition g="-18,-20" name="Empty" to="Send Empty e-mail"/>
| </task>
| <mail g="16,264,157,40" name="Send rejection e-mail">
| <to addresses="${employee_email}"/>
| <subject>Your vacation request has been rejected</subject>
| <text>Your vacation request for ${number_of_days} has been rejected. Reason: ${reason}</text>
| <transition to="vacation_rejected"/>
| </mail>
| <mail g="205,264,163,40" name="Send acceptance e-mail">
| <to addresses="${employee_email}"/>
| <subject>Your vacation request has been accepted</subject>
| <text>Success: your vacation request for ${number_of_days} has been accepted.</text>
| <transition to="vacation_accepted"/>
| </mail>
| <end g="70,336,48,48" name="vacation_rejected"/>
| <end g="262,336,48,48" name="vacation_accepted"/>
|
| <mail g="400,264,163,40" name="Send Empty e-mail">
| <to addresses="${employee_email}"/>
| <subject>Your vacation request has been accepted</subject>
| <text>Success: your vacation request for ${number_of_days} has been accepted.</text>
| <transition to="end1"/>
| </mail>
|
|
| <end g="457,336,48,48" name="end1"/>
| <task g="222,96,129,52" name="PressTheButton" candidate-users="peter,mary" form="be/jorambarrez/jbpm4/demo/taskform/press_the_button.ftl">
| <transition name="to verify_request" to="verify_request" g="-89,-18"/>
| </task>
| </process>
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251002#4251002
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251002
16 years, 8 months
[JCA/JBoss] - Bug in connection validation code
by bortx
Hi,
We have a production environment with jboss 4.2.3. It has been working successfully until now, when we are experiencing network issues. TCP connections are broken very often. Also we noticed that a great number of tcp connections in a ESTABLISHED status were beginning to increase out of control. We have a pool of 9 max connections and we had 3 hundred of ESTABLISHED connections and rising. So we had a look at the code and noticed a bug in connection validation, in org.jboss.resource.connectionmanager.InternalManagedConnectionPool class validateConnections method.
| boolean destroyed = false;
|
| try
| {
|
| while (true)
| {
|
| ConnectionListener cl = null;
|
| synchronized (cls)
| {
| if (cls.size() == 0)
| {
| break;
| }
|
| cl = removeForFrequencyCheck();
|
| }
|
| if (cl == null)
| {
| break;
| }
|
| try
| {
|
| Set candidateSet = Collections.singleton(cl.getManagedConnection());
|
| if (mcf instanceof ValidatingManagedConnectionFactory)
| {
| ValidatingManagedConnectionFactory vcf = (ValidatingManagedConnectionFactory) mcf;
| candidateSet = vcf.getInvalidConnections(candidateSet);
|
| if (candidateSet != null && candidateSet.size() > 0)
| {
|
| if (cl.getState() != ConnectionListener.DESTROY)
| {
| doDestroy(cl);
| destroyed = true;
| }
| }
|
| }
| else
| {
| log.warn("warning: background validation was specified with a non compliant ManagedConnectionFactory interface.");
| }
|
| }
| finally
| {
| if(!destroyed)
| {
| synchronized (cls)
| {
| returnForFrequencyCheck(cl);
| }
| }
|
| }
|
| }
|
| }
| finally
| {
| permits.release();
|
| if (destroyed && shutdown.get() == false && poolParams.minSize > 0)
| {
| PoolFiller.fillPool(this);
| }
|
| }
|
What happens when you have a set of 3 connections in the pool, and when you run this validation code, the fist one is not valid and the following 2 are valid? I will tell you. Those 2 valid connections remain established but they don't return to the pool, resulting that you have 2 established connections out of control. Besides, counters don't get updated and the resource adapter turns into an inconsistent status. All of this is because you don't update destroyed variable to false on every iteration. I think it is not necesary to explain this more in detail...
So I have developed the following simple solution to fix this issue:
| boolean anyDestroyed = false;
|
| try {
|
| while (true) {
|
| boolean destroyed = false;
|
| ConnectionListener cl = null;
|
| synchronized (cls) {
| if (cls.size() == 0) {
| break;
| }
|
| cl = removeForFrequencyCheck();
|
| }
|
| if (cl == null) {
| break;
| }
|
| try {
|
| Set candidateSet = Collections.singleton(cl.getManagedConnection());
|
| if (mcf instanceof ValidatingManagedConnectionFactory) {
| ValidatingManagedConnectionFactory vcf = (ValidatingManagedConnectionFactory) mcf;
| candidateSet = vcf.getInvalidConnections(candidateSet);
|
| if (candidateSet != null && candidateSet.size() > 0) {
|
| if (cl.getState() != ConnectionListener.DESTROY) {
| doDestroy(cl);
| destroyed = true;
| anyDestroyed = true;
| }
| }
|
| } else {
| log.warn("warning: background validation was specified with a non compliant ManagedConnectionFactory interface.");
| }
|
| } finally {
| if (!destroyed) {
| synchronized (cls) {
| returnForFrequencyCheck(cl);
| }
| }
|
| }
|
| }
|
| } finally {
| permits.release();
|
| if (anyDestroyed && shutdown.get() == false && poolParams.minSize > 0) {
| PoolFiller.fillPool(this);
| }
|
| }
|
I've had a look at the jira and haven't found this bug as reported. If it has been already fixed i apologize for making you loose your time, if not, it would be so kind of you to send me one of those jboss merchandising caps as I have helped you to find several jca bugs so far... ;) Actually, I think this bug is so big that I can't understand how nobody has noticed it before...
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250999#4250999
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250999
16 years, 8 months
[Installation, Configuration & DEPLOYMENT] - Configre DIGEST authentication
by meme64310
Hi,
I try to configure DIGEST authentication to protect a web app on JBoss 5.1 and 5.0. This is how I configured login-config.xml:
| <application-policy name="MyApp">
| <authentication>
| <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
| flag="required">
| <module-option name="usersProperties">props/pbdigest-users.properties</module-option>
| <module-option name="rolesProperties">props/pb-roles.properties</module-option>
| <module-option name="hashAlgorithm">MD5</module-option>
| <module-option name="hashEncoding">rfc2617</module-option>
| <module-option name="hashUserPassword">false</module-option>
| <module-option name="hashStorePassword">true</module-option>
| <module-option name="passwordIsA1Hash">true</module-option>
| <module-option name="storeDigestCallback">
| org.jboss.security.auth.spi.RFC2617Digest
| </module-option>
| </login-module>
| </authentication>
| </application-policy>
|
Now the problem is, that it simple does not work. I cannot authenticate and I have no idea why it fails. The only thing I can think of is that I have stored plain-text-passwords in users.properties.
The whole setup works perfectly when I switch to BASIC authentication.
Unfortunately I cannot create encrypted password hashes for users.properties. I've tried this command:
| java -cp server/default/lib/jbosssx.jar org.jboss.security.auth.spi.RFC2617Digest admin2 "JBoss JMX Console" admin2
|
It does not work: I get this error: Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/security/auth/spi/RFC2617Digest
Does anybody have an idea what's wrong here?
Many thanks in advance,
Michael
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250992#4250992
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250992
16 years, 8 months
[JNDI/Naming/Network] - Trying to send e-mail using JavaMail, JBoss 5, and JNDI
by socal_javaguy
Hello there,
Am using JBoss 5.1.0GA and JDK 1.5.0_19 on OS X Leopard.
Created a working [SendMailServlet|http://tinyurl.com/SendMailServletCode].
Have now decided to refactor it into two separate classes (extract out JavaMail code to a separate class and create a ServletController).
Am also trying to use JNDI to access the connection properties in the mail-service.xml configuration file residing in JBoss.
The Mailer class contains the reusable functionality needed to send an e-mail:
| public class Mailer {
| private Session mailSession;
|
| protected void sendMsg(String email, String subject, String body)
| throws MessagingException, NamingException {
| Properties props = new Properties();
| InitialContext ictx = new InitialContext(props);
| Session mailSession = (Session) ictx.lookup("java:/Mail");
| // Session mailSessoin = Session.getDefaultInstance(props);
| String username = (String) props.get("mail.smtps.user");
| String password = (String) props.get("mail.smtps.password");
|
| MimeMessage message = new MimeMessage(mailSession);
| message.setSubject(subject);
| message.setRecipients(javax.mail.Message.RecipientType.TO,
| javax.mail.internet.InternetAddress.parse(email, false));
| message.setText(body);
| message.saveChanges();
|
| Transport transport = mailSession.getTransport("smtps");
| try {
| transport.connect(username, password);
| transport.sendMessage(message, message.getAllRecipients());
| Logger.getLogger(this.getClass()).warn("Message sent");
| }
| finally {
| transport.close();
| }
| }
| }
|
The MailController class serves as a standard Java Servlet which invokes the Mailer.class's sendMsg() method:
| public class MailController extends HttpServlet {
| /** static final HTML setting for content type */
| private static final String HTML = "text/html";
|
| myapp/** static final HTML setting for content type */
| private static final String PLAIN = "text/plain";
|
| public void doGet(HttpServletRequest request, HttpServletResponse response)
| throws ServletException, IOException {
| doPost(request, response);
| }
|
| public void doPost(HttpServletRequest request, HttpServletResponse response)
| throws ServletException, IOException {
| response.setContentType(PLAIN);
| PrintWriter out = response.getWriter();
| String mailToken = TokenUtil.getEncryptedKey();
| String body = "Hello there, " + "\n\n"
| + "Wanna play a game of golf?" + "\n\n"
| + "Please confirm: https://localhost:8443/myapp/confirm?token="
| + mailToken + "\n\n" + "-Golf USA";
| Mailer mailer = new Mailer();
| try {
| mailer.sendMsg("recipient(a)gmail.com", "Golf Invitation!", body);
| out.println("Message Sent");
| }
| catch (MessagingException e) {
| e.printStackTrace();
| }
| catch (NamingException e) {
| e.printStackTrace();
| }
| }
| }
|
Have the mail configuration set under $JBOSS_HOME/server/default/deploy/mail-service.xml:
| <server>
| <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
| <attribute name="JNDIName">java:/Mail</attribute>
| <attribute name="User">user</attribute>
| <attribute name="Password">password</attribute>
| <attribute name="Configuration">
| <configuration>
| <property name="mail.store.protocol" value="pop3"/>
| <property name="mail.transport.protocol" value="smtp"/>
| <property name="mail.user" value="user"/>
| <property name="mail.pop3.host" value="pop3.gmail.com"/>
| <property name="mail.smtp.host" value="smtp.gmail.com"/>
| <property name="mail.smtp.port" value="25"/>
| <property name="mail.from" value="user(a)gmail.com"/>
| <property name="mail.debug" value="true"/>
| </configuration>
| </attribute>
| <depends>jboss:service=Naming</depends>
| </mbean>
| </server>
|
web.xml (Deployment Descriptor):
| <servlet>
| <servlet-name>MailController</servlet-name>
| <servlet-class>com.myapp.MailController</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>MailController</servlet-name>
| <url-pattern>/sendmail</url-pattern>
| </servlet-mapping>
|
This is what is outputted when I start JBOSS and click point my browser to:
https://localhost:8443/myapp/sendmail
| [MailService] Mail Service bound to java:/Mail
|
| [STDOUT] DEBUG: JavaMail version 1.4ea
| [STDOUT] DEBUG: java.io.FileNotFoundException:
|
| /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/javamail.providers
| (No such file or directory)
|
| [STDOUT] DEBUG: !anyLoaded
| [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
| [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
|
| [STDOUT] DEBUG: getProvider() returning
| javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
|
| [STDOUT] DEBUG SMTP: useEhlo true, useAuth false
| [STDOUT] DEBUG SMTP: trying to connect to host "localhost", port 465, isSSL true
|
| [STDERR] javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465;
| nested exception is:
| java.net.ConnectException: Connection refused
| [STDERR] at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
| [STDERR] at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
| [STDERR] at javax.mail.Service.connect(Service.java:275)
| [STDERR] at javax.mail.Service.connect(Service.java:156)
| [STDERR] at javax.mail.Service.connect(Service.java:176)
| [STDERR] at com.myapp.Mailer.sendMsg(Mailer.java:45)
| [STDERR] at com.myapp.MailController.doPost(MailController.java:42)
| [STDERR] at com.myapp.MailController.doGet(MailController.java:26)
|
Why am I getting this java.net.ConnectException: Connection refused exception?
Happy programming,
Mike
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250979#4250979
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250979
16 years, 8 months
[JBoss Portal] - Re: CMSException(Access denied) for pdf or doc content
by briankous
I found that user is saved in session, but not the roles. Therefore, I changed the viewfile.jsp and pending_items.jsp so that roles are saved in the session.
I also changed the CMSPreviewServlet so that it retrieves the roles from the session and put it in JCRCMS object. Now it is working fine. The changed codes are as follows.
Following are added to the jsp's.
Set roles = new HashSet();
// Get the current authenticated subject through the JACC contract
Subject subject = (Subject)PolicyContext.getContext("javax.security.auth.Subject.container");
if (subject != null)
{
Set tmp = subject.getPrincipals(JACCPortalPrincipal.class);
JACCPortalPrincipal pp = null;
for (Iterator k = tmp.iterator(); k.hasNext();)
{
pp = (JACCPortalPrincipal) k.next();
if (pp != null)
{
break;
}
}
if (pp == null)
{
pp = new JACCPortalPrincipal(subject);
tmp.add(pp);
// Lazy create all the permission containers for the given role names
for (Iterator k = pp.getRoles().iterator(); k.hasNext();)
{
Principal role = (Principal) k.next();
roles.add(role.getName());
}
}
}
request.getSession().setAttribute("remoteRoles", roles);
Following were added to CMSPreviewServlet
Set roles = (Set)request.getSession().getAttribute("remoteRoles");
JCRCMS.setRoles(roles);
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250977#4250977
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250977
16 years, 8 months