How to config JNDI data source in Embedded Tomcat 5.028

2006-03-18 Thread Minilin-inbox
Hi,
I want to config a JNDI data source in an embedded tomcat which is started in 
Eclipse
I've tried several methods, but no one worked well.

First, I tried to indicate a configuration file which include a data source 
configuration
  StandardContext standardContext = (StandardContext) 
embedded.createContext("/web", "E:/Project/MyJava/TomcatProj/web");
  
standardContext.setConfigFile("E:/Project/MyJava/EmbeddedTomcat/conf/webexp.xml");
  host.addChild(standardContext);

but no data source could be found:
  try {
InitialContext initial = new InitialContext();
DataSource dsource = (DataSource)initial.lookup("jdbc/SQLServer");
if (dsource != null) {
   System.out.println("Data source has found!");
}
  } catch (Exception e) {
e.printStackTrace();
  }

The exception described like that:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
 at org.apache.naming.NamingContext.lookup(NamingContext.java:815)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:198)
 at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
 at javax.naming.InitialContext.lookup(InitialContext.java:347)
 at com.gul.struts.LoginAction.getUser(LoginAction.java:35)
 at com.gul.struts.LoginAction.execute(LoginAction.java:96)
..


Then, I tried the second method:
StandardContext rootCtx = (StandardContext)embedded.createContext("/web", 
"E:/Project/MyJava/EmbeddedTomcat/web");
rootCtx.setWorkDir("E:/Project/MyJava/EmbeddedTomcat");

ContextResource res = new ContextResource();
res.setName("jdbc/SQLServer");
res.setType("javax.sql.DataSource");
res.setAuth("Container");


ResourceParams params = new ResourceParams();
params.setName("jdbc/SQLServer");
params.addParameter("factory", 
"org.apache.commons.dbcp.BasicDataSourceFactory");
params.addParameter("maxActive", "50");
params.addParameter("maxIdle", "10");
params.addParameter("maxWait", "1");
params.addParameter("username", "root");
params.addParameter("password", "");
params.addParameter("driverClassName", "org.gjt.mm.mysql.Driver");
params.addParameter("url", "jdbc:mysql://localhost/employee");


rootCtx.getNamingResources().addResource(res);
rootCtx.getNamingResources().addResourceParams(params);

host.addChild(rootCtx);
But, still the exception was thrown.

Could anybody give me a help? 
Thanks


JNDI in embedded tomcat

2006-03-19 Thread Minilin-inbox
Hi, All,

I want to start tomcat by program, but I also need a JNDI data source.
Could anyone tell me how to config a Tomcat JNDI data source by program, 
or any method let the data source configuration file work?

Minilin

Re: JNDI in embedded tomcat

2006-03-20 Thread Minilin-inbox
I'm sorry, I should have given the question more detailed.
Generally, we config our JNDI data source in configuration file and put it into 
"conf/catalina/localhost", when tomcat is starting up alone, the configuration 
is loaded by tomcat and then we can find our data source like that:
Context context = new InitialContext()
context.lookup("my_data_sourc_name");

But now I start up tomcat in Eclipse and the configuration isn't loaded 
automatically and also the data source couldn't be found.
So, the question is how could I make the configuration file work.

In one word, how to make tomcat(started by Eclipse) include a data source that 
I can find out like the above snippet.


- Original Message - 
From: "David Smith" <[EMAIL PROTECTED]>
To: "Tomcat Users List" 
Sent: Monday, March 20, 2006 8:15 AM
Subject: Re: JNDI in embedded tomcat


> Details please. This question is way to general to answer without even
> so much as a version number.
> 
> JNDI config information for tomcat can be found at
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html for
> tomcat 5.5.x
> 
> --David
> 
> Minilin-inbox wrote:
> 
>>Hi, All,
>>
>>I want to start tomcat by program, but I also need a JNDI data source.
>>Could anyone tell me how to config a Tomcat JNDI data source by program, 
>>or any method let the data source configuration file work?
>>
>>Minilin
>>
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

How to debug in eclipse with tomcat started by sysdeo

2006-05-08 Thread minilin-inbox
Hi,
I want to debug my web application with the web service tomcat started by 
sysdeo in eclipse, How could I do?

Minilin