Re: Can't create jdbc resource in context.xml

2007-04-25 Thread Glen Vermeylen

It also doesn't work with the resource-ref element. The error was 
javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context,
but I was able to lookup the jdbc/sandwiches datasource using programmatic
jndi lookup.
Weird part is that everything works fine if I move the datasource element
from the context file to server.xml. Is it possible that the realm gets
initialized before the datasource or that something causes the realm to
initialize in a different context where it doesn't have access to the
datasource?

Anyways, thank you very much for your help. I've found a solution which
works but if there are some suggestions on how to get it to work using a
datasourcerealm I will still try them out.

Regards,
Glen.


2007/4/23, Rashmi Rubdi [EMAIL PROTECTED]:


Hi Glen,

I compared your configuration with the standard configuration
mentioned
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
and found a few differences.

Please see my replies to your post below:

On 4/20/07, Glen Vermeylen [EMAIL PROTECTED] wrote:
 Hello everybody,

 I'm trying to move a global jdbc resource out of server.xml so it is
 application specific. Following is the server.xml (which works fine)
.

 What I did was remove the the GlobalNamingResources and Realm 
elements
 from server.xml and put them inside
 $CATALINA_HOME/conf/Catalina/localhost/esandwich.xml (don't mind the
weird
 name :) ), but I keep getting the error
 javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context

 esandwich.xml:
 Context docBase=c:/workspace/esandwich/WebContent/ reloadable=true
 crosscontext=true

crossContext attribute's case needs to be crossContext , but it is
specified as crosscontext.

One question, though a little irrelevant is -- do you really need
crossContext=true ? Just because it is specified in the sample on
the JDBC Datasource HowTo page, doesn't mean you would need it - this
is just a thought. If you don't need it, please set it to false or
remove the attribute.

 Resource name=jdbc/sandwiches auth=Container driverClassName=
 com.mysql.jdbc.Driver
 password=tomcat type=javax.sql.DataSource

url=jdbc:mysql://192.168.16.39:3306/sandwiches?autoReconnect=true
 username=tomcat /


 Realm className=org.apache.catalina.realm.DataSourceRealm
 dataSourceName=jdbc/sandwiches debug=99 roleNameCol=role
 userCredCol=password userNameCol=user
userRoleTable=userroles
 userTable=users /
 /Context

 I believe the problem lies witht he Resource element

No the problem is in web.xml , I don't see any definition for:

resource-ref

please see under 3. web.xml configuration at

http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
for the details on web.xml entries.

 because if only move
 the realm element to the esandwich.xml and leave the
 GlobalNamingResourcesResource./... in server.xml everything
still
 works. We've been searching for a few hours now and can't find the
solution.
 Any help would be highly appreciated.

 web.xml:
 ?xml version=1.0 encoding=UTF-8?
 web-app id=WebApp_ID version=2.4
 xmlns=http://java.sun.com/xml/ns/j2ee;
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
 display-nameesandwich/display-name
 listener
 listener-class
 org.springframework.web.context.ContextLoaderListener
 /listener-class
 /listener
 servlet
 servlet-namedispatcher/servlet-name
 servlet-class
 org.springframework.web.servlet.DispatcherServlet
 /servlet-class
 /servlet
 servlet-mapping
 servlet-namedispatcher/servlet-name
 url-pattern/app/*/url-pattern
 /servlet-mapping
 welcome-file-list
 welcome-fileindex.jsp/welcome-file
 /welcome-file-list
 login-config
 auth-methodFORM/auth-method
 form-login-config
 form-login-page/login.html/form-login-page
 form-error-page/loginError.html/form-error-page
 /form-login-config
 /login-config

 security-constraint
 web-resource-collection
 web-resource-namedefault/web-resource-name
 url-pattern/app/*/url-pattern
 http-methodPOST/http-method
 http-methodGET/http-method
 /web-resource-collection
 auth-constraint
 descriptioneveryone can log in/description
 role-name*/role-name
 /auth-constraint
 /security-constraint

 security-role
 descriptionThe Only Secure Role/description
 role-nameadmin/role-name
 /security-role

 /web-app


 Many thanks in advance,
 Glen.


-Regards
Rashmi

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL 

