[JBoss Seam] - Conversation ends on its own
by vikramchhetryy
Hi All,
I am trying to edit User details in a very unorthodox manner, I dont know if this is cause for Conversation problem.
My Code:-
| public class CallCenterAgentEditAction implements CallCenterAgentEdit {
|
| @Logger
| private Log log;
|
| @PersistenceContext
| private EntityManager entityManager;
|
| @Out(required = false)
| Person person;
| @Out(required = false)
| Account account;
| @Out(required = false)
| PersonContactDetail personContactDetail;
| @Out(required = false)
| Roles roles;
|
| @In
| FacesMessages facesMessages;
|
| public String prevSelectedCallCenterAgentDetails() {
| log.info("Inside editSelectedCallCenterAgentDetails method ");
|
| log.info("Exiting editSelectedCallCenterAgentDetails method");
| return "callCenterAgentEditPrev.xhtml";
| }
|
| @Begin
| public void getSelectedCallCenterAgentDetails(Account acc) {
| log.info("Inside getSelectedCallCenterAgentDetails method");
|
| int personId = acc.getPerson().getIpersonId();
|
| person = (Person) entityManager.createQuery(
| "from Person p " + "where " + "p.ipersonId = :personId ")
| .setParameter("personId", personId).getSingleResult();
|
| personContactDetail = (PersonContactDetail) entityManager.createQuery(
| "from PersonContactDetail p " + "where "
| + "p.person.ipersonId = :personId ").setParameter(
| "personId", personId).getSingleResult();
|
| int roleId = (Integer) entityManager.createQuery(
| "select pr.roles.iroleId from PersonRoles pr " + "where "
| + "pr.person.ipersonId = :personId ").setParameter(
| "personId", personId).getSingleResult();
|
| roles = new Roles();
| roles.setIroleId(roleId);
| account = acc;
| log.info("Exiting getSelectedCallCenterAgentDetails method");
| }
|
| @End
| public void updateCallCenterAgentDetails() {
| log.info("Inside updateCallCenterAgentDetails method");
| CallCenterAgent callCenterAgent = new CallCenterAgent();
| PersonRoles personRoles = new PersonRoles();
| Date date = new Date();
| log.info("After Creating object");
| person.setDtUpdated(date);
| account.setDtUpdated(date);
| personContactDetail.setDtUpdated(date);
|
| callCenterAgent.setIcallCenterAgentId(person.getIpersonId());
| callCenterAgent.setDtUpdated(date);
|
| personRoles.getPerson().setIpersonId(person.getIpersonId());
| personRoles.getPerson().setIpersonId(person.getIpersonId());
| personRoles.getRoles().setIroleId(roles.getIroleId());
|
| log.info("Updating the database");
| entityManager.merge(person);
| entityManager.merge(account);
| entityManager.merge(personContactDetail);
| entityManager.merge(personRoles);
| entityManager.merge(callCenterAgent);
| facesMessages.add("Successfully updated the Agent");
| log.info("Exiting updateCallCenterAgentDetails method");
| }
|
| @Remove
| public void destroy() {
| }
|
| public String editAgentMoveBack() {
| return "/callCenterAgentAdd.xhtml";
| }
|
| @End
| public void cancel() {
| }
|
| }
|
<page view-id="/callCenterAgentManage.xhtml" login-required="true">
| <navigation from-action="#{callCenterAgentEdit.getSelectedCallCenterAgentDetails(details)}">
| <redirect view-id="/callCenterAgentEdit.xhtml" />
| </navigation>
|
| <navigation from-action="#{callCenterAgentManage.updateCallCenterAgentDetails}">
| <redirect view-id="/callCenterAgentManage.xhtml" />
| </navigation>
|
| <navigation from-action="#{callCenterAgentManage.cancel}">
| <redirect view-id="/callCenterAgentManage.xhtml" />
| </navigation>
|
| </page>
|
edit xhtml
| <s:decorate id="fNameDecoration" template="layout/edit.xhtml">
| <ui:define name="label">First Name</ui:define>
| <h:inputText id="fName" required="true"
| value="#{person.strFirstName}">
| <a:support event="onblur" reRender="fNameDecoration" />
| </h:inputText>
| </s:decorate>
|
when i try to change the details the conversation ends and after some time when I see the server logs it says multiple threads running and the screen hangs.
Can anyone help me get througn this?
Any help would be appreciated.
-Vikram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118929#4118929
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118929
18 years, 6 months
[EJB 3.0] - Re: Accessing EJB3s through a firewall
by magnus.ahlander
Thanks for your advice.
Actually I have a working configuration, but with the inconvenience of having to configure remote bindings in the jboss.xml file of my EAR for all beans I want to remotely access:
<session>
| <ejb-name>TestBean</ejb-name>
| <remote-binding>
| <client-bind-url>socket://<external_host_name>:3873</client-bind-url>
| </remote-binding>
| </session>
|
This is inconvenient because developers don't necessarily know where the EAR is going to be deployed at build time. The application deployer is therefore forced to make configurations within the EAR before deploy.
I wonder if setting -Djava.rmi.server.useLocalHostname=true has any effect if having set -Djava.rmi.server.hostname=<external_host_name>? Seems like no according to
http://manuales.gfc.edu.co/java/manual/guide/rmi/faq.html#nethostname
My configuration:
* JBossAS 4.2.1 GA
* Using -Djava.rmi.server.hostname=<external_host_name> when starting JBossAS
* Using -b 0.0.0.0 when starting JBossAS
* Entry <internal_ip> <external_host_name> in C:\Windows\System32\drivers\etc\hosts
* Remote binding in jboss.xml for all beans remotely accessed <remote-binding>
| <client-bind-url>socket://<external_host_name>:3873</client-bind-url>
| </remote-binding>
|
Regards,
Magnus
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118922#4118922
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118922
18 years, 6 months
[JBoss Seam] - Trouble connecting to built-in HSQL using SQuirreL
by siegfried@heintze.com
I'm following the instructions at http://wiki.jboss.org/wiki/Wiki.jsp?page=NukesUsingHSQLDB to connect to the interal HSQL built-into JBoss. I want to see the results of my interaction with the web interface.
I'm running the initial helloworld application from "JBoss Seam" by Yuan and Heute.
When I try to connect to the internal HSQL database using SQirreL, I get "JBoss: socket creation error".
What am I doing wrong?
Thanks,
Siegfried
| ava.sql.SQLException: socket creation error
| at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
| at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
| at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
| at org.hsqldb.jdbcDriver.connect(Unknown Source)
| at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
| at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.execute(OpenConnectionCommand.java:97)
| at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.run(ConnectToAliasCommand.java:279)
| at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:82)
| at java.lang.Thread.run(Thread.java:619)
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118919#4118919
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118919
18 years, 6 months
[JBoss jBPM] - JBPM-3.2.2 Migrated to Oracle 10g, Hibernate_Sequence is acce
by soumya_in
Hi All,
I have migrated JBPM in Oracle 10g but I have encountered a problem regarding Hibernate_sequence that has been provided with the given Oracle script.
Actually when my JBPM was associated with Hypersonic after each deployment the Process_ID is getting increased evenly and with an interval of 1. e.g Process A if I deploy it gets it's ID as 1,then the next process deployed get it's ID 2 and so on.....But in Oracle,the scenario is completely uneven.
I changed the hibenate.cfg.xml and made the following changes......Uncomment the following section
<property name="hibernate.show_sql">true</property>
| <property name="hibernate.format_sql">true</property>
| <property name="hibernate.use_sql_comments">true</property>
Then I found that due to dependency of different tables and as the single sequence is being used by every table,sequence is accessed globally and that's why this strange behaviour is reflected in Oracle.
As compared to Hypersonic,It doesn't follow the SQL-200n standard.Sequence never accessed globally even same sequence is accessed by different table.
To eradicarte the problem what may be the possible solution?????
Any comment and suggestion is most welcome
Thanks
Soumya
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118914#4118914
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118914
18 years, 6 months
[EJB/JBoss] - What is wrong with my local ejb JNDI lookup code (or the ejb
by sairndain
I'm trying to perform a JNDI lookup on a local stateless session bean.
When I use the jboss jmx console to check the JNDI name space I get the following:
anonymous wrote : +- HandleDelegate (class: org.jboss.proxy.ejb.handle.HandleDelegateImpl)
| +- ORB (class: org.jacorb.orb.ORB)
| +- env (class: org.jnp.interfaces.NamingContext)
| | +- ejb (class: org.jnp.interfaces.NamingContext)
| | | +- DddEJBBeanLocal[link -> local/DddEJBBean@16619879] (class: javax.naming.LinkRef)
| | +- DddEJBRemoteHome[link -> DddEJBBean] (class: javax.naming.LinkRef)
The code I am using for the JNDI lookup is as follows:
private DddEJBLocal lookupDddEJBBean() {
| try {
| Context c = new InitialContext();
| DddEJBLocalHome rv = (DddEJBLocalHome) c.lookup("java:comp/env/ejb/DddEJBBeanLocal");
| return rv.create();
| } catch (NamingException ne) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
| throw new RuntimeException(ne);
| } catch (CreateException ce) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
| throw new RuntimeException(ce);
| }
| }
The ejb-jar.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
| <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
| <enterprise-beans>
| <session>
| <display-name>DddEJBSB</display-name>
| <ejb-name>DddEJBBean</ejb-name>
| <home>ddd.ejb.DddEJBRemoteHome</home>
| <remote>ddd.ejb.DddEJBRemote</remote>
| <local-home>ddd.ejb.DddEJBLocalHome</local-home>
| <local>ddd.ejb.DddEJBLocal</local>
| <ejb-class>ddd.ejb.DddEJBBean</ejb-class>
| <session-type>Stateless</session-type>
| <transaction-type>Container</transaction-type>
|
| <ejb-ref>
| <description>DddEJBBean</description>
| <ejb-link>dddEAR-ejb.jar#DddEJBBean</ejb-link>
| <ejb-ref-name>DddEJBRemoteHome</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <home>ddd.ejb.DddEJBRemoteHome</home>
| <remote>ddd.ejb.DddEJBRemote</remote>
| </ejb-ref>
|
| <ejb-local-ref>
| <description>DddEJBBean</description>
| <ejb-link>dddEAR-ejb.jar#DddEJBBean</ejb-link>
| <ejb-ref-name>ejb/DddEJBBeanLocal</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <local-home>ddd.ejb.DddEJBLocalHome</local-home>
| <local>ddd.ejb.DddEJBLocal</local>
| </ejb-local-ref>
|
| </session>
| </enterprise-beans>
| <assembly-descriptor>
| <container-transaction>
| <method>
| <ejb-name>DddEJBBean</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>Required</trans-attribute>
| </container-transaction>
| </assembly-descriptor>
| </ejb-jar>
I get the the following error:
anonymous wrote : javax.naming.NameNotFoundException: ejb not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:716)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at ddd.ejb.DddHelper.lookupDddEJBBean(DddHelper.java:32)
QUESTION#1:
What is wrong with my lookup code or the ejb-jar.xml configuration?
QUESTION#2
Are proprietary JBoss configuration files (e.g., jboss.xml) required in order to successfully perform a JNDI lookup on the above mentioned bean?
Thanks for any help! --sd
[More information... if needed]
***ddd.ejb.DddEJBBean***
package ddd.ejb;
|
| import javax.ejb.SessionBean;
| import javax.ejb.SessionContext;
|
| /**
| *
| * @author sairndain
| */
| public class DddEJBBean implements SessionBean {
|
| private SessionContext context;
|
| // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">;
|
| // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
| // TODO Add business methods or web service operations
|
| /**
| * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
| */
| public void setSessionContext(SessionContext aContext) {
| context = aContext;
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbActivate()
| */
| public void ejbActivate() {
|
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbPassivate()
| */
| public void ejbPassivate() {
|
| }
|
| /**
| * @see javax.ejb.SessionBean#ejbRemove()
| */
| public void ejbRemove() {
|
| }
|
| // </editor-fold>;
|
| /**
| * See section 7.10.3 of the EJB 2.0 specification
| * See section 7.11.3 of the EJB 2.1 specification
| */
| public void ejbCreate() {
| // TODO implement ejbCreate if necessary, acquire resources
| // This method has access to the JNDI context so resource aquisition
| // spanning all methods can be performed here such as home interfaces
| // and data sources.
| }
|
| private String field1 = "...value of field1 in DddEJBBean.java...";
| public String getField1() {
| System.out.println(".................DddEJBBean/getField1()..............");
|
| return this.field1;
| }
|
| // Add business logic below. (Right-click in editor and choose
| // "EJB Methods > Add Business Method" or "Web Service > Add Operation")
|
| }
|
***ddd.ejb.DddHelper***
package ddd.ejb;
|
| import javax.ejb.CreateException;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
|
| /**
| *
| * @author sairndain
| */
| public class DddHelper {
|
|
| private String field1 = "...value of field1 in DddHelper.java...";
| public String getField1()
| {
| System.out.println(".................DddHelper/getField1()..............");
|
| DddEJBLocal localref = this.lookupDddEJBBean();
| return localref.getField1() + this.field1;
| }
|
| private DddEJBLocal lookupDddEJBBean() {
| try {
| Context c = new InitialContext();
| DddEJBLocalHome rv = (DddEJBLocalHome) c.lookup("java:comp/env/ejb/DddEJBBeanLocal");
| return rv.create();
| } catch (NamingException ne) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
| throw new RuntimeException(ne);
| } catch (CreateException ce) {
| java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
| throw new RuntimeException(ce);
| }
| }
| }
|
***ddd.web.WelcomeJSFBean***
package ddd.web;
|
| import ddd.ejb.DddHelper;
|
| /**
| *
| * @author sairndain
| */
|
| public class WelcomeJSFBean {
|
| /** Creates a new instance of WelcomeJSFBean */
| public WelcomeJSFBean() {
| }
|
| private String field1 = "...value of field1 in WelcomeJSFBean.java...";
| public String getField1()
| {
| System.out.println(".................WelcomeJSFBean/getField1()..............");
| DddHelper dh = new DddHelper();
| return dh.getField1() + this.field1;
| }
| }
***web.xml***
<?xml version="1.0" encoding="UTF-8"?>
| <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.faces</url-pattern>
| </servlet-mapping>
| <session-config>
| <session-timeout>
| 30
| </session-timeout>
| </session-config>
| <welcome-file-list>
| <welcome-file>welcomeJSF.faces</welcome-file>
| </welcome-file-list>
| </web-app>
|
***
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118913#4118913
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118913
18 years, 6 months
[Security & JAAS/JBoss] - Re: looking for working example: custom login module extends
by ragavgomatam
I have a custom login module that is working fine with jboss 4.2.1 and jboss 5 Beta 3. Caveat is I extend the AbstractServerLoginModule NOT UsernamePasswordLoginModule. But this should not a big issue as UsernamePasswordLoginModule extends AbstractServerLoginModule. So enjoy...
Code
package com.jaas.module;
|
| import java.math.BigDecimal;
| import java.security.Principal;
| import java.security.acl.Group;
| import java.sql.SQLException;
| import java.util.Arrays;
| import java.util.Map;
| import java.util.Set;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.security.auth.Subject;
| import javax.security.auth.callback.Callback;
| import javax.security.auth.callback.CallbackHandler;
| import javax.security.auth.callback.NameCallback;
| import javax.security.auth.callback.PasswordCallback;
| import javax.security.auth.callback.UnsupportedCallbackException;
| import javax.security.auth.login.LoginException;
| import javax.sql.DataSource;
|
| import org.apache.commons.dbutils.QueryRunner;
| import org.apache.commons.dbutils.handlers.ArrayHandler;
| import org.jboss.security.SimpleGroup;
| import org.jboss.security.SimplePrincipal;
| import org.jboss.security.auth.spi.AbstractServerLoginModule;
|
| public class CustomLoginModule extends AbstractServerLoginModule {
|
| private Principal principal;
|
| private String authSql;
|
| private String rolesSql;
|
| private String name = null;
|
| private String password = null;
|
| @SuppressWarnings("unused")
| private String ssn = null;
|
| public void initialize(Subject subject, CallbackHandler callbackHandler,
| Map sharedState, Map options) {
| super.initialize(subject, callbackHandler, sharedState, options);
| this.authSql = (String) options.get("authSql");
| this.rolesSql = (String) options.get("rolesSql");
| }
|
| public boolean login() throws LoginException {
|
| //this is a protected boolean in Super class
| loginOk = false;
| if (this.callbackHandler == null) {
| throw new LoginException("No callback handler is available");
| }
|
| Callback callbacks[] = new Callback[2];
|
| callbacks[0] = new NameCallback("Name :");
| callbacks[1] = new PasswordCallback("Password :", false);
|
| try {
| this.callbackHandler.handle(callbacks);
| name = ((NameCallback) callbacks[0]).getName().trim();
| password = new String(((PasswordCallback) callbacks[1])
| .getPassword());
|
| Object[] results = (Object[]) getQueryRunner().query(authSql,
| new Object[] { name, password }, new ArrayHandler());
|
| ssn = ((BigDecimal) results[3]).toString();
| principal = new CustomPrincipal((String) results[0],
| (String) results[1], ((BigDecimal) results[2]).toString(),
| ((BigDecimal) results[3]).toString());
|
| loginOk = true;
|
| } catch (java.io.IOException ioe) {
| ioe.printStackTrace();
| throw new LoginException(ioe.toString());
| } catch (UnsupportedCallbackException ce) {
| ce.printStackTrace();
| throw new LoginException("Error: " + ce.getCallback().toString());
| } catch (SQLException ex) {
| ex.printStackTrace();
| }
| return loginOk;
| }
|
| @Override
| protected Principal getIdentity() {
| return this.principal;
| }
|
| @Override
| protected Group[] getRoleSets() {
|
| Group roleGroup = new SimpleGroup("Roles");
| Group callerPrincipal = new SimpleGroup("CallerPrincipal");
| Group[] groups = { roleGroup, callerPrincipal };
|
| try {
| Object[] grps = (Object[]) getQueryRunner().query(rolesSql,
| new Object[] { name }, new ArrayHandler());
| for (int i = 0; i < grps.length; i++) {
| roleGroup.addMember(new SimplePrincipal(((String) grps)
| .trim()));
| }
| } catch (SQLException ex) {
| ex.printStackTrace();
| }
| callerPrincipal.addMember(this.principal);
| return groups;
| }
|
| public boolean commit() throws LoginException {
|
| boolean flag = false;
|
| if (!loginOk) {
| abort();
| throw new LoginException(
| "Error: Username Password failed to authenticate ");
| }
|
| if (loginOk) {
| Set<? super Principal> setOfPrincipals = subject.getPrincipals();
| setOfPrincipals.add(this.principal);
| setOfPrincipals.addAll(Arrays.asList(this.getRoleSets()));
| flag = true;
| } else {
| flag = false;
| }
| return flag;
| }
|
| public boolean logout() {
|
| this.subject.getPrincipals().remove(this.principal);
| subject = null;
| return true;
|
| }
|
| public boolean abort() {
|
| if ((subject != null) && (this.principal != null)) {
| Set setOfPrincipals = subject.getPrincipals();
| setOfPrincipals.remove(this.principal);
| }
| subject = null;
| this.principal = null;
| return true;
|
| }
|
| private Context getContext() throws NamingException {
| return new InitialContext();
| }
|
| private DataSource getDataSource() {
| DataSource ds = null;
| try {
| ds = (DataSource) getContext().lookup("java:jdbc/OracleDS");
| } catch (NamingException ne) {
| ne.printStackTrace();
| }
| return ds;
| }
|
| private QueryRunner getQueryRunner() {
| return new QueryRunner(getDataSource());
| }
|
| }
|
|
|
My Custom Principal
Code
package com.jaas.module;
|
| import java.security.Principal;
|
| public class CustomPrincipal implements Principal {
|
| private String firstName;
|
| private String lastName;
|
| private int age;
|
| private int ssn;
|
| public String getName() {
| String name = "";
| name = this.lastName != null ? this.firstName + " " + this.lastName
| : this.firstName;
| return name;
| }
|
| public String getFirstName() {
| return this.firstName;
| }
|
| public String getLastName() {
| return this.lastName;
| }
|
| public int getAge() {
| return this.age;
| }
|
| private void setFirstName(String firstName) {
| this.firstName = firstName;
| }
|
| private void setLastName(String lastName) {
| this.lastName = lastName;
| }
|
| private void setAge(String age) {
| this.age = Integer.parseInt(age);
| }
|
| public CustomPrincipal(String fName, String lName, String age, String ssn) {
| setFirstName(fName.trim());
| if (lName != null)
| setLastName(lName.trim());
| setAge(age.trim());
| setSsn(ssn.trim());
| }
|
| public CustomPrincipal(String name) {
| setFirstName(name.trim());
| }
|
| public int getSsn() {
| return this.ssn;
| }
|
| public void setSsn(String ssn) {
| this.ssn = Integer.parseInt(ssn);
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118904#4118904
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118904
18 years, 6 months
[EJB 3.0] - Transactions broken? Trivial Hibernate example with EJB3 and
by smithmb
Hello folks,
I'm trying to create a trivial example of a transaction working correctly with MySQ L5.0.x and local-tx-datasource and Connector/J 3.x. I'm using Hibernate and EJB3, and JBoss 4.0.x. I cannot get transactions to rollback w/ SessionContext.setRollbackOnly() OR by throwing an uncaught EJB/Runtime exception.
Rolling back via the mysql command line client works great, and the tables in question are InnoDB.
Here is my documentation of the problem -- I'd love it if anyone can tell me anything that looks weird. Please help -- this is so trivial it SHOULD work!
mysql-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>MySqlDS</jndi-name>
| <connection-url>jdbc:mysql://127.0.0.1:3306/scheduler_db</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>censored</user-name>
| <password>censored</password>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
persistence.xml:
| <persistence>
| <persistence-unit name="persistence-unit">
| <jta-data-source>java:/MySqlDS</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.connection.release_mode" value="auto"/>
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
| </properties>
| </persistence-unit>
| </persistence>
|
My EJB3 session bean:
| @Stateless
| public class TestBean implements TestBeanLocal, TestBeanRemote
| {
|
| @PersistenceContext(name = "persistence-unit")
| EntityManager em;
|
| @Resource
| SessionContext ctx;
|
| public static final String RemoteJNDIName = "example/" + TestBean.class.getSimpleName() + "/remote";
| public static final String LocalJNDIName = "example/" + TestBean.class.getSimpleName() + "/local";
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void test()
| {
| Book book = new Book(null, "My first book", "Person 1");
| em.persist(book);
|
| Book book2 = new Book(null, "My second book", "Person 2");
| em.persist(book2);
|
| System.out.println("CURRENT TRANSACTION STATUS 1: " + (ctx.getRollbackOnly() ? "ROLLBACK" : "NOT ROLLBACK"));
| ctx.setRollbackOnly();
| System.out.println("CURRENT TRANSACTION STATUS 2: " + (ctx.getRollbackOnly() ? "ROLLBACK" : "NOT ROLLBACK"));
|
| Book book3 = new Book(null, "My third book", "Person 3");
| em.persist(book3);
|
| List someBooks = em.createQuery("from Book").getResultList();
|
| for (Iterator iter = someBooks.iterator(); iter.hasNext();)
| {
| Book element = (Book) iter.next();
| em.remove(element);
| }
| }
|
My test client:
| public static void main(String[] args) throws Exception
| {
| Properties properties = new Properties();
| properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| properties.put("java.naming.factory.url.pkgs", "=org.jboss.naming:org.jnp.interfaces");
| properties.put("java.naming.provider.url", "localhost:1099");
| Context context = new InitialContext(properties);
|
| TestBeanRemote beanRemote = (TestBeanRemote) context.lookup(TestBean.RemoteJNDIName);
| beanRemote.test();
| }
|
Output log from JBoss:
| 2008-01-10 17:15:40,755 DEBUG [org.jboss.remoting.transport.socket.ServerThread] WAKEUP in SERVER THREAD
| 2008-01-10 17:15:40,991 DEBUG [org.jboss.remoting.transport.socket.ServerThread] beginning dorun
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4915213685571584
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
| 2008-01-10 17:15:41,220 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
| 2008-01-10 17:15:41,224 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2008-01-10 17:15:41,224 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2008-01-10 17:15:41,352 DEBUG [org.hibernate.SQL] insert into book (title, author) values (?, ?)
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 1
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.SQL] insert into book (title, author) values (?, ?)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 2
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2008-01-10 17:15:41,421 INFO [STDOUT] CURRENT TRANSACTION STATUS 1: NOT ROLLBACK
| 2008-01-10 17:15:41,422 INFO [STDOUT] CURRENT TRANSACTION STATUS 2: ROLLBACK
| 2008-01-10 17:15:41,422 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
| 2008-01-10 17:15:41,447 DEBUG [org.jboss.remoting.transport.socket.ServerThread] begin thread wait
|
Book.java (the hibernate entity):
| @Entity
| @Table(name = "book")
| @SequenceGenerator(name = "book_sequence", sequenceName = "book_id_seq")
| public class Book implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = -9108127436362270765L;
| private Integer id;
| private String title;
| private String author;
|
| public Book()
| {
| super();
| }
|
| public Book(Integer id, String title, String author)
| {
| super();
| this.id = id;
| this.title = title;
| this.author = author;
| }
|
| @Override
| public String toString()
| {
|
| return "Book: " + getId() + " Title " + getTitle() + " Author " + getAuthor();
| }
|
| /**
| * @return the author
| */
| public String getAuthor()
| {
| return author;
| }
|
| /**
| * @param author the author to set
| */
| public void setAuthor(String author)
| {
| this.author = author;
| }
|
| /**
| * @return the id
| */
| @Id
| @GeneratedValue(strategy = GenerationType.AUTO, generator = "book_sequence")
| public Integer getId()
| {
| return id;
| }
|
| /**
| * @param id the id to set
| */
| public void setId(Integer id)
| {
| this.id = id;
| }
|
| /**
| * @return the title
| */
| public String getTitle()
| {
| return title;
| }
|
| /**
| * @param title the title to set
| */
| public void setTitle(String title)
| {
| this.title = title;
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118903#4118903
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118903
18 years, 6 months
[Messaging, JMS & JBossMQ] - InProcessMessageCount
by anant
I have an application that sends several JMS messages to a queue with one MDB that listens for messages on that queue. Under heavy loads (hundreds of messages being sent) I notice that the queue fills up. This is expected since the work associated with the MDB could take some time (the rate at which messages are processed is slower than the rate they are being added to the queue). CPU utilization is not at 100% when this is happening. I noticed that the InProcessMessageCount reaches 16 when this occurs and the QueueDepth begins to increase (and subsequently decreases once messages stop being sent). My questions are why the InProcessMessageCount always reaches 16, and if this value can be changed. I would think that this limit would be bounded by the resources of the machine it is running on, but it doesn't seem to be the case. It always stops at 16.
TIA
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118902#4118902
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118902
18 years, 6 months
[Security & JAAS/JBoss] - Re: Can I create a login .war module that my other .war modu
by ragavgomatam
Answer is no. Make it a Custom Jaas Module & sprinkle <security-constraint>
| <web-resource-collection>
| <web-resource-name>SecurePages</web-resource-name>
| <description>
| Security constraint testing using custom Jaas Module
| </description>
| <url-pattern>/jsp/secure.jsp</url-pattern>
| <http-method>POST</http-method>
| <http-method>GET</http-method>
| </web-resource-collection>
| <auth-constraint>
| <description>Only let the authenticated users login</description>
| <role-name>admin</role-name>
| <role-name>webAdmin</role-name>
| </auth-constraint>
| <user-data-constraint>
| <description>Determines the transport layer security</description>
| <transport-guarantee>NONE</transport-guarantee>
| </user-data-constraint>
| </security-constraint>
| <login-config>
| <auth-method>BASIC</auth-method>
| <realm-name>JaasRealm</realm-name>
| </login-config>
| <security-role>
| <description>The Only Secure Role</description>
| <role-name>admin</role-name>
| </security-role>
| <security-role>
| <description>Another Secure Role</description>
| <role-name>webAdmin</role-name>
| </security-role> tags in your web.xml and
<security-domain>java:/jaas/MyJaas</security-domain>
jboss-web.xml. You are set.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118900#4118900
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118900
18 years, 6 months
[Security & JAAS/JBoss] - Re: Capturing client IP address
by ragavgomatam
One answer would be writing a Tomcat Valve that intercepts every HttpRequest before it make it to the container. This valve would intercept the request before your login module. I have given an example implementation. Package this in tomcat.sar , & check out how to configure this in jboss & you are set to go. Should not be too difficult
package test.tomcat;
|
| import java.io.IOException;
| import java.util.ArrayList;
| import java.util.List;
| import java.util.StringTokenizer;
|
| import javax.servlet.ServletException;
| import javax.servlet.http.HttpServletRequest;
|
| import org.apache.catalina.*;
|
| /**
| * The Tomcat valve that transfers credentials into a Principal object,
| * to provide seamless integration between Jaas and the J2EE security model.
| */
|
| public class MyValve implements Valve {
|
| public String getInfo() {
| return null;
| }
|
|
| /**
| * Looks for the Http headers in the originating request and creates a
| * Principal representing these if they exist.
| */
|
| public void invoke(Request request, Response response, ValveContext valveContext)
| throws IOException, ServletException {
|
| // Ha ! Ha !...Got the request before it makes it to Login Module...
|
| HttpRequest httpRequest = (HttpRequest)request;
| HttpServletRequest httpServletRequest = (HttpServletRequest)request.getRequest();
| List roles = new ArrayList();
| String username = (String)httpServletRequest.getHeader("myHeader");
| String rolesAsString = (String)httpServletRequest.getHeader("myList");
|
| StringTokenizer tok = new StringTokenizer(rolesAsString, ",");
| while (tok.hasMoreTokens()) {
| String token = tok.nextToken().trim();
| roles.add(token);
| }
|
| httpRequest.setUserPrincipal(new MyPrincipal(
| httpRequest.getContext().getRealm(), username, roles));
|
| // now execute all other valves
| valveContext.invokeNext(request, response);
| }
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118899#4118899
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118899
18 years, 6 months
[JBoss Tools (users)] - Re: Ant Task not dependent upon Eclipse plugins
by rob.stryker@jboss.com
Great job, wcrossman =D
In my own defense, the current ant task doesn't need the eclipse build system ;) It just needs some jars from the archives.core plugin, and 1 eclipse jar ;)
And it turns out only 1 class is needed from that eclipse jar, IPath =D
Just for further information, the build process itself in archives.core does not look once at what type of package it is (jar, ear, war, sar, etc). It doesn't affect the build process one way or the other.... as of now. There may be extensions in the future that allow other actions to be performed before or after.
Either way, great contrib. In the future I'll be trying to clean up the ant task entry point a bit, and if it's ok with you I may consider your code when doing so?
- Rob
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118888#4118888
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118888
18 years, 6 months
[JBoss Seam] - JbpmContext Transaction begin not detected
by jcarlos_andia
Hi everybody.
I have a workflow to approve users, for that I have a method with the annotation @CreateProcess that creates a ProcessInstance, which works well (creates a processInstance with no problem). In a second method I need to update the first taskInstance of the processInstance created, for that I injected the @JbpmContext jbmContext so I can make jbmContext .save(taskInstance) and now I can not create a process the error is "Transaction begin not detected, try installing transaction:ejb-transaction in components.xml". When I add an entry like this:
<transaction:ejb-transaction/>
It throws an error when starting the server stating that the entry transaction is not bound.
I also try not injecting the JbpmContext and create it from jbpmConfiguration (jbpmConfiguration.createJbpmContext) but it appears an error saying "Illegal attempt to associate a collection with two open sessions".
I have been going around doing session.merge, beginning transactions, closing a session and open it againg, etc. and nothing works. I would like to know what I am doing wrong with injecting the JbpmContext, or with creating the jbpmContext from jbpmConfiguration, or if there is another way to save a jbpm component.
All this stuff is within a SFSB with a scope of BusinessProcess. The funny part is that all this was working when I called its methods from another SFSB (the creation of the process and the updating of the task instance) but I had to change that and call my method from within my SFSB since its functionality is going to be used from various components.
I'm using Seam 2.0GA with Jboss-4.2.2.GA.
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118884#4118884
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118884
18 years, 6 months
[JBoss jBPM] - JSP compile issue inside a jstl loop
by zlegein
I am seeing a ton of these in our logs, does any one know what this is? This file does compile but it fails sometimes? I am not sure what exactly this error message is trying to tell me.
The section of code that it is complaining about is a jstl loop in a jsp that has two dynamic columns in a table.
Here is that section of code.
<c:forEach items="${programCategoryGroups}" var="programCategoryGroup" varStatus="loop">
<c:choose>
<c:when test="${loop.index % 2 == 0}">
<c:choose>
<c:when test="${lmbwebfn:contains(inquiry.programCategoryGroups, programCategoryGroup)}">
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
<spring:message code="${programCategoryGroup.resource.key}"/>
<c:if test="${(loop.index + 1) == fn:length(programCategoryGroups)}">
<c:out value="" escapeXml="false"/>
</c:if>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${lmbwebfn:contains(inquiry.programCategoryGroups, programCategoryGroup)}">
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
<spring:message code="${programCategoryGroup.resource.key}"/>
<c:out value="" escapeXml="false"/>
</c:otherwise>
</c:choose>
</c:forEach>
2007-12-06 06:55:52,877 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[jsp]] Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: ServletException in '/WEB-INF/presentations/7014/jsp/form1.jsp': Unable to compile class for JSP
Generated servlet error:
Duplicate field form1_jsp._jspx_fnmap_0
Generated servlet error:
Duplicate field form1_jsp._jspx_fnmap_0
Generated servlet error:
_jspx_fnmap_0 cannot be resolved
Generated servlet error:
_jspx_fnmap_0 cannot be resolved
An error occurred at line: 43 in the jsp file: /WEB-INF/presentations/7014/jsp/form1.jsp
Generated servlet error:
_jspx_fnmap_0 cannot be resolved
An error occurred at line: 46 in the jsp file: /WEB-INF/presentations/7014/jsp/form1.jsp
Generated servlet error:
_jspx_fnmap_0 cannot be resolved
An error occurred at line: 52 in the jsp file: /WEB-INF/presentations/7014/jsp/form1.jsp
Generated servlet error:
_jspx_fnmap_0 cannot be resolved
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:921)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
at org.apache.jsp.WEB_002dINF.presentations._7014.jsp.layout_jsp._jspx_meth_tiles_insert_4(layout_jsp.java:1221)
at org.apache.jsp.WEB_002dINF.presentations._7014.jsp.layout_jsp._jspService(layout_jsp.java:548)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:142)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:243)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1141)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:878)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at net.lmb.web.filter.UserProfileFilter.doFilter(UserProfileFilter.java:51)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.AbFilter.doFilter(AbFilter.java:154)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.TrafficFilter.doFilter(TrafficFilter.java:77)
at net.lmb.web.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:40)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.VisitorFilter.doFilter(VisitorFilter.java:89)
at net.lmb.web.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:40)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.ClientInfoFilter.doFilter(ClientInfoFilter.java:47)
at net.lmb.web.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:40)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.LocaleFilter.doFilter(LocaleFilter.java:69)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.SessionFilter.doFilter(SessionFilter.java:54)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.PageCacheFilter.doFilter(PageCacheFilter.java:29)
at net.lmb.web.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:40)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at net.lmb.web.filter.SecureRequestFilter.doFilter(SecureRequestFilter.java:46)
at net.lmb.web.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:40)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118876#4118876
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118876
18 years, 6 months
[JBossCache] - Hibernate and OptimisticTreeCache
by youngm
I've had a JBossCache+hibernate question over on the hibernate forums for a while with no responses. I was wondering if someone here might be able to help me out?
The question is:
Looking at the code in Hibernate OptimisticTreeCache it appears that Hibernate tells JBossCache to use an entity's version column for the cache's optimistic check when writing to the cache.
If the entity doesn't have a version column it appears hibernate tells JBossCache not to do a version check of any kind when updating the cache using a dummy DataVersion implementation. (Last update wins I presume?)
So, theoretically if I am using OptimisticeTreeCache with a Hibernate entity that don't contain a version column will my cache and DB remain synchronized? Is there any possible concurrent modification scenario where the 2 could become out of sync? For this particular Entity I don't care if concurrent changes step on each other as long as the cache and the db don't get out of sync when all is said and done. Does anyone on this forum have any insight for me?
Thanks,
Mike
http://forum.hibernate.org/viewtopic.php?t=981936&highlight=
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118864#4118864
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118864
18 years, 6 months
[Persistence, JBoss/CMP, Hibernate, Database] - Trivial Hibernate example with EJB3 and Hibernate, but trans
by smithmb
Hello folks,
I'm trying to create a trivial example of a transaction working correctly with MySQ L5.0.x and local-tx-datasource and Connector/J 3.x. I'm using Hibernate and EJB3, and JBoss 4.0.x. I cannot get transactions to rollback w/ SessionContext.setRollbackOnly() OR by throwing an uncaught EJB/Runtime exception.
Rolling back via the mysql command line client works great, and the tables in question are InnoDB.
Here is my documentation of the problem -- I'd love it if anyone can tell me anything that looks weird. Please help -- this is so trivial it SHOULD work!
mysql-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>MySqlDS</jndi-name>
| <connection-url>jdbc:mysql://127.0.0.1:3306/scheduler_db</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>censored</user-name>
| <password>censored</password>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
persistence.xml:
| <persistence>
| <persistence-unit name="persistence-unit">
| <jta-data-source>java:/MySqlDS</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.connection.release_mode" value="auto"/>
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
| </properties>
| </persistence-unit>
| </persistence>
|
My EJB3 session bean:
| @Stateless
| public class TestBean implements TestBeanLocal, TestBeanRemote
| {
|
| @PersistenceContext(name = "persistence-unit")
| EntityManager em;
|
| @Resource
| SessionContext ctx;
|
| public static final String RemoteJNDIName = "example/" + TestBean.class.getSimpleName() + "/remote";
| public static final String LocalJNDIName = "example/" + TestBean.class.getSimpleName() + "/local";
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void test()
| {
| Book book = new Book(null, "My first book", "Person 1");
| em.persist(book);
|
| Book book2 = new Book(null, "My second book", "Person 2");
| em.persist(book2);
|
| System.out.println("CURRENT TRANSACTION STATUS 1: " + (ctx.getRollbackOnly() ? "ROLLBACK" : "NOT ROLLBACK"));
| ctx.setRollbackOnly();
| System.out.println("CURRENT TRANSACTION STATUS 2: " + (ctx.getRollbackOnly() ? "ROLLBACK" : "NOT ROLLBACK"));
|
| Book book3 = new Book(null, "My third book", "Person 3");
| em.persist(book3);
|
| List someBooks = em.createQuery("from Book").getResultList();
|
| for (Iterator iter = someBooks.iterator(); iter.hasNext();)
| {
| Book element = (Book) iter.next();
| em.remove(element);
| }
| }
|
My test client:
| public static void main(String[] args) throws Exception
| {
| Properties properties = new Properties();
| properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| properties.put("java.naming.factory.url.pkgs", "=org.jboss.naming:org.jnp.interfaces");
| properties.put("java.naming.provider.url", "localhost:1099");
| Context context = new InitialContext(properties);
|
| TestBeanRemote beanRemote = (TestBeanRemote) context.lookup(TestBean.RemoteJNDIName);
| beanRemote.test();
| }
|
Output log from JBoss:
| 2008-01-10 17:15:40,755 DEBUG [org.jboss.remoting.transport.socket.ServerThread] WAKEUP in SERVER THREAD
| 2008-01-10 17:15:40,991 DEBUG [org.jboss.remoting.transport.socket.ServerThread] beginning dorun
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4915213685571584
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2008-01-10 17:15:41,211 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
| 2008-01-10 17:15:41,220 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
| 2008-01-10 17:15:41,224 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2008-01-10 17:15:41,224 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2008-01-10 17:15:41,352 DEBUG [org.hibernate.SQL] insert into book (title, author) values (?, ?)
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 1
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2008-01-10 17:15:41,420 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.SQL] insert into book (title, author) values (?, ?)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 2
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2008-01-10 17:15:41,421 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2008-01-10 17:15:41,421 INFO [STDOUT] CURRENT TRANSACTION STATUS 1: NOT ROLLBACK
| 2008-01-10 17:15:41,422 INFO [STDOUT] CURRENT TRANSACTION STATUS 2: ROLLBACK
| 2008-01-10 17:15:41,422 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
| 2008-01-10 17:15:41,447 DEBUG [org.jboss.remoting.transport.socket.ServerThread] begin thread wait
|
Book.java (the hibernate entity):
| @Entity
| @Table(name = "book")
| @SequenceGenerator(name = "book_sequence", sequenceName = "book_id_seq")
| public class Book implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = -9108127436362270765L;
| private Integer id;
| private String title;
| private String author;
|
| public Book()
| {
| super();
| }
|
| public Book(Integer id, String title, String author)
| {
| super();
| this.id = id;
| this.title = title;
| this.author = author;
| }
|
| @Override
| public String toString()
| {
|
| return "Book: " + getId() + " Title " + getTitle() + " Author " + getAuthor();
| }
|
| /**
| * @return the author
| */
| public String getAuthor()
| {
| return author;
| }
|
| /**
| * @param author the author to set
| */
| public void setAuthor(String author)
| {
| this.author = author;
| }
|
| /**
| * @return the id
| */
| @Id
| @GeneratedValue(strategy = GenerationType.AUTO, generator = "book_sequence")
| public Integer getId()
| {
| return id;
| }
|
| /**
| * @param id the id to set
| */
| public void setId(Integer id)
| {
| this.id = id;
| }
|
| /**
| * @return the title
| */
| public String getTitle()
| {
| return title;
| }
|
| /**
| * @param title the title to set
| */
| public void setTitle(String title)
| {
| this.title = title;
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118862#4118862
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118862
18 years, 6 months
[Installation, Configuration & DEPLOYMENT] - Re: 5.0 beta3, war class scoping problem
by PeterJ
Here are the test files:
RouteServlet.java
package peter.scope;
| import java.io.*;
| import javax.servlet.ServletException;
| import javax.servlet.http.*;
| public class RouteServlet extends HttpServlet {
| protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
| IOException {
| InEar ie = new InEar();
| String result = ie.route();
| PrintWriter out = resp.getWriter();
| out.print("<html><body><h2>" + result + "</h2></body></html>");
| }
| protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
| IOException {
| doGet(req, resp);
| }
| }
InWar.java
package peter.scope;
| public class InWar {
| public String route() {
| return "oops";
| }
| }
InEar.java
package peter.scope;
| public class InEar {
| public String route() {
| String result = null;
| try {
| result = callInWar();
| } catch (Throwable e) {
| result = "exception when calling InWar: " + e;
| }
| return result;
| }
| private String callInWar() {
| InWar id = new InWar();
| return id.route();
| }
| }
application.xml
<application>
| <display-name>Route</display-name>
| <module>
| <java>inear.jar</java>
| </module>
| </application>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
| <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
| version="2.5"
| >
| <servlet>
| <servlet-name>Route</servlet-name>
| <servlet-class>peter.scope.RouteServlet</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>Route</servlet-name>
| <url-pattern>/route</url-pattern>
| </servlet-mapping>
| <welcome-file-list>
| <welcome-file>route</welcome-file>
| </welcome-file-list>
| </web-app>
Compile the three Java source files together. Then package the files as follows:
inear.jar should contain:
peter/scope/InEar.class
inear.ear should contain:
inear.jar
META-INF/application.xml
route.war should contain:
WEB-INF/web.xml
WEB-INF/classes/peter/scope/InWar.class
WEB-INF/classes/peter/scope/RouteServlet.class
Deploy inear.ear and route.war, point a browser at http://localhost:8080/route.
When I do this on 5.0.0.Beta3, the browser displays:
anonymous wrote : oops
When I do this on 4.2.2.GA, the browser displays:
anonymous wrote : exception when calling InWar: java.lang.NoClassDefFoundError: peter/scope/InWar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118858#4118858
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118858
18 years, 6 months
[JBoss Seam] - Re: How to control end of conversations/state of stateful be
by chris.simons
I think part of the problem here is that outside of a few, small example applications provided by the gracious Seam team, there are no true examples of a large, enterprise-level application properly using Seam conversations.
Seam is so closely coupled with conversations that there is no true way of escaping them. Yet the amount of confusion over how to manage them in an Web environment where the user is truly allowed to go anywhere, do anything, start any process and end it at any time, should point out to the Seam team that *are* issues with conversations in general.
They're a great idea - but I know we're struggling with their usage. Results are unpredictable at best. The authors of Seam documentation attempt to show its great value but in practice it is hard to come by. Try using breadcrumbs based off of Seam conversations - I'll tell you upfront that it simply will cause more headaches than it is worth in a system with many pages and processes.
I think there needs to be a definitive, large-scale example on how to manage conversations in an enterprise application. There is simply too much confusion for this to be ignored.
My two cents.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118845#4118845
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118845
18 years, 6 months