Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object - websphere

i am trying to connect db2 from my java code in web sphere application server.
i am getting following exception.please suggest any one on this.
Caused by: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is javax.xml.stream.FactoryConfigurationError: Provider javax.xml.stream.XMLInputFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.sun.xml.internal.stream.XMLInputFactoryImpl not a subtype] at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1232) at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:925) at com.ibm.ws.naming.jndicos.CNContextImpl.processBoundObjectForLookup(CNContextImpl.java:2877) at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:3974) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1876) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1777) at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1434) at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:616) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179) at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161) at javax.naming.InitialContext.lookup(InitialContext.java:428) at com.deere.u90.iaf.jdbc.connection.ConnectionManager.initializeEnvironment(ConnectionManager.java:276) ... 38 more Caused by: javax.xml.stream.FactoryConfigurationError: Provider javax.xml.stream.XMLInputFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.sun.xml.internal.stream.XMLInputFactoryImpl not a subtype at javax.xml.stream.XMLInputFactory.newFactory(Unknown Source) at javax.xml.stream.XMLInputFactory.newInstance(Unknown Source) at com.ibm.websphere.product.metadata.im.IMMetadata.setHistoryEventsFromHistoryXml(IMMetadata.java:745) at com.ibm.websphere.product.metadata.im.IMMetadata.parseHistoryXmlFile(IMMetadata.java:587) at com.ibm.websphere.product.metadata.im.IMMetadata.parseInstallRegistryFiles(IMMetadata.java:399) at com.ibm.websphere.product.metadata.im.IMMetadata.(IMMetadata.java:269) at com.ibm.websphere.product.metadata.im.IMMetadata.getIMMetadataInstance(IMMetadata.java:133) at com.ibm.websphere.product.metadata.WASMetadata.parseMetadataFiles(WASMetadata.java:939) at com.ibm.websphere.product.metadata.WASMetadata.(WASMetadata.java:784) at com.ibm.websphere.product.metadata.WASMetadata.getWASMetadataInstance(WASMetadata.java:215) at com.ibm.websphere.product.WASDirectory.initMetadataInstance(WASDirectory.java:1415) at com.ibm.websphere.product.WASDirectory.getIMLogLocation(WASDirectory.java:435) at com.ibm.websphere.product.VersionInfo.printSource(VersionInfo.java:1534) at com.ibm.websphere.product.VersionInfo.printReport(VersionInfo.java:1322) at com.ibm.websphere.product.VersionInfo.runReport(VersionInfo.java:1064) at com.ibm.websphere.product.VersionInfo.runReport(VersionInfo.java:1025) at com.ibm.ws.rsadapter.spi.ServerFunction$7.run(ServerFunction.java:596) at com.ibm.ws.rsadapter.spi.ServerFunction$7.run(ServerFunction.java:590) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) at com.ibm.ws.rsadapter.spi.ServerFunction.getServerVersion(ServerFunction.java:588) at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.(WSManagedConnectionFactoryImpl.java:748) at java.lang.J9VMInternals.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1899) at com.ibm.ejs.j2c.J2CUtilityClass.createMCFEntry(J2CUtilityClass.java:468) at com.ibm.ejs.j2c.ConnectionFactoryBuilderServerImpl.createMCFandPM(ConnectionFactoryBuilderServerImpl.java:592) at com.ibm.ejs.j2c.ConnectionFactoryBuilderServerImpl.processObjectInstance(ConnectionFactoryBuilderServerImpl.java:1185) at com.ibm.ejs.j2c.ServerFunction.processObjectInstance(ServerFunction.java:2009) at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:662) at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstanceUsingObjectFactoryBuilders(ObjectFactoryHelper.java:349) at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstance(ObjectFactoryHelper.java:89) at org.apache.aries.jndi.OSGiObjectFactoryBuilder.getObjectInstance(OSGiObjectFactoryBuilder.java:62) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:311) at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1122) ... 50 more

