[JCA/JBoss] - SQL Trace output concern with mapped DS
by wcydaip
I have two datasource mappings pointed at the same server-database combination. The two are used by different applications as to differentiate between testing and release code. Each datasource has their own respective login to the database, but, use the same group of classes to access the db.
I just released a new version of one of my apps and found that at times it appears to be confusing the datasource choice. i.e., I tell it to use ds1, however, it looks to be using ds2.
I'm running JBossAS-4.0.2 on a W2K box against SQLServer2K.
Here's the connection object:
| ...
|
| /**
| *
| * Handles connections to multiple databases.
| */
| public class AppHelper
| {
| private static AppHelper appHelperInstance = null;
| public static final String SC_DEFAULT_DS_CON = Constants.DEFAULT_DS_CON_VALUE;
| public static final String SC_CATS_DS_MAIN = Constants.CATS_DS_MAIN_VALUE;
|
| ...
|
| //--------------------------------------------------------------------
| /**
| * Static method used to retrieve an instance of the object (or to create
| * a new instance, if none exists.)
| * @return AppHelper app helper instance
| */
| public static synchronized AppHelper getInstance() {
| logger.debug("entering getInstance()");
| appHelperInstance = (null == appHelperInstance) ?
| new AppHelper() : appHelperInstance;
| logger.debug("leaving getInstance()");
| return appHelperInstance;
| }
|
| private AppHelper(){
| logger.debug("creating the AppHelper Singleton");
| logger.debug("leaving AppHelper Singleton");
| }
|
| ...
|
| synchronized public Connection getConnection(String ds)throws NamingException, SQLException
| {
| logger.debug("entering getConnection()");
| logger.info("get connection for "+ds);
|
| DataSource dataSource = initializeDataSource(ds);
|
| Connection conn = null;
|
| try {
| conn = dataSource.getConnection();
| logger.info("connection:"+conn.toString());
| } catch (NullPointerException e) {
| logger.error("caught np exception getting connection from cached resource!");
| logger.info("attempting to restart the datasource...");
| /*
| * If the dataSource has been shutdown or perhaps
| * the database server has been restarted, then, these
| * exception handlers will restart the datasource...
| * NOTE: All works fine if a user is in the middle of using the app,
| * however, since the Security relies on JBoss CMP then
| * are unable to authenticate
| */
| conn = resetDataSource(ds);
| logger.info("connection established!");
| } catch (SQLException e) {
| logger.error("caught sql exception getting connection from cached resource!");
| logger.info("sql ex->"+e.getMessage());
| logger.info("attempting to restart the datasource...");
| /*
| * If the dataSource has been shutdown or perhaps
| * the database server has been restarted, then, these
| * exception handlers will restart the datasource...
| * NOTE: All works fine if a user is in the middle of using the app,
| * however, since the Security relies on JBoss CMP then
| * are unable to authenticate
| */
| conn = resetDataSource(ds);
| logger.info("connection established!");
| }
|
| //conn.setAutoCommit(true);
| logger.debug("leaving getConnection()");
| return conn;
| }
|
| ...
|
| }
|
|
A call that switches ds:
| con = AppHelper.getInstance().getConnection(
| AppHelper.SC_DEFAULT_DS_CON);
| // appears not to use the default ds con
| ps = con.prepareStatement(
| "UPDATE TempNewTest SET" +
| "TC = ? " +
| "WHERE SessionID = ? " +
| "AND TC = ?");
|
The Constants static lookup:
| static {
| try {
| resourceBundle = ResourceBundle.getBundle("util");
|
| DEFAULT_DS_CON_VALUE = resourceBundle.getString(DEFAULT_DS_CON);
| CATS_DS_MAIN_VALUE = resourceBundle.getString(CATS_DS_MAIN);
|
| } catch(Exception e) {
| System.err.println("Caught exception getting util.properties resource bundle.");
| }
| }
|
The value:
| default.ds.con=java:DefaultDS
| cats.ds.con=java:CATS_DS_MAIN
|
In the trace the expected login for the call is not the one listed in the DefaultDS file. Another strange thing is that it's only with Insert and Update calls. All the Selects are done with the correct login.
If anyone could validate this or perhaps suggest something that I might be able to do to figure this out would be greatly appreciated.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973380#3973380
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973380
19 years, 7 months
[Management, JMX/JBoss] - Re: MBean: parameters name & description of operations with
by kapilanand
hi all,
I am looking for the same solution. I had posted a topic in EJB3 user forum but got no response. I could not find anything documented on this either. Looks like this feature is absent. I was considering to move to XMBeans.
I see two short-comings in the xmbean solution:
1. There is no way to separate out application and management interface.
2. You will have to do something addition to put the service in JNDI:
Option1: Using deployment descriptor define a RMI adaptor and register it in JNDI. Will be ineffecient if you need only local interface for the service, perhaps in-JVM JBoss JNDI lookup will return a local reference instead of network-enabled stub. (Will make the service remotely available though)
Option2: Write a separate startup service that creates these services and add them to JNDI programatically (and in the service kernel too perhaps). I am not sure this can be done for ejb3 services.
I think the JBoss local JNDI implementation store the local reference of the object instead of the serialized copy, so implementing Referenceable might not be needed. (that's what is evident from the example in tutorial that binds a hashtable/hashmap in JNDI and uses it as a live object)
Please let me know if my information is flawed or same things can be done in a better or different way.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973375#3973375
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973375
19 years, 7 months
[EJB 3.0] - Re: embedded ejb3 - deploying *-ds.xml?
by dhartford
Trying
| EJB3StandaloneBootstrap.deployXmlResource("mydb-ds.xml");
|
causes error:
| Caused by: org.jboss.xb.binding.JBossXBRuntimeException: No cursor for local-tx-datasource
| at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:280)
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:301)
| at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
| at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
| at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
| at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
| at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
| at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
| at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
| at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
| at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
| at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:138)
| ... 4 more
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973361#3973361
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973361
19 years, 7 months