File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Exception occurred while attempting to acquire a JDBC DataSource from JNDI : Tomcat 7 and Mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Exception occurred while attempting to acquire a JDBC DataSource from JNDI : Tomcat 7 and Mysql" Watch "Exception occurred while attempting to acquire a JDBC DataSource from JNDI : Tomcat 7 and Mysql" New topic
Author

Exception occurred while attempting to acquire a JDBC DataSource from JNDI : Tomcat 7 and Mysql

Rajwant mishra
Greenhorn

Joined: Jul 21, 2011
Posts: 2
Hi Experts,
<Sorry fo rthe such a long post>

I have spent my almost 1 week by reading through all the post and still struglling to get my happyjuddi.jsp workig...I here in hope to get some pointer to find the correct issue .
I have
Server=>Apache-Tomcat 7.0.16
Java=> Jdk 1.6
Juddi=>juddi-tomcat-2.0.1
Mysql=>mysql-5.5.14-win32

Now the Error which I get when click on validate button Below error from my Localhost log file and Juddi Log file:

I have user Juddi setup in mysql , Nothing in server.xml
but C:\Eclipse\apache-tomcat-7.0.16\webapps\juddi\META-INF is having context file :
as shown below :

<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log." suffix=".txt"
pattern="common"/>

<ResourceLink
global="jdbc/juddiDB"
name="jdbc/juddiDB"
type="javax.sql.DataSource"/>

<Resource name="jdbc/juddiDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="1000"
username="juddi" password="juddi"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/juddi?autoReconnect=true"
validationQuery="select count(*) from PUBLISHER"/>
<Resource name="jdbc/juddi"
auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="1000"
username="juddi" password="juddi"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/juddi?autoReconnect=true"
validationQuery="select count(*) from PUBLISHER"/>
</Context>


========> Web.xml have


<resource-ref>
<description>jUDDI DataSource</description>
<res-ref-name>jdbc/juddiDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<description>jUDDI DataSource</description>
<res-ref-name>jdbc/juddi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>




Local Host Log file:
Jul 21, 2011 1:52:25 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 21, 2011 1:52:25 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 21, 2011 1:52:25 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@bc5596')
Jul 21, 2011 1:52:45 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/juddi] threw exception [Unable to compile class for JSP:

An error occurred at line: 25 in the generated java file
Only a type can be imported. org.apache.taglibs.standard.tag.common.core.Util resolves to a package

An error occurred at line: 253 in the jsp file: /happyjuddi.jsp
Util cannot be resolved
250: if ((dsname == null) || (dsname.trim().length() == 0)) {
251: dsname = "java:comp/env/jdbc/juddiDB";
252: } else {
253: dsname = Util.escapeXml(dsname);
254: }
255:
256: ctx = new InitialContext();


Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 25 in the generated java file
Only a type can be imported. org.apache.taglibs.standard.tag.common.core.Util resolves to a package

An error occurred at line: 253 in the jsp file: /happyjuddi.jsp
Util cannot be resolved
250: if ((dsname == null) || (dsname.trim().length() == 0)) {
251: dsname = "java:comp/env/jdbc/juddiDB";
252: } else {
253: dsname = Util.escapeXml(dsname);
254: }
255:
256: ctx = new InitialContext();


Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:601)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:286)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:272)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1730)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Jul 21, 2011 1:53:57 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 21, 2011 1:53:57 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Jul 21, 2011 2:11:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 21, 2011 2:11:47 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 21, 2011 2:11:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@1dafbaf')
Jul 21, 2011 2:14:06 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 21, 2011 2:14:06 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Jul 21, 2011 2:14:13 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 21, 2011 2:14:13 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 21, 2011 2:14:13 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@185ad79')
Jul 21, 2011 2:15:17 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 21, 2011 2:15:17 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Jul 21, 2011 2:15:25 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 21, 2011 2:15:25 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 21, 2011 2:15:25 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@bc5596')
Jul 21, 2011 2:17:01 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 21, 2011 2:17:01 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Jul 21, 2011 2:22:56 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 21, 2011 2:22:56 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 21, 2011 2:22:56 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@1ce1bea')
Jul 21, 2011 2:24:18 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 21, 2011 2:24:18 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()



[b][b]-------------------------------------------------------------------------------------------------------------------------------

Log From my Juddi.log file
[/b][/b]



2011-07-21 14:22:56,035 INFO [org.apache.juddi.registry.RegistryServlet] - Loading jUDDI configuration.
2011-07-21 14:22:56,035 INFO [org.apache.juddi.registry.RegistryServlet] - Resources loaded from: /WEB-INF/juddi.properties
2011-07-21 14:22:56,035 INFO [org.apache.juddi.registry.RegistryServlet] - Initializing jUDDI components.
2011-07-21 14:22:56,144 INFO [org.apache.juddi.util.jdbc.ConnectionManager] - Using JNDI to aquire a JDBC DataSource with name: java:comp/env/jdbc/juddiDB
2011-07-21 14:22:56,144 ERROR [org.apache.juddi.util.jdbc.ConnectionManager] - Exception occurred while attempting to acquire a JDBC DataSource from JNDI: Name jdbc is not bound in this Context
2011-07-21 14:22:56,144 ERROR [org.apache.juddi.registry.RegistryEngine] - Could not create jUDDI database null
java.lang.NullPointerException
at org.apache.juddi.registry.RegistryEngine.initializeDatabase(RegistryEngine.java:253)
at org.apache.juddi.registry.RegistryEngine.init(RegistryEngine.java:196)
at org.apache.juddi.registry.RegistryServlet.init(RegistryServlet.java:182)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1201)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1114)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1021)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2011-07-21 14:24:18,691 INFO [org.apache.juddi.registry.RegistryServlet] - jUDDI Stopping: Cleaning up existing resources.


Rajwant mishra
Greenhorn

Joined: Jul 21, 2011
Posts: 2
any input.....
please guide.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Welcome to the JavaRanch, Rajwant. Sorry about the delay, but everything has its price, and in the case of "free" help, the price is that you don't get instant answers. We have people in pretty much every timezone in the world, but we all check in if/when it's convenient. In my case, it was about an hour before you posted your message.

You can make things a little easier if you use the "Code" button in your message editor to bracket code and XML samples. They'll display in a much more readable form.

I cannot see anything obviously wrong, but whenever you're defining a datasource in Tomcat, things can go wrong that aren't very obvious. Since the datasource named "jdbc/juddiDB" isn't being found in JNDI, that means that you should take a very close look at its definition in the WAR's context.xml file. Also, while Tomcat is not running, check the TOMCAT_HOME/conf/Catalina/localhost directory to see if an old, stale copy of that file was copied there, and if there's an exploded WAR in TOMCAT_HOME/webapps, delete it, because that copy will override any newer deployed WAR file.

Other than that, if there's a problem with the resource definition, it normally shows up in the catalina.out logfile.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception occurred while attempting to acquire a JDBC DataSource from JNDI : Tomcat 7 and Mysql
 
Similar Threads
Problem to run my application
error in filters
org.apache.catalina.connector.Connector pause SEVERE: Protocol handler pause failed
embedded JBoss and Tomcat 6.0
Error in tomcat 5.5