I'm implementing Dbutils using net.sourceforge.jtds.jdbc.Driver driver in jtds package.
Problem is it gives me java.sql.SQLException: net.sourceforge.jtds.jdbc.Driver error even after including jtds jar in project. It works fine when i include this jtds jar file in lib folder of tomcat.
I checked build code, jtds jar file is present there.
java.sql.SQLException: net.sourceforge.jtds.jdbc.Driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:702)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:488)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
at com.cibil.crs.escalationmatrix.dbutil.DataSourceFactory.createDataSource(DataSourceFactory.java:46)
at com.cibil.crs.escalationmatrix.dbutil.DataSourceFactory.createDataSource(DataSourceFactory.java:17)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:237)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1093)
at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:672)
at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:271)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
Any idea?
You are using a connection pool and you are making use of the tomcat. See the link below, and notice the line that says "The fully qualified Java class name of the JDBC driver to be used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar".
https://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html
Related
(embedded Tomcat 7.0.59, gradle 2.13, HikariCP 2.4.6, mysql-connector-java 6.0.2)
I want to create connection pool (mysql) in my web application.
When I execute gradle tomcatRun, I get the following message:
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:89)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:294)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:91)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:101)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71)
at [my package].DbContextListener.initDataSource(DbContextListener.java:40)
at [my package].DbContextListener.contextInitialized(DbContextListener.java:27)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:76)
... 15 more
I found that tomcat may not contain dbcp-jar, so I tried to add it via gradle:
compile 'org.apache.tomcat:tomcat-jdbc:7.0.59' but nothing changed
Can anyone explain me how it should be done?
I am trying to set up to run Jacoco agent (http://mvnrepository.com/artifact/org.jacoco/org.jacoco.agent/0.7.6.201602180812), and I am getting an exception as below.
java.lang.instrument.IllegalClassFormatException: Error while instrumenting class ...
at org.jacoco.agent.rt.internal_14f7ee5.CoverageTransformer.transform(CoverageTransformer.java:93)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3114)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1342)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1823)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
at org.apache.catalina.util.Introspection.loadClass(Introspection.java:143)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:132)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:415)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:892)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5405)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Error while instrumenting class org/apache/jsp/isml2jsp/cartridges/app_005fbusiness_005fmanager/default_/product/batch/AttributeValue_002d37d0cd03a157eeffaecd90c11598827569e0327d_jsp.
at org.jacoco.agent.rt.internal_14f7ee5.core.instr.Instrumenter.instrumentError(Instrumenter.java:152)
at org.jacoco.agent.rt.internal_14f7ee5.core.instr.Instrumenter.instrument(Instrumenter.java:103)
at org.jacoco.agent.rt.internal_14f7ee5.CoverageTransformer.transform(CoverageTransformer.java:91)
... 25 more
Caused by: java.lang.RuntimeException: Method code too large!
at org.jacoco.agent.rt.internal_14f7ee5.asm.MethodWriter.getSize(MethodWriter.java:2036)
at org.jacoco.agent.rt.internal_14f7ee5.asm.ClassWriter.toByteArray(ClassWriter.java:827)
at org.jacoco.agent.rt.internal_14f7ee5.core.instr.Instrumenter.instrument(Instrumenter.java:84)
at org.jacoco.agent.rt.internal_14f7ee5.core.instr.Instrumenter.instrument(Instrumenter.java:101)
... 26 more
The Java Option to run the Jacoco agent is set as:
JAVA_OPTS=$JAVA_OPTS\ -javaagent:/myserver/tomcat/lib/jacocoagent.jar=destfile=/tmp/jacoco.exec
I am not using a Maven or Ant file to run it, and the option to run the agent is set directly in the Tomcat startup script. Can anyone please help?
I encounter the following error when trying to connect to a database using SQuirreLSQL.
Error :
Unexpected Error occured attempting to open an SQL connection
Stacktrace :
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:202)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:175)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at net.sourceforge.squirrel_sql.fw.util.MyURLClassLoader.findClass(MyURLClassLoader.java:209)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:128)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 7 more
I also tried to check Driver Properties and the following error is displayed :
Loading JDBC driver "Microsoft MSSQL Server JDBC Driver" failed.
Can not load driver properties tab.
You need to copy driver into squirrel-sql/lib folder.
I've had same issue with MySql driver.
After copied drived into:
$HOME/squirrel-sql-3.7/lib/mysql-connector-java-3.0.17-ga-bin.jar
and restart Squirrel - there was no error anymore.
I have application in /var/lib/tomcat7/webapps/code I have init.java file that use json-rpc-2.0
I compile it using:
export CLASSPATH=$CLASSPATH:/path/jsonrpc2-base-1.35.jar:/path/json-smart-1.2.jar
javac init.java
it compile but when I run the app (not the servlet) I got error 404 from Tomcat and in catalina.out file there is exception:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngin
e[Catalina].StandardHost[localhost].StandardContext[/code]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig
.java:1673)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: com/thetransactioncompany/jsonrpc2/JSONRPC2ParseException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2387)
at java.lang.Class.getDeclaredFields(Class.java:1796)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.thetransactioncompany.jsonrpc2.JSONRPC2ParseException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
with caused by not found com/thetransactioncompany/jsonrpc2/JSONRPC2ParseException which is in jar file.
What's happening here? How can I fix it to make it work?
This is usually the jar files are not available for Tomcat.
The best way to solve this is place the json-rpc-2.0 jar files into your Tomcat's lib folder
Update
As specified by A4L user , you can also put the jar in your web applications WEB-INF/lib as well.
After I had deployed succesfully the Ametys CMS to my Tomcat server (XAMPP), I accessed the configuration link http://localhost/cms and started completing the necessary data. The I click Save and restart and it shows an error:
An error occurred. Please contact the administrator of the application.
here are the details it is showing:
An error occurred. Please contact the administrator of the application.org.apache.avalon.framework.component.ComponentException: Unable to initialize the ComponentManager (key [org.apache.cocoon.Processor]) at org.ametys.runtime.cocoon.TreeProcessor.compose(TreeProcessor.java:94) at org.apache.avalon.framework.container.ContainerUtil.compose(ContainerUtil.java:173) at org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:266) at org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.initialize(ThreadSafeComponentHandler.java:108) at org.apache.avalon.excalibur.component.ExcaliburComponentManager.initialize(ExcaliburComponentManager.java:524) at org.apache.cocoon.components.CocoonComponentManager.initialize(CocoonComponentManager.java:583) at org.apache.avalon.framework.container.ContainerUtil.initialize(ContainerUtil.java:244) at org.apache.cocoon.Cocoon.initialize(Cocoon.java:345) at org.apache.avalon.framework.container.ContainerUtil.initialize(ContainerUtil.java:244) at org.apache.cocoon.servlet.CocoonServlet.createCocoon(CocoonServlet.java:1435) at org.ametys.runtime.servlet.RuntimeServlet.createCocoon(RuntimeServlet.java:225) at org.apache.cocoon.servlet.CocoonServlet.init(CocoonServlet.java:495) at org.ametys.runtime.servlet.RuntimeServlet.init(RuntimeServlet.java:171) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: org.apache.avalon.framework.configuration.ConfigurationException: Specified driver class does not exist: com.mysql.jdbc.Driver at org.ametys.runtime.datasource.DataSourceExtensionPoint.addExtension(DataSourceExtensionPoint.java:65) at org.ametys.runtime.plugin.PluginsManager._loadExtensions(PluginsManager.java:1077) at org.ametys.runtime.plugin.PluginsManager._loadFeatures(PluginsManager.java:1030) at org.ametys.runtime.plugin.PluginsManager.initExtensions(PluginsManager.java:472) at org.ametys.runtime.cocoon.TreeProcessor.compose(TreeProcessor.java:65) ... 29 more Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at org.ametys.runtime.datasource.DataSourceExtensionPoint.addExtension(DataSourceExtensionPoint.java:61) ... 33 more
Does anyone know what is all about? Tried googling, haven't find anything helpful, like restarting the Tomcat.
I know Java for desktop, mobile, but I don't know much of deploying webapps with Tomcat. I'll appreciate any help.
Ok, so the problem was that the Tomcat was missing the mysql-connector-java-5.1.6-bin.jar library. I have placed it in tomcat/lib/, the error is gone. Next time I should look more carefully in the log.