-
1. Re: Exception in main: WazaguaDS not bound
jfradkin Jun 22, 2003 3:36 AM (in response to jfradkin)Just to confuse me even more it works fine from the bean deployed in an ear file.
Argh, can I run this as a plain jain class ?
Thank you again
Joel -
2. Re: Exception in main: WazaguaDS not bound
jonlee Jun 22, 2003 5:21 AM (in response to jfradkin)You cannot access a datasource from outside the JVM (from a remote client). From a JNDI perspective, the name is bound in an area not visible to external clients. The datasource in any case, manufactures JDBC compatible connections that cannot be used in a proxied sense outside the JVM in which it is created.
See http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= for more details from David Jencks. -
3. Re: Exception in main: WazaguaDS not bound
jfradkin Jun 23, 2003 8:11 AM (in response to jfradkin)Ok so for the java challanged I can not write a class in eclipse that is running Jboss to test my data base stuff.
I can use the other connection method:
Class.forName(driver);
Connection con1 = DriverManager.getConnection(url, username, password);
Statement stmt = con1.createStatement();
to test my database functions without having to recompile and deploy to a bean.
My intent is to use in a bean so in production it will use a pooled connection.
Sorry for being so uninformed I did a great deal of reading but some of this stuff is just not communicating in a way I understand (no offense, I am just not up to speed yet).
I swear I had it cranked up the other day but maybe I was hullucinating, for sure I don realy understand the terminology. At the risk of sounding like a total NewB (which I am); what is a VM as it applies to Jboss development? If I understand it at all I think you mean at a minimum it has to be a jar (war, ear) in the deploy directory, but is not a class in eclipse even when Jboss is started using the IDE. Also if I understand what I have read that the proper usage is to get the code happy in a bean that has a close in a finnally and that under normal access opens , does its processing and closes the data connection.
I appreciate the feedback as I continue to learn what make this environment tick.
Joel -
4. Re: Exception in main: WazaguaDS not bound
jonlee Jun 23, 2003 9:32 AM (in response to jfradkin)OK. Big questions here.
The Java Virtual Machine (JVM) is the runtime environment for a Java program. So when you start JBoss you are essentially executing:
java -cp run.jar:/j2sdk14/lib/tools.jar -server org.jboss.Main
The java command creates a JVM, in which org.jboss.Main can run - and then executes the program from the org.jboss.Main entry point. This bootstraps the JBoss microkernel that runs within this JVM. For SUN JDK installations, the -server tells the JVM to support server type operations, rather than client type operations.
JBoss is among other things, an EJB container - that is an environment in which EJBs can exist. JBoss also has an embedded servlet container (Jetty or Tomcat), in which servlets and JSPs can exist. It's the Russian dolls analogy. JBoss also has a JNDI service (which you are trying to use to locate resources such as a datasource, an EJB and so on). All these survive with the JVM created by the initial java command.
Now I'm not too familiar with Eclipse. It may be possible to run JBoss within the same JVM in which Eclipse is running. But I would have thought that things would get very crowded in the one JVM and possible to create crashes.
I would expect Eclipse to spawn JBoss in it's own JVM - so you would have two JVMs - one running JBoss and one running Eclipse if this happens. Probably your test client would run in it's own JVM so if anything went wrong you wouldn't risk clobbering your IDE's runtime environment.
So, anything running under the JBoss microkernel will be able to access JNDI names for datasources. Things from any other JVM will not. Note, that a servlet running within the embedded servlet container (Jetty or Tomcat) will be able to access the datasources so this might help you for your testing/experimentation (as well as EJBs of course).
If you use CMP entity beans, the container will normally take care of connections. In BMP entity beans, and session beans, you take care of connections. In the cases where you have the responsibility, it is good practice to close the connection before you leave the method in which you opened the connection - closing the connection only returns the connection to the pool. As connections from a connection pool are a shared resource, it is best practice to only have the connection open as long as you need it and no more. This ensures that a connection is available for the maximum amount of time.
Hope that helps somewhat but is by no means an authorative answer. -
5. Re: Exception in main: WazaguaDS not bound
jfradkin Jun 23, 2003 9:54 AM (in response to jfradkin)Many thanks for the explanation. I think I get it. At least it is working in an ear (since this is in the JVM with JNDI services available). Since my ultimate plan is to deploy in that manner I will just develop useing non data source conection and then test it in the bean once i hvae it working. I have several books to read, my problem is I may be dense an example in my own environment is worth a million words to me. Luckily there is much help via this forum and reading old messages has allready helped me a huge amount. My thanks to all of those who tae the time to answer and provide light to those of us still in the dark. Only example I was iunterested in looking at that I did not get running was Turbine. I did get Velocity going in eclipse and J2ee bean in eclipse (thanx to the Jboss IDE tutorial). Thanks again
Joel