Re: Can't create jdbc resource in context.xml

2007-04-25 Thread Martin Gainty
in your webapp WEB-INF/web.xml you will need to define the 
ContextLoaderListener

then you will also need a way to define the root context

if you want to locate the parameters in your applicationContext.xml try
!--
  - Loads the root application context of this web app at startup,
  - by default from /WEB-INF/applicationContext.xml.
 - Note that you need to fall back to Spring's ContextLoaderServlet for
 - J2EE servers that do not follow the Servlet 2.4 initialization order.
  - Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
  - to access it anywhere in the web application, outside of the framework.
  - The root context is the parent of all servlet-specific contexts.
  - This means that its beans are automatically available in these child 
contexts,

  - both for getBean(name) calls and (external) bean references.
  --
listener
 
listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
/listener

!-- This will display The root application context
  - Location of the XML file that defines the root application context.
  - Applied by ContextLoaderServlet.
 - Can be set to /WEB-INF/applicationContext-hibernate.xml for the 
Hibernate implementation,

- /WEB-INF/applicationContext-ojb.xml for the Apache OJB one,
 - /WEB-INF/applicationContext-toplink.xml for the Oracle TopLink one,
 - or /WEB-INF/applicationContext-jdbc.xml for the JDBC one.
  --
context-param
 param-namecontextConfigLocation/param-name
 param-value/WEB-INF/applicationContext-jdbc.xml/param-value
 !--
 param-value/WEB-INF/applicationContext-hibernate.xml/param-value
 param-value/WEB-INF/applicationContext-ojb.xml/param-value
 param-value/WEB-INF/applicationContext-toplink.xml/param-value
  --
/context-param

Does this help?
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

- Original Message - 
From: Glen Vermeylen [EMAIL PROTECTED]

To: Tomcat Users List users@tomcat.apache.org
Sent: Wednesday, April 25, 2007 10:07 AM
Subject: Re: Can't create jdbc resource in context.xml



It also doesn't work with the resource-ref element. The error was 
javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context,
but I was able to lookup the jdbc/sandwiches datasource using programmatic
jndi lookup.
Weird part is that everything works fine if I move the datasource element
from the context file to server.xml. Is it possible that the realm gets
initialized before the datasource or that something causes the realm to
initialize in a different context where it doesn't have access to the
datasource?

Anyways, thank you very much for your help. I've found a solution which
works but if there are some suggestions on how to get it to work using a
datasourcerealm I will still try them out.

Regards,
Glen.


2007/4/23, Rashmi Rubdi [EMAIL PROTECTED]:


Hi Glen,

I compared your configuration with the standard configuration
mentioned
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
and found a few differences.

Please see my replies to your post below:

On 4/20/07, Glen Vermeylen [EMAIL PROTECTED] wrote:
 Hello everybody,

 I'm trying to move a global jdbc resource out of server.xml so it is
 application specific. Following is the server.xml (which works fine)
.

 What I did was remove the the GlobalNamingResources and Realm 
elements
 from server.xml and put them inside
 $CATALINA_HOME/conf/Catalina/localhost/esandwich.xml (don't mind the
weird
 name :) ), but I keep getting the error
 javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context

 esandwich.xml:
 Context docBase=c:/workspace/esandwich/WebContent/ reloadable=true
 crosscontext=true

crossContext attribute's case needs to be crossContext , but it is
specified as crosscontext.

One question, though a little irrelevant is -- do you really need
crossContext=true ? Just because it is specified in the sample on
the JDBC Datasource HowTo page, doesn't mean you would need it - this
is just a thought. If you don't need it, please set it to false or
remove the attribute.

 Resource name=jdbc/sandwiches auth=Container driverClassName=
 com.mysql.jdbc.Driver
 password=tomcat type=javax.sql.DataSource

url=jdbc:mysql://192.168.16.39:3306/sandwiches?autoReconnect=true
 username=tomcat /


 Realm className=org.apache.catalina.realm.DataSourceRealm
 dataSourceName=jdbc/sandwiches debug=99 roleNameCol=role
 userCredCol=password userNameCol=user
userRoleTable=userroles
 userTable=users /
 /Context

 I believe the problem lies witht he Resource element

