[JBoss-user] [EJB 3.0] - Re: JBoss 4.0.3 - EJB 3.0 - Exception caused by UNIQUE const

2006-01-19 Thread laboratory
can't fix this problem, am i doing something wrong?

My Exception:

  | @ApplicationException
  | public class CreateAccountException extends Exception {
  | 
  | public CreateAccountException(String message) {
  | super(message);
  | }
  | }
  | 

My Entity Field:

  | @Column(name=USERNAME, unique=true)
  | public String getUsername() {
  | return username;
  | }
  | public void setUsername(String username) {
  | this.username = username;
  | }
  | 

My SLSB Method:

  | public void addAccount(String username, String password) throws 
CreateAccountException {
  | Account account = new Account();
  | account.setUsername(username);
  | account.setPassword(password);
  | try {
  | entityManager.persist(account);
  | entityManager.flush();
  | } catch(ConstraintViolationException e) {
  | throw new CreateAccountException([+]ERROR CREATING 
ACCOUNT);
  | }
  | }
  | 

My Servlet Method:

  | protected void doPost(HttpServletRequest req, HttpServletResponse resp)
  | throws ServletException, IOException {
  | accountsManager.sayHello();
  | try {
  | accountsManager.addAccount(a,b);
  | accountsManager.addAccount(a,b);
  | } catch (CreateAccountException e) {
  | System.err.println(e.getMessage());
  | }
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3918369#3918369

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3918369


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnkkid=103432bid=230486dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: JBoss 4.0.3 - EJB 3.0 - Exception caused by UNIQUE const

2006-01-19 Thread laboratory
solved adding (rollback=true) to ApplicationException tnx anyway ;)

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3918371#3918371

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3918371


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnkkid=103432bid=230486dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: JBoss 4.0.3 - EJB 3.0 - Exception caused by UNIQUE const

2005-12-20 Thread Jonefun
Any checked exceptions raised should all be annotated with 
@ApplicationException so that the container does not raise them as a 
RuntimeException which is what is happening in this case.

Cheers

Jono

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3913570#3913570

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3913570


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: JBoss 4.0.3 - EJB 3.0 - Exception caused by UNIQUE const

2005-12-15 Thread trofimov
I have a similar problem.
My Slsb have method:

  | public void addUser(User user) throws Exception {
  | try {
  | em.persist(user);
  | em.flush();
  |} catch (ConstraintViolationException e) {
  | throw new UserAlreadyExistsException(
  | User already exist!, e);
  | } catch (PropertyValueException e) {
  | throw new PropertyInvalidException(e.getEntityName(), 
e.getPropertyName());
  | }
  | }
  | 

UserAlreadyExistsException it is caught, but if i catch PropertyValueException, 
PropertyInvalidException not rise!
Client recive:


  | java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to 
commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=lserver/68, 
BranchQual=, localId=68] status=STATUS_NO_TRANSACTION; - nested throwable: 
(org.hibernate.PropertyValueException: not-null property references a null or 
transient value: ru.migusoft.ent.persist.security.User.accountName)

Where I should catch PropertyValueException exception?

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3913040#3913040

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3913040


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user