We have deployed our application on tomcat server.
Java version - 1.8
Sometime our application is impacted with the error :
SEVERE [main] org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans Exception processing Global JNDI Resources
javax.naming.NamingException: Unexpected exception resolving reference [Root exception is java.sql.SQLException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver']
But whenever we restart the server, it will resolved.
We get this issue once in two days.
Any help in this is appreciated .
Related
My website is/was working just fine. But I am being forced to upgrade the OS of the servers it runs on, because the newer version of a piece of software I need to upgrade, won't run on the old OS. So, now I am in dependency hell.
So, on a test server, I've upgraded the OS from Ubuntu 14.04 to 18.04.1 . I was also forced to use a later version of Java from:
echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
to
echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64/
And the version of Tomcat from 7 to 8.
Having fiddled a bit (I started this in January, but have only just been able to get back to it, so I can't remember what exactly, though can search the history for clues if required), I can build my application OK, but it fails at the final hurdle:
BUILD SUCCESSFUL Total time: 19 seconds Using CATALINA_BASE:
/var/lib/tomcat8 Using CATALINA_HOME: /usr/share/tomcat8 Using
CATALINA_TMPDIR: /var/lib/tomcat8/temp Using JRE_HOME:
/usr/lib/jvm/java-11-openjdk-amd64/ Using CLASSPATH:
/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
Using CATALINA_PID: /root/catalina.pid Tomcat started.
--2019-05-28 16:10:16-- http://localhost:8080/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost
(localhost)|127.0.0.1|:8080... connected. HTTP request sent, awaiting
response... 404 2019-05-28 16:10:16 ERROR 404: (no description).
Further investigation reveals:
less /var/log/tomcat8/catalina.out
2019-05-28 16:10:06.418 UTC [localhost-startStop-1] ERROR
org.springframework.web.context.ContextLoader - Context initialization
failed org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'embedController' defined in ServletContext
resource [/WEB-INF/playground-servlet.xml]: Cannot resolve reference
to bean 'homeController' while settin g bean property
'homeController'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'homeController' defined in ServletContext
resource [/WEB-INF/playground-servlet.xml]: Cannot re solve reference
to bean 'execService' while setting bean property 'execService';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'execService': Invocation of init method
failed; nested exception is javax.ws.rs.ProcessingException:
java.net.ConnectException: Connection refused (Connection refused)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
It should be abundantly clear by now that I don't have much clue what I'm doing. I have spent the afternoon doing lots of googling and looking at lots of Stack Overflow answers, but nothing seems relevant.
that error comes from Spring. For Java 11 support, you'd also need to upgrade Spring to the latest 5.x version (currently 5.2.x).
You may encounter various compatibility issues when upgrading an older environment to Java 11. Unless you absolutely need to upgrade, you may consider staying on a previous version. Java 8 is still being supported.
So I got sort of strange situation. I have Spring webapp and in it I have JNDI datasource that I have defined in tomcat's server.xml to connect to mysql database
I have mysql-connector-java 5.1.2 in my Maven pom.
Application works when I start it from localhost, but when I deploy it to remote tomcat it is not getting the call to the database.
This Exception occurs :
Couldnt execute sql CALL shareholders_company_list(?)
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Unable to create correct SQLException class instance, error class/codes may be incorrect. Reason:
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Can't instantiate required class due to java.lang.ClassNotFoundException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
STACKTRACE:
java.sql.SQLException: Can't instantiate required class due to java.lang.ClassNotFoundException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
Is there away to avoid this ClassNotFoundException, so that I can get full stack trace, since it seems that explicit error why this happens is in MySQLNonTransientConnectionException, and I can't seem to reach it.
import required version(if you don't have any preference go for latest) of mysql-connector-java-latestVersion.jar under tomcat\lib
I'm running a couple of SQL connections from a Job. They are all working with the sqljdbc4.jar, but when I run them with MS SQL Server Native (which was by default) instead of MS SQL Server - they fail with this error:
Error connecting to database [xxx_zxxxx] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver)
Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
at org.pentaho.di.core.database.Database.normalConnect(Database.java:427)
at org.pentaho.di.core.database.Database.connect(Database.java:361)
.................
Caused by: org.pentaho.di.core.exception.KettleDatabaseException:
Can this be caused by the new JDK_1.8 I've installed? How to resolve this issue?
Thank you.
I found a work-around solution that worked just fine in my case. Just remove the sqljdbc.jar and leave only sqljdbc4.jar in my file system. Also added only sqljdbc4.jar to the System variables > path
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
Error! Please, check your JDBC/JDNI Configurations and Database Server avaliability. Could not open or put a Hibernate Session in ValueStack: JDBC Driver class not found: com.mysql.jdbc.driver
File: com/googlecode/s2hibernate/struts2/plugin/interceptors/SessionTransactionInjectorInterceptor.java
Line number: 134
JDBC Driver class not found: com.mysql.jdbc.driver
I have kept MySQL jar in lib and have checked in ref lib all are correct please suggest me ho to solve this issue I am trying to connect db by Hibernate annotation
Stacktraces
org.hibernate.SessionException: Error! Please, check your JDBC/JDNI Configurations and Database Server avaliability. Could not open or put a Hibernate Session in ValueStack: JDBC Driver class not found: com.mysql.jdbc.driver
You have wrong driver class configured. The correct class name com.mysql.jdbc.Driver. See the example of usage here.
We have a project made in netbeans 7.3 and are about to deploying this to a remote glassfish server, everything is configured and set up properly and the connection pools for our project are also generated in glassfish.
Currently we are getting this error when deploying to the remote server:
deploy?DEFAULT=D:\SVN\PTS62\Applicaties\Rekeningrijderwebsite\RekeningRijder\dist\RekeningRijder.war&name=RekeningRijder&contextroot=/RekeningRijder&force=true
failed on GlassFish Server 3+
Error occurred during deployment: Exception while preparing the app :
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a
connection. Cause: Class name is wrong or classpath is not set for :
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Error Code: 0. Please see server.log for more details.
And the message the server generates:
Caused by: javax.resource.ResourceException: Class name is wrong or
classpath is not set for :
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:292)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:114)
at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1307)
at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:163)
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:102)
at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
... 62 more
Google wasn't very helpfull before, so hopefully you guys/girls can help me
Thanks in advance!
You may need a mysql / java connector.
You can find it there. Extract the mysql-connector-java .jar from the archive. Then place it into the glassfish external lib directory {INSTALL DIR}/glassfish/domains/domain1/lib/ext.
Restart your glassfish server.
There are more details on this answer. If that's not what you are looking for, or if it doesn't work, tell us. #+
Right, you just lack mysql lib, just find and download mysql-connector-java-5.x.x-bin.jar copy to E:\Projects\glassfish3.1.1\glassfish\lib then restart server and enjoy !!!