No the problem is in web.xml , I don't see any definition for:

resource-ref

Re: Can't create jdbc resource in context.xml

2007-04-23 Thread Glen Vermeylen

Thanks for the response,

We use tomcat 5.5.

-Glen

2007/4/20, Rashmi Rubdi [EMAIL PROTECTED]:


Hello Glen,

What is the version of Tomcat? I'm asking for the version because the
JNDI Datasource configuration is different for different version of
Tomcat. The one for 4.x is different from the one for 6.x for example.

-Rashmi

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Can't create jdbc resource in context.xml

2007-04-23 Thread Rashmi Rubdi

Hi Glen,

I compared your configuration with the standard configuration
mentioned 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
and found a few differences.

Please see my replies to your post below:

On 4/20/07, Glen Vermeylen [EMAIL PROTECTED] wrote:

Hello everybody,

I'm trying to move a global jdbc resource out of server.xml so it is
application specific. Following is the server.xml (which works fine)

.


What I did was remove the the GlobalNamingResources and Realm  elements
from server.xml and put them inside
$CATALINA_HOME/conf/Catalina/localhost/esandwich.xml (don't mind the weird
name :) ), but I keep getting the error
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

esandwich.xml:
Context docBase=c:/workspace/esandwich/WebContent/ reloadable=true
crosscontext=true


crossContext attribute's case needs to be crossContext , but it is
specified as crosscontext.

One question, though a little irrelevant is -- do you really need
crossContext=true ? Just because it is specified in the sample on
the JDBC Datasource HowTo page, doesn't mean you would need it - this
is just a thought. If you don't need it, please set it to false or
remove the attribute.


Resource name=jdbc/sandwiches auth=Container driverClassName=
com.mysql.jdbc.Driver
password=tomcat type=javax.sql.DataSource
url=jdbc:mysql://192.168.16.39:3306/sandwiches?autoReconnect=true
username=tomcat /


Realm className=org.apache.catalina.realm.DataSourceRealm
dataSourceName=jdbc/sandwiches debug=99 roleNameCol=role
userCredCol=password userNameCol=user userRoleTable=userroles
userTable=users /
/Context

I believe the problem lies witht he Resource element


No the problem is in web.xml , I don't see any definition for:

resource-ref

please see under 3. web.xml configuration at
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
for the details on web.xml entries.


because if only move
the realm element to the esandwich.xml and leave the
GlobalNamingResourcesResource./... in server.xml everything still
works. We've been searching for a few hours now and can't find the solution.
Any help would be highly appreciated.

web.xml:
?xml version=1.0 encoding=UTF-8?
web-app id=WebApp_ID version=2.4
xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
display-nameesandwich/display-name
listener
listener-class
org.springframework.web.context.ContextLoaderListener
/listener-class
/listener
servlet
servlet-namedispatcher/servlet-name
servlet-class
org.springframework.web.servlet.DispatcherServlet
/servlet-class
/servlet
servlet-mapping
servlet-namedispatcher/servlet-name
url-pattern/app/*/url-pattern
/servlet-mapping
welcome-file-list
welcome-fileindex.jsp/welcome-file
/welcome-file-list
login-config
auth-methodFORM/auth-method
form-login-config
form-login-page/login.html/form-login-page
form-error-page/loginError.html/form-error-page
/form-login-config
/login-config

security-constraint
web-resource-collection
web-resource-namedefault/web-resource-name
url-pattern/app/*/url-pattern
http-methodPOST/http-method
http-methodGET/http-method
/web-resource-collection
auth-constraint
descriptioneveryone can log in/description
role-name*/role-name
/auth-constraint
/security-constraint

security-role
descriptionThe Only Secure Role/description
role-nameadmin/role-name
/security-role

/web-app


Many thanks in advance,
Glen.



-Regards
Rashmi

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Can't create jdbc resource in context.xml

2007-04-20 Thread Glen Vermeylen

Hello everybody,

I'm trying to move a global jdbc resource out of server.xml so it is
application specific. Following is the server.xml (which works fine)

?xml version=1.0 encoding=UTF-8?
Server port=8005 shutdown=SHUTDOWN
   Listener className=org.apache.catalina.core.AprLifecycleListener/
   Listener className=org.apache.catalina.mbeans.ServerLifecycleListener
