-
1. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
bipin_deshpande Mar 13, 2003 4:45 AM (in response to bipin_deshpande)i mean to say why I am unable to connect it from "myclient"
-
2. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
srinivas_rc Mar 13, 2003 11:03 AM (in response to bipin_deshpande)Why dont you attach your 'ejb-jar.xml' and the part of client code, which is doing the lookup. That may help.
Srini -
3. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
bipin_deshpande Mar 14, 2003 1:40 AM (in response to bipin_deshpande)Is there any need to edit ejb-jar zml for data source ?
Because I have added mysql-service xml and added application policy name MySqlDB in login-config.xml. -
4. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
bipin_deshpande Mar 14, 2003 1:44 AM (in response to bipin_deshpande)Is there any need to ejb-jar.xml?In case of Datasource?
I have added mysql-service.xml in my deploy directory.
And also added application policy name "MySqlDS" in login-config.xml.
My client code is
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
import first.*;
import java.sql.*;
import javax.sql.*;
import java.util.*;
public class MyClient
{
public static void main( String [] args )
{
Connection conn = null;
DataSource ds = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "comp180:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
try
{
InitialContext ctx = new InitialContext(env);
System.out.println(ctx);
Enumeration e = ctx.list("java:/");
while(e.hasMoreElements()){
System.out.println(""+e.nextElement());
}
ds = (DataSource)ctx.lookup("java:/MySqlDS");
conn = ds.getConnection();
}
catch ( Exception e )
{
e.printStackTrace();
System.out.println( "Exception: " + e.getMessage() );
}
}
} -
5. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
bipin_deshpande Mar 14, 2003 1:50 AM (in response to bipin_deshpande)Is there any need to ejb-jar.xml?In case of Datasource?
I have added mysql-service.xml in my deploy directory.
And also added application policy name "MySqlDS" in login-config.xml.
My Client code :
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
import first.*;
import java.sql.*;
import javax.sql.*;
import java.util.*;
public class MyClient
{
public static void main( String [] args )
{
Connection conn = null;
DataSource ds = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "comp180:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
try
{
InitialContext ctx = new InitialContext(env);
System.out.println(ctx);
Enumeration e = ctx.list("java:/");
while(e.hasMoreElements()){
System.out.println(""+e.nextElement());
}
ds = (DataSource)ctx.lookup("java:/MySqlDS");
conn = ds.getConnection();
}
catch ( Exception e )
{
e.printStackTrace();
System.out.println( "Exception: " + e.getMessage() );
}
}
} -
6. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
srinivas_rc Mar 14, 2003 10:31 AM (in response to bipin_deshpande)Oh! So you are not using ejb. You just want to use a DataSource from a client java program (that is may be within or outside jboss).
If that is the case, First I will suggest you see your JNDI Tree (using JndiView MBEAN available from http://localhost:8080/jmx-console).
Use the method list() or listXml() to see all the bindings done, and see what is the exact path ...in ur case u assume it is :
MySqlDS
If it is in 'Java' Namespace, I think you can use it only from within Jboss. You can do a lookup with
Context rootCtx = getInitialContext();
DataSource ds = (DataSource) rootCtx.lookup("java:/MySqlDS");
If it is in global jndi namespace, then you can do lookup from client outside jboss env.
DataSource ds = (DataSource) rootCtx.lookup("MySqlDS");
Hope this helps. -
7. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
bipin_deshpande Mar 18, 2003 2:58 AM (in response to bipin_deshpande)this is what I get from my
http://localhost:8080/jmx-console/index.jsp
jboss.jca
name=JBoss LocalTransaction JDBC Wrapper,service=RARDeployment
name=JMS Adapter,service=RARDeployment
name=Minerva JDBC XATransaction ResourceAdapter,service=RARDeployment
name=MySqlDS,service=LocalTxCM
name=MySqlDS,service=LocalTxDS
name=MySqlDS,service=LocalTxPool
name=hsqldbDS,service=LocalTxCM
name=hsqldbDS,service=LocalTxDS
name=hsqldbDS,service=LocalTxPool
name=jmsra,service=XaTxCM
name=jmsra,service=XaTxDS
name=jmsra,service=XaTxPool
service=CachedConnectionManager
service=RARDeployer
It clearly shows that MySqlDS is bound
Even if I am unable to get it from my client by the same name 'MySqlDS'.
Is there any problem of classpath or something ? -
8. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
srinivas_rc Mar 18, 2003 8:37 AM (in response to bipin_deshpande)This is fine. But sometime, you want to see whether this is bound to which jndi name in "java:" namespace. For that you have to run JndiView MBean (which u can see in the jmx-console.
Also, you did not mentioned, from where you are running the client? are you running it from outside the Jboss?? or from within the jboss?? I have tested from within jboss like, jsp, session bean, etc. and it works fine.