[Persistence, JBoss/CMP, Hibernate, Database] - Re: Getting Exception for Derby Data Source
by nicolas.jouanin
Hi Alex,
It seems that the problem doesn't come from Derby, but from a jboss class which is not found , look at the class name : org.jboss.jdbc.DerbyDatabase
One solution i've found to deploy the datasource is to comment out the two following lines in your -ds.xml file :
| <depends>jboss:service=Derby</depends>
| ...
| <mbean code="org.jboss.jdbc.DerbyDatabase" name="jboss:service=Derby"/>
|
Here is a sample -ds.xml file:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!-- The Derby embedded database JCA connection factory config
| $Id: derby-ds.xml 25345 2004-11-03 13:29:58Z loubyansky $ -->
|
|
| <datasources>
| <local-tx-datasource>
|
| <!-- The jndi name of the DataSource, it is prefixed with java:/ -->
| <!-- Datasources are not available outside the virtual machine -->
| <jndi-name>EscapeKDS</jndi-name>
|
| <!-- for in-process persistent db, saved when jboss stops. The
| org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown -->
| <connection-url>jdbc:derby:${jboss.server.data.dir}${/}derby${/}localDB;create=true</connection-url>
|
| <!-- The driver class -->
| <driver-class>org.apache.derby.jdbc.EmbeddedDriver</driver-class>
|
| <!-- The login and password -->
| <user-name>sa</user-name>
| <password></password>
|
| <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
| <min-pool-size>5</min-pool-size>
|
| <!-- The maximum connections in a pool/sub-pool -->
| <max-pool-size>20</max-pool-size>
|
| <!-- The time before an unused connection is destroyed -->
| <idle-timeout-minutes>5</idle-timeout-minutes>
|
| <!-- Whether to check all statements are closed when the connection is returned to the pool,
| this is a debugging feature that should be turned off in production -->
| <track-statements/>
|
| <!-- This mbean can be used when using in process persistent derby -->
| <!--
| <depends>jboss:service=Derby</depends>
| -->
| </local-tx-datasource>
|
| <!--
| <mbean code="org.jboss.jdbc.DerbyDatabase" name="jboss:service=Derby"/>
| -->
| </datasources>
|
PS : Does someone knows where to find that org.jboss.jdbc.DerbyDatabase class, and what it does ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995224#3995224
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995224
19 years, 4 months
[JBoss Seam] - Re: Basic Seam questions
by lightbulb432
I have been looking into the whole issue of Exceptions and have several questions about how to choose and design Exceptions for a Seam application. There's quite a few questions below, but hopefully somebody could address them. (I imagine all these dumb beginner questions must be getting irritating by now, but I've really appreciated all your help!)
1) Should exceptions be checked or unchecked in Seam? I'm gonna guess that all should be unchecked because isn't that the whole reason that exceptions.xml and exception annotations exist...they handle cases where the exception propagates far enough up that the rules take effect. If you declared any exception as checked, you'd have to catch it and it would never propagate and exceptions.xml wouldn't be used, right?
2) Would exceptions.xml rules also not be used for any exception that was unchecked but that you caught in every case where it possibly could be thrown?
3) Would you expect to see more checked or unchecked user-defined exceptions in a Seam application? (Or does it totally depend upon the nature of the application, meaning there aren't universal best practices on this issue?)
4) I can't tell whether my exceptions should cause a rollback or not. What criteria might help me understand this decision more clearly? For example, should an exception in a method that makes NO updates/additions/removals to the database never cause a rollback?
What about for ones that do make changes - is it ALWAYS yes for rollbacks in this case?
5) In exceptions.xml, is there a way to return a logical outcome name for a given exception (that would be defined in the navigation rules) rather than an actual view ID for a physical page? I didn't see an attribute for render and redirect that implies this case in the DTD.
6) If there were an exception and I needed to return a page indicating an error to the user, I could do one of two things: annotate the exception with an error code, then in web.xml (or wherever it is) define a custom view to be associated with that error code; OR I could simply do a @Render or @Redirect to the same view.
So then what's the difference between returning an error code and a regular view ID? In either case, what the user would see on his screen would be the same in either case, so what criteria go into choosing one over the other?
7) An example that's got me stumped is a login() action method on a session bean. It searches for the entered login name in the database. If the login name doesn't exist, it throws a user-defined exception. I realize the questions below are application-specific, but I don't even know how to go about making these choices. Perhaps you could explain what you might do in this case and why?
A) Should this be a system or application exception?
B) If application, should it be checked or unchecked with @ApplicationException annotation?
C) If application, should it be cause a rollback or not?
D) In either case, should I let it propagate or catch it?
-Wow, so confused on this!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995221#3995221
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995221
19 years, 4 months
[EJB/JBoss] - Re: Executing Outside Transaction
by murtuza52
I have resolved this problem with @Version attribute. Those who are interested in knowing here is how i did it:
The counter entity bean is modified as follows:
| @Entity
| @Table(name = "counter")
| public class Counter implements Serializable{
|
| private String counterName;
|
| private long value;
|
| private int version;
|
| @Id
| public String getCounterName() {
| return counterName;
| }
|
| public void setCounterName(String name) {
| this.counterName = name;
| }
|
| public long getValue() {
| return value;
| }
|
| public void setValue(long value) {
| this.value = value;
| }
|
| @Version
| public int getVersion() {
| return version;
| }
|
| public void setVersion(int version) {
| this.version = version;
| }
| }
|
The update method is modified as follows:
| public long count(){
|
| Counter counter = manager.find(Counter.class, "methodA");
| manager.lock(counter, LockModeType.READ);
| if(counter==null)
| {
| counter = new Counter();
| counter.setCounterName(tableName);
| counter.setValue(1);
| manager.persist(counter);
| }
|
| long returnValue = counter.getValue();
| key.setNextKey(returnValue+1);
| manager.merge(counter);
| manager.flush();
| return returnValue;
| }
|
Murtuza
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995219#3995219
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995219
19 years, 4 months