/
   Listener className=
org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/
   Listener className=
org.apache.catalina.storeconfig.StoreConfigLifecycleListener/
   GlobalNamingResources
   Resource auth=Container driverClassName=com.mysql.jdbc.Driver
maxActive=10 maxIdle=1 maxWait=1 name=jdbc/sandwiches
password=tomcat type=javax.sql.DataSource
url=jdbc:mysql://192.168.16.39:3306/sandwiches?autoReconnect=true
username=tomcat/
   /GlobalNamingResources
   Service name=Catalina
   Connector acceptCount=100 connectionTimeout=2
disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192
maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=8080
redirectPort=8443/
   Connector enableLookups=false port=8009 protocol=AJP/1.3
redirectPort=8443/
   Engine defaultHost=laocalhost name=Catalina
   Realm className=org.apache.catalina.realm.DataSourceRealm
dataSourceName=jdbc/sandwiches debug=99 roleNameCol=role
userCredCol=password userNameCol=user userRoleTable=userroles
userTable=users/
   Host appBase=webapps autoDeploy=true name=localhost
unpackWARs=true xmlNamespaceAware=false xmlValidation=false
   /Host
   /Engine
   /Service
/Server

What I did was remove the the GlobalNamingResources and Realm  elements
from server.xml and put them inside
$CATALINA_HOME/conf/Catalina/localhost/esandwich.xml (don't mind the weird
name :) ), but I keep getting the error
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

esandwich.xml:
Context docBase=c:/workspace/esandwich/WebContent/ reloadable=true
crosscontext=true
   Resource name=jdbc/sandwiches auth=Container driverClassName=
com.mysql.jdbc.Driver
   password=tomcat type=javax.sql.DataSource
   url=jdbc:mysql://192.168.16.39:3306/sandwiches?autoReconnect=true
   username=tomcat /


   Realm className=org.apache.catalina.realm.DataSourceRealm
   dataSourceName=jdbc/sandwiches debug=99 roleNameCol=role
   userCredCol=password userNameCol=user userRoleTable=userroles
   userTable=users /
/Context

I believe the problem lies witht he Resource element because if only move
the realm element to the esandwich.xml and leave the
GlobalNamingResourcesResource./... in server.xml everything still
works. We've been searching for a few hours now and can't find the solution.
Any help would be highly appreciated.

web.xml:
?xml version=1.0 encoding=UTF-8?
web-app id=WebApp_ID version=2.4
   xmlns=http://java.sun.com/xml/ns/j2ee;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
   display-nameesandwich/display-name
   listener
   listener-class
   org.springframework.web.context.ContextLoaderListener
   /listener-class
   /listener
   servlet
   servlet-namedispatcher/servlet-name
   servlet-class
   org.springframework.web.servlet.DispatcherServlet
   /servlet-class
   /servlet
   servlet-mapping
   servlet-namedispatcher/servlet-name
   url-pattern/app/*/url-pattern
   /servlet-mapping
   welcome-file-list
   welcome-fileindex.jsp/welcome-file
   /welcome-file-list
   login-config
   auth-methodFORM/auth-method
   form-login-config
   form-login-page/login.html/form-login-page
   form-error-page/loginError.html/form-error-page
   /form-login-config
   /login-config

   security-constraint
   web-resource-collection
   web-resource-namedefault/web-resource-name
   url-pattern/app/*/url-pattern
   http-methodPOST/http-method
   http-methodGET/http-method
   /web-resource-collection
   auth-constraint
   descriptioneveryone can log in/description
   role-name*/role-name
   /auth-constraint
   /security-constraint

   security-role
   descriptionThe Only Secure Role/description
   role-nameadmin/role-name
   /security-role

/web-app


Many thanks in advance,
Glen.


Re: Can't create jdbc resource in context.xml

2007-04-20 Thread Rashmi Rubdi

Hello Glen,

What is the version of Tomcat? I'm asking for the version because the
JNDI Datasource configuration is different for different version of
Tomcat. The one for 4.x is different from the one for 6.x for example.

-Rashmi

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]