Hi have a tomcat server with a web app in that is supposed to connect to a MySQL database.
The driver is loaded when I use -verbose:class
[Loaded com.mysql.jdbc.Driver from file:/app/tomcat/8.5.4/webapps/my-app/WEB-INF/lib/mysql-connector-java-5.1.36.jar]
But for some reason it's still throwing me an exception when loading spring context:
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.RuntimeException: Could not load class of driverClassName com.mysql.jdbc.Driver
I tried to move the connector lib file to tomcat lib folder, but it didn't change anything. I tried different versions of the connector still same issue.
I can't find out what exactly problem is without your code files: but i can guess, due to this problems it throws this kinda Exception.
Possible solution, there's some mistake in database property file.
This is some property, you can check, give database name and username password according to your system. The problem occurs due to single . or , or ; too.. You can find more detail here.
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/mydb
jdbc.username=myinfuser
jdbc.password=myinfuserpw
Related
APPLICATION FAILED TO START
Description:
Binding to target HikariDataSource (HikariPool-1) failed:
Property: spring.datasource.hikari.connectionTestQuery
Value: SELECT 1
Reason: Property 'connectionTestQuery' threw exception; nested exception is java.lang.IllegalStateException: The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes.
As per Hikari documentation, you may not required to set this property if you use latest JDBC drivers. This property is for legacy JDBC drivers (<JDBC4).
You can try running your application without setting this property. Moreover, if still issue persists, please share hikari bean definition; I will update my answer based on that.
After upgrading the application to the below version of the spring boot, the application started with no errors
<parent>
<groupId>com.accurate.boot</groupId>
<artifactId>accurate-spring-starter-parent</artifactId>
<version>1.5.22.RELEASE</version>
We have a Spring application deployed on tomcat, and it does not start.
The application error is as follows:
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${hibernate.connection.driver_class}]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1564)
... 49 more
We do have a properties file defined at:
/opt/tomcat/appname/tomcat8-2
with three files: config.properties, core-ws.proprties, and log4j-config.xml
We know ${TOMCAT_CONFIG_HOME} is defined to be: /opt/tomcat/appname/tomcat8-2
We know that the file permissions are correct, the user running tomcat has read permissions to the directories and files in this config directory. I can as that tomcat user edit/read the properties file. So, we know it's not a permissions issue.
From the app log, we have this error message:
Skipped XML bean definition file due to specified profiles [default] not matching: class path resource [spring/app-platform-entity-context.xml]
The Spring application context file has this for properties:
<beans profile="default">
<context:property-placeholder location="file:${TOMCAT_CONFIG_HOME}/core-ws.properties" />
</beans>
Finally here is what the core-ws.properties looks like:
hibernate.connection.url=jdbc:oracle:thin:#//123.456.789/APP_DB
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.username=some_db_user
hibernate.connection.password=some_db_password
So, I have looked into this for a coupe of days, and I am at my wits end. I can tell you we have no problem with the log4j-config.xml file. The app can find it, and read it just fine. it is just this one parameter that seems to be crashing the app ...
Any help with this matter would be much appreciated. Thanks!
The reason that XML file was skipped was because we had a -Dspring.profiles.active=prod in our CATALINA_OPTS setup.
We didn't find it until we started exporting what the values were as tomcat started.
Once we removed this line, our [default] profile tookover as it should.
Thanks!
Answering this for stand-alone apps:
In my case it was because of the order of setting up ApplicationContext, I was loading the xml file, before setting the profile.
The correct order is:
GenericXmlApplicationContext ctx =
new GenericXmlApplicationContext();
ctx.getEnvironment().setActiveProfiles("dev");
ctx.load("com/profiles/*-config.xml");
ctx.refresh();
I am trying to program in java using both jdbc and rmi but i am not able to to run the program without exporting classpath for stub for e.g. if my stub is located "home/java" i need to export it using "export CLASSPATH="home/java" and if i don't export it is throwing following exception :
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: GImplement_Stub
Now the problem is when i am exporting the path for the stub may be mysql database path is getting overwritten and it is throwing :
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
though if i am not exporting any path other jdbc programs are working fine.
How can this be resolved?
You can have multiple entries in the CLASSPATH variable and the -cp command-line argument separated by the colon character :.
However I would strongly recommend maven for this job, as it makes building way, way easier than juggling classpaths by hand...
hi guyz I'm new to spring JDBC I'm running first JDBCSpring application given in javaTpoint but I'm getting above error..please help me to solve this error.Iadded jdbc14.jar and all related jars also.
The message says, that you have to add the oracle jdbc driver to your classpath.
My java EE application is giving following error when i try to run the application on glassfish server. It says "Invalid resource : jdbc/busservice__nontx". Where should i look to fix this error? Previously it was giving error with "jdbc/busservice__pm". Once I created JDBC resource and connected with connection pool, error disappeared. However i'm still getting error with "jdbc/busservice__nontx"
Info: PER02100: Could not load Toplink Essentials. Assuming this is an upgrade from V2. Switching Persistence Unit [BusReservationPU] to use [org.eclipse.persistence.jpa.PersistenceProvider] as JPA provider. If you intend to use Toplink Essentials, please ensure that it is visible to your application."
Severe: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
Severe: java.lang.RuntimeException: Invalid resource : jdbc/busservice__nontx
at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:593)
at com.sun.enterprise.connectors.ConnectorRuntime.lookupNonTxResource(ConnectorRuntime.java:559)
at org.glassfish.persistence.common.PersistenceHelper.lookupNonTxResource(PersistenceHelper.java:59)
at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupNonTxDataSource(ProviderContainerContractInfoBase.java:76)
at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:109)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:142)
Do not add "jdbc/busservice__pm" to your Glassfish JDBC Resources, just add it as "jdbc/busservice". It looks like the __pm and __nontx are some internal names that it adds to the end of your jdbc name internally, and when you specifically add it will mess it up and throw that error.