I was facing the same issue and here was my resolution
I had wrongly spelled my jta data source in IBM Admin Console and was using a different name in my persistence xml so Websphere couldn't connect.
Please check the Resources Tab in the Admin Console and validate your jta data source name as declared in persistence xml

Related

How to disable all connection pooling in Spring Boot?

Context
By default our SpringBoot application uses HikariCP for its connection pooling.
We are currently investigating how to increase the performance of our application, and want to check out how our load tests behave when using PgPool instead.
It is our understanding that HikariCP and PgPool will not work well with each other and thus that we should be able to disable HikariCP in order to test the performance when using PgPool appropriately.
Question
How does one ensure that no connection pooling ("CP") is used at all at the application level?
Precision
The ultimate goal being to plug PgPool in between our application and our database.
It's my (potentially flawed) understanding that HikariCP should be disabled for that, and that each getConnection() call should return a new connection fetch from the JDBC URL configured for our application. And that that JDBC URL should eventually point to PgPool instead of the DB, which will take care of returning pooled connections.
Attempts
First, we simply removed Hikari from the dependencies:
configurations.all { exclude group: 'com.zaxxer' }
But we'd get this error:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.]
13:04:34.0242 - ERROR TenantId[] UserId[] TraceId[] Thread[main]
Logger[org.springframework.boot.SpringApplication]
Msg[Application run failed]
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
at com.sap.s4hana.eureka.business.centralinventory.application.Application.main(Application.java:17)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthRegistryCustomizer' defined in class path resource
...(I interrupt the stacktrace there due to company policy)
nested exception is java.lang.IllegalStateException: No supported DataSource type found
I eventually got around to adding the following to our dependencies:
implementation 'org.apache.tomcat:tomcat-jdbc:10.0.14'
But then I'm left wondering:
Does Tomcat enable CP by default? (Which would thus mean I have not effectively removed application-level CP)
Is there not a way to simply add a configuration in application.properties to keep the servlet container but avoid CP? (So that I don't need to remove Hikari from the dependencies.)
I also tried adding (inspired by this SO answer):
spring.datasource.type=org.springframework.jdbc.datasource.DriverManagerDataSource
spring.datasource.driver-class-name=org.postgresql.Driver
And also tried replacing that DriverManagerDataSource with SimpleDriverDataSource, but to no apparent avail since I cannot seem to confirm that indeed no CP is used.

Cannot execute update in a read only transaction

As a database we use PostgreSQL. Application uses spring libraries, and transaction is managed by spring. Transactional annotation is used correctly, where it is needed as read-only, and where it is used with write abilities. But in logs we occasinally see exception
2020-12-30 11:39:13.513 [jmsContainer-8] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ERROR: cannot execute nextval() in a read-only transaction
2020-12-30 11:39:13.515 [jmsContainer-8] ERROR o.s.t.s.TransactionSynchronizationUtils - TransactionSynchronization.afterCompletion threw exception
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:780)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:758)
at jdk.internal.reflect.GeneratedMethodAccessor2794.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:301)
at com.sun.proxy.$Proxy226.persist(Unknown Source)
Connections to PostgreSQL is provided through pg_bouncer, and pool_mode=sesssion, the server_reset_query=DISCARD ALL.
We tried restarting the pg_bouncer, though maybe some connection by default set read-only and being kept alive, but it did not help.
Any thoughts?

Connecting NIFI to Posgresql instance java.sql.SQLException: No suitable driver

I'm trying to set up a simple test in Apache Nifi to connect to an existing PostgreSQL instance. I'm able to connect outside of nifi using other tools like dBeaver, and am fairly sure my connection string is proper. I have tried putting the postgresql jdbc driver in all sorts of places, but still keep seeing the "No suitable driver" error. I'll include some screenshots of my DBCPConnectionPool controller as well as my stack traces.
I have seen other posts like this, but none of them seem to lead to any solutions for me. Any help is appreciated.
Stack Trace
19-11-05 23:50:09,933 ERROR [Timer-Driven Process Thread-2] o.a.nifi.processors.standard.ExecuteSQL ExecuteSQL[id=3d68fb42-016e-1000-0ea4-abcc7dcc2e48] Unable to execute SQL select query select * from records; due to org.apache.nifi.processor.exception.ProcessException: java.sql.SQLException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://salt.db.elephantsql.com:5432/oickotoy'. No FlowFile to route to failure: org.apache.nifi.processor.exception.ProcessException: java.sql.SQLException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://salt.db.elephantsql.com:5432/oickotoy'
org.apache.nifi.processor.exception.ProcessException: java.sql.SQLException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://salt.db.elephantsql.com:5432/oickotoy'
at org.apache.nifi.dbcp.DBCPConnectionPool.getConnection(DBCPConnectionPool.java:442)
at org.apache.nifi.dbcp.DBCPService.getConnection(DBCPService.java:49)
at sun.reflect.GeneratedMethodAccessor609.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:87)
at com.sun.proxy.$Proxy91.getConnection(Unknown Source)
at org.apache.nifi.processors.standard.AbstractExecuteSQL.onTrigger(AbstractExecuteSQL.java:223)
at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1176)
at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:213)
at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://salt.db.elephantsql.com:5432/oickotoy'
at org.apache.commons.dbcp2.DriverFactory.createDriver(DriverFactory.java:75)
at org.apache.commons.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:472)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:538)
at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:753)
at org.apache.nifi.dbcp.DBCPConnectionPool.getConnection(DBCPConnectionPool.java:438)
... 19 common frames omitted
Caused by: java.sql.SQLException: No suitable driver
at org.apache.commons.dbcp2.DriverFactory.createDriver(DriverFactory.java:68)
... 23 common frames omitted
What solved this issue for me was oddly enough deleting the Database connection URL (jdbc:postgresql://.....), applying the empty connection string to the controller service, then re-typing the connection string and then applying the now re-typed connection string to the controller service.
Seems like some kind of special character has caused this hiccup
What ended up solving this in the end was a version problem. I was apparently working on a dev release of Nifi that this was broken in. After I upgraded to the latest stable release, my problem went away.

eclipselink and weblogic12g CLOB ClassCastException

I have an application deployed in a Weblogic 12g, and a datasource configured against an oracle RAC.
It uses as JPA provider; EclipseLink 2.4.1.
The problem is this exception;
Caused by: Exception [EclipseLink-3001] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB#87a98a], of class [class weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB], could not be converted to [class java.lang.String].
Internal Exception: java.lang.ClassCastException: oracle.sql.CLOB
....
Caused by: java.lang.ClassCastException: oracle.sql.CLOB
at weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB.length(Unknown Source)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToString(ConversionManager.java:679)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:100)
....
Well, I understand what is the problem but I can't understand why only occurs when some Oracle instance in the Oracle RAC was reset. When this occurs, the only thing to do is restart the WLS instance. ah! While I have this error, the rest of the datatypes work well!.
Maybe there are some kind of direct relaction between LOB types and instances of Oracle servers inside a RAC? It's possible some kind of scenario that restarting an Oracle instance inside a RAC the CLOB datatypes don't works?
Thanks in advance!
Best regards

java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext

When I stop my server I get this exception:
SEVERE: Exception loading sessions from persistent storage
java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext:/Life: no factory registered for this id
at org.springframework.beans.factory.support.DefaultListableBeanFactory$SerializedBeanFactoryReference.readResolve(DefaultListableBeanFactory.java:953)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadResolve(Unknown Source)
Why is that?
My guess: when spring beans are serialized (for example, as part of the http session), on restoring spring tries not to restore their original values (since they might be meaningless after the deserialization), but instead tries to fetch them by their id. If you have changed your bean definitions and have removed the bean in question, and spring tries to deserialize it (from where it has serialized it, under circumstances which I don't know based on the information given), it would throw the exception that no such bean exists.

Resources