Getting error to failed to look up JNDI DataSource in WebLogic - java

I'm using WebLogic 12.2.1.4, I have already created the datasource with the name "jdbc/TESTDataSource but still getting the below error. Is there are any additional steps that I'm missing here. Please help.
Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'java:comp/env/jdbc/TESTDataSource'; nested exception is javax.naming.NameNotFoundException: While trying to look up comp/env/jdbc/TESTDataSource in /app/webapp/TEST.war/1431676420.; remaining name 'comp/env/jdbc/TESTDataSource'

Related

Overriding Hibernate ConnectionProvider in Spring Boot 2.1

I am upgrading a kotlin Spring Boot 1.x application to use Spring Boot 2.1.6
Previously I used EntityManagerFactoryBeanCallback to set the hibernate.connection.provider_class to our custom implementation of ConnectionProvider. This was deprecated and removed in spring boot 2.0 and 2.1 respectively.
I am now attempting to use a HibernatePropertiesCustomizer
#Bean
fun hibernatePropertiesCustomizer() = HibernatePropertiesCustomizer {
it["hibernate.connection.provider_class"] = ScopedConnectionProvider::class.java.name
}
The application throws an error now:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by:
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
If I comment out the it["hibernate.connection.provider_class"] = ScopedConnectionProvider::class.java.name line everything works except obviously the custom ConnectionProvider
For reference I am using the ScopedConnectionProvider to enable our multitenancy by setting a variable on each connection representing the customers scope ID. Any alternate solution that allows me to run a SET #scope_id = ? query on every connection would also be fine.
Relevant version information:
Spring Boot: 2.1.6
Spring: 5.1.8
Hibernate: 5.3.10
Kotlin: 1.3.21
It turns out that the Datasource was not being injected into my ScopedConnectionProvider correctly anymore. I changed it so that I was inheriting from DatasourceConnectionProviderImpl instead of implementing my own ConnectionProvider from scratch. This seems to have removed the need to specify the dialect.

Solace - Failed to create InitialContext when the solace jar was upgraded to v10.1

We have upgraded the solace version from 7.1 to 10.1 for an existing spring based application. After upgrading it, we started the application and observed the below error. Is new solace jar causing this error?
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solaceConnectionFactory' defined in class path resource [SolRes.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable [Root exception is java.lang.NullPointerException]

How can I resolve the error during starting Tomcat?

I am trying to run Tomcat with web-matrix.war, but I can not.
I am look at log file and see exception:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': Cannot resolve reference
to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'lobHandlerDetector' while setting bean property 'lobHandler';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'lobHandlerDetector': Invocation of init
method failed; nested exception is
org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null' at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
..............................................
Caused by: java.lang.NullPointerException at
sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:524) at
sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:493) at
sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at
java.sql.DriverManager.getDriver(DriverManager.java:262) at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
My settings are:
/usr/share/apache-tomcat-7.0.55/conf/Catalina/localhost/web-matrix.xml
<Context path="/web-matrix" reloadable="true">
<Resource
name="jdbc/webmatrix"
auth="Container"
type="javax.sql.DataSource"
username="webmatrix"
password="webmatrix"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#spb-fusion02:1521:orcl"
/>
</Context>
Does anyone help me?
I've checked the connection with listener. It's good.
[root#spb-fusionwm02 localhost]# /opt/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnsping spb-fusionwm02:1521/orcl
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2014 09:22:17
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=orcl))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.82.64)(PORT=1521)))
OK (10 msec)
in driverClassNamee try :
oracle.jdbc.driver.OracleDriver;
I think the url you are passing to it is not proper so that's why you are getting problem.
where's the oracle DB server reside ?
On your machine or other ?
The error shows that the source / url is null.

javaURLContextFactory ClassNotFound

We are trying to get InitialContext using a listener in web.xml of our application and getting below error:
SEVERE: Unable to init UserDataCachejavax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is
java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:17)
This class is present in catalina.jar.
Java version used is jdk1.6.0_02
Tomcat version is tomcat 7
Please let us know if any one has faced this error or is it related to security manager on server?

JNDI lookup fails in Glassfish

I am working on a web project using maven.When I run the server on net-beans 6.8,the build is succes,but when deploying to server I am getting lookup failed exception.Please find the server log in the following url http://pastie.org/1997218. Let me know What I have missed here. The stack trace for the error is
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'jdbc/deliver' in SerialContext [Root exception is javax.naming.NameNotFoundException: deliver not found]
at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init> (PersistenceUnitInfoImpl.java:111)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:130)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:96)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:121)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:644)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:296)
...
As it seems your production server is missing the database resource jdbc/deliver your application needs. You have configured it properly for your test instance in NetBeans. Have a look at the Services tab in NetBeans and make sure you have a similar database set up on your server.

Categories