jms connection factory javax.naming.NamingException: Could not create resource factory instance - spring

Hi I am trying to connect WebSphere IBM MQ 7.5.0.7 Connection factory from Tomcat 8. While starting tomcat server we load spring XML, from that we connect to IBM MQ Connection factory.
Below is the code in spring xml.
<bean name="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/JMS/QFX_PF1UATMQCF" />
</bean>
Below code in Context.xml in Tomcat.
<Resource name="JMS/QFX_PF1UATMQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="some hostname"
PORT="1425"
CHAN="SYSTEM.DEF.SVRCONN"
TRAN="1"
QMGR="EUQFXP7A"/>
Below is the exception i am getting while starting tomcat.
Cannot resolve reference to bean 'jmsConnectionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory' defined in class path resource : Invocation of init method failed; nested exception is javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.NoClassDefFoundError: javax/jms/JMSException]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

You need to copy at least the following JAR files to Tomcat (e.g. $CATALINA_BASE/lib):
jms.jar
com.ibm.mq.allclient.jar
As #JoshMc mentioned, you should not use MQ 7.5 anymore.
When starting Tomcat, you may see WARNING messages in catalina.log like this:
24-Feb-2018 22:06:40.473 WARNING [localhost-startStop-1] org.apache.tomcat.util.scan.StandardJarScanner.processURLs Failed to scan [file:.../lib/jms.jar] from classloader hierarchy
java.io.FileNotFoundException: .../lib/jms.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
You can eliminate these warnings by adding the MQ jar to tomcat.util.scan.StandardJarScanFilter.jarsToSkip property in catalina.properties.

Related

Spring Migration to 5.3.19 from 4.3.29 issue with .binding files

I have started my migration of spring version from 4.3.29.RELEASE to 5.3.29 I have fixed some of the issues with servlet and AbstractClientHttpRequest files but I was facing some issue with .binding files, I see they were loading as part of application context after migrating the spring version to 5.3.19 , with the older version of Spring 4.3.29.RELEASE I was able to bring up my application with out any issues. Now with 5.3.19 when I start my application I am getting below issue.
03-May-2022 10:11:00.537 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TestMgmtDAO': Unsatisfied dependency expressed through field 'editorService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'editorService': Unsatisfied dependency expressed through field 'trentonMessagePublisher'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trentonMessagePublisher' defined in class path resource [config/queue-config.xml]: Cannot resolve reference to bean 'jmsTemplate' while setting bean property 'jmsTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [config/queue-config.xml]: Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [config/queue-config.xml]: Cannot resolve reference to bean 'testConnectionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testConnectionFactory' defined in class path resource [config/queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [TEST_QMGR_QCF] is not bound in this Context. Unable to find [TEST_QMGR_QCF].
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testConnectionFactory' defined in class path resource [config/queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [TEST_QMGR_QCF] is not bound in this Context. Unable to find [TEST_QMGR_QCF].
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myTestQueue' defined in class path resource [config/queue-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [Q_OUTBOUND_TEST.CHECK_TO_QUEUETON] is not bound in this Context. Unable to find [Q_OUTBOUND_TEST.CHECK_TO_QUEUETON].
My Sample .binding file is below , I am using IBM MQ.
TEST_QMGR_QCF/RefAddr/1/Type=XXX
TEST_QMGR_QCF/RefAddr/2/Content=XXXX
TEST_QMGR_QCF/RefAddr/3/Content=TEST.TEST.TLS
TEST_QMGR_QCF/RefAddr/4/Content=true
TEST_QMGR_QCF/RefAddr/5/Content=0
TEST_QMGR_QCF/RefAddr/9/Type=TCM
TEST_QMGR_QCF/RefAddr/91/Type=TM
Version of the the IBM Mq jar files used are.
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>1.7.10.RELEASE</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.2.2.0</version>
</dependency>
I have com.sun.jndi.fscontext.RefFSContextFactory entry to to load my .binding files in my beans.xml like below.
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
<prop key="java.naming.provider.url">file:///C:/Local</prop>
</props>
</property>
</bean>
<bean id="umConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="TEST_QMGR_QCF"/>
</bean>
This is where I see with older version of Spring I was able to load the .bindings but with upgrade unable to load.
The best that I can do is to try to point you in the right direction. The .bindings file uses the com.sun.jndi.fscontext.RefFSContextFactory to provide a JNDI like lookup that is initialized from your .bindings file.
You can find some references here IBM and Sun.
Note that the jar files fscontext.jar and providerutil.jar are provided with the IBM MQ distribution in the /opt/mqm/java/lib directory. These are the Sun jars needed for the file system context. These files are not, however, provided by the com.ibm.mq.allclient maven artifact.
These jars must have been provided in your older version. You can find them in Maven Central:
<groupId>com.sun.messaging.mq</groupId>
<artifactId>fscontext</artifactId>
<packaging>jar</packaging>
<version>4.6-b01</version>
Note that the two jars seem to have been merged into the one jar in this artifact. Ensure that these Sun classes are in your current project.
Then, you'll need to find where you are doing something like (from the Sun link):
// Create the environment for constructing the initial JNDI
// naming context.
Hashtable env = new Hashtable();
// Store the environment attributes that tell JNDI which initial context
// factory to use and where to find the provider.//
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:///C:/imq_admin_objects");
// Create the initial context.
Context ctx = new InitialContext(env);
// Look up the connection factory object in the JNDI object store.
String CF_LOOKUP_NAME = "MyConnectionFactory";
ConnectionFactory myFactory = (ConnectionFactory) ctx.lookup
(CF_LOOKUP_NAME);
in your code. Note that the .bindings file name is expected, and that the location specified is a directory where the .bindings file is located.

org.apache.nifi.web.NiFiCoreException: Unable to start Flow Controller

I am setting up a NiFi 1.7.1 release build cluster of 3 nodes.
I am using 3 other nodes for zookeeper (not using the embedded zk)
Using Java 1.8 build 181
Getting this error when starting Nifi in cluster mode with external zookeeper
Nifi-bootstrap.log
2018-08-21 19:58:49,675 INFO [main] org.apache.nifi.bootstrap.Command Launched Apache NiFi with Process ID 14956
2018-08-21 19:58:50,156 INFO [NiFi Bootstrap Command Listener] org.apache.nifi.bootstrap.RunNiFi Apache NiFi now running and listening for Bootstrap requests on port 44710
2018-08-21 19:59:09,700 ERROR [NiFi logging handler] org.apache.nifi.StdErr Failed to start web server: Unable to start Flow Controller.
2018-08-21 19:59:09,701 ERROR [NiFi logging handler] org.apache.nifi.StdErr Shutting down...
2018-08-21 19:59:10,679 INFO [main] org.apache.nifi.bootstrap.RunNiFi NiFi never started. Will not restart NiFi
Nifi-App.log
2018-08-21 19:59:09,222 WARN [main] org.eclipse.jetty.webapp.WebAppContext Failed startup of context o.e.j.w.WebAppContext#7115d5af{/nifi-api,file:///opt/nifi-1.7.1/work/jetty/nifi-web-api-1.7.1.war/webapp/,UNAVAILABLE}{./work/nar/framework/nifi-framework-nar-1.7.1.nar-unpacked/META-INF/bundled-dependencies/nifi-web-api-1.7.1.war}
org.apache.nifi.web.NiFiCoreException: Unable to start Flow Controller.
at org.apache.nifi.web.contextlistener.ApplicationStartupContextListener.contextInitialized(ApplicationStartupContextListener.java:88)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:876)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:532)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:839)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1480)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1442)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:799)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:540)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:290)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.server.Server.start(Server.java:452)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:419)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:838)
at org.apache.nifi.NiFi.<init>(NiFi.java:157)
at org.apache.nifi.NiFi.<init>(NiFi.java:71)
at org.apache.nifi.NiFi.main(NiFi.java:292)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowService': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowController' defined in class path resource [nifi-context.xml]: Cannot resolve reference to bean 'clusterCoordinator' while setting bean property 'clusterCoordinator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clusterCoordinator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clusterCoordinationProtocolSenderListener' defined in class path resource [nifi-cluster-protocol-context.xml]: Cannot resolve reference to bean 'protocolListener' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'protocolListener' defined in class path resource [nifi-cluster-protocol-context.xml]: Unsatisfied dependency expressed through constructor parameter 1: Could not convert argument value of type [null] to required type [int]: Failed to convert value of type 'null' to required type 'int'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type 'null' to required type 'int': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value of type 'null'
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1084)
at org.apache.nifi.web.contextlistener.ApplicationStartupContextListener.contextInitialized(ApplicationStartupContextListener.java:55)
... 33 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowController' defined in class path resource [nifi-context.xml]: Cannot resolve reference to bean 'clusterCoordinator' while setting bean property 'clusterCoordinator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clusterCoordinator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clusterCoordinationProtocolSenderListener' defined in class path resource [nifi-cluster-protocol-context.xml]: Cannot resolve reference to bean 'protocolListener' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with:
The original cause of the exception is Error creating bean with name 'protocolListener' defined in class path resource [nifi-cluster-protocol-context.xml]: Unsatisfied dependency expressed through constructor parameter 1: Could not convert argument value of type [null] to required type [int]: ... Parameter 1 (the second parameter) of protocolListener is the clusterNodeProtocolPort:
<!-- protocol listener -->
<bean id="protocolListener" class="org.apache.nifi.cluster.protocol.impl.SocketProtocolListener">
<constructor-arg index="0">
<bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolThreads"/>
</constructor-arg>
<constructor-arg index="1">
<bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolPort"/>
</constructor-arg>
<constructor-arg ref="protocolServerSocketConfiguration" index="2"/>
<constructor-arg ref="protocolContext" index="3"/>
</bean>
In your nifi.properties file, you should have: nifi.cluster.node.protocol.port=11443 or some other port number. I'm guessing it is blank in your nifi.properties. Remember to set it on each node, and ensure the ports do not conflict if they are running on the same machine.
Make sure all your Zookeeper settings are correct on each node as well.

java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection

I am trying to use WAS liberty rutime profile with eclipse Luna.
My environment:
Window 7
Eclipse luna
Websphere application server tools V8.5 plugin
Websphere liberty profile
My application using spring framework 2.5, and configuration file as below.
<!-- For Oracle and Websphere; you need to use this lob handler definition instead of defaultLobHandler. Because of differences in Oracle's Blob objects. -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" >
<property name="nativeJdbcExtractor" >
<bean class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor"/>
</property>
</bean>
however when I deploy my application into Liberty Profile (LP). for some reason the class can not be loaded properly.
I can find this class in com.ibm.ws.jdbc_1.0.8.jar file, and this jar file located under {server.home}/lib folder. As I understand this library should be loaded automatically.
The detail of error log:
[ERROR ] SRVE0283E: Exception caught while initializing context: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oracleLobHandler' defined in ServletContext resource [/WEB-INF/dataAccessContext.xml]: Cannot create inner bean 'org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor#fff379a3' of type [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor] while setting bean property 'nativeJdbcExtractor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor#fff379a3' defined in ServletContext resource [/WEB-INF/dataAccessContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2388)
at [internal classes]
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004)
... 21 more
Caused by: java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor.<init>(WebSphereNativeJdbcExtractor.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
Any ideas on this issue really appreciate. I really got pain with this one.
Many thanks in advance.
com.ibm.ws.jdbc_1.0.8.jar is OSGi bundle, and package you are referring is not exported, so it is not available for application classes.
I assume that you need that to get to the native connection, for that you have two options:
use the JDBC API unwrap() method, like for example connection.unwrap(). See some examples for connection and prepareStatement here
Update to Spring 3.0.5 or higher and use OracleJdbc4NativeJdbcExtractor instead of WebSphereNativeJdbcExtractor (I didn't test that, but should work in theory).
Do you have the jdbc feature enabled in your server.xml? If you have a recent Liberty installation, I would recommend enabling the webProfile-6.0 feature, which is a combination of many commonly used features.
change:
class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor" />
to:
class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />

Spring OAuth2 implementation with InMemoryTokenStore bean creation issue

I try to implement Oauth2 into my project using this blog
I am newbie on Spring framework, so occured an exception such as ClassNotFoundException, altough all comliant classes exist under right package though.
Source (maven project) can be seen on github
Thank you
Error begins with:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.trafficalarm.rest.security.HierarchicalJsr250Voter] for bean with name 'roleVoter' defined in class path resource [spring/security/security-configuration.xml]; nested exception is java.lang.ClassNotFoundException: com.trafficalarm.rest.security.HierarchicalJsr250Voter
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.trafficalarm.rest.security.HierarchicalJsr250Voter] for bean with name 'roleVoter' defined in class path resource [spring/security/security-configuration.xml]; nested exception is java.lang.ClassNotFoundException: com.trafficalarm.rest.security.HierarchicalJsr250Voter
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.trafficalarm.rest.filter.spring.SpringCrossOriginResourceSharingFilter] for bean with name 'corsFilter' defined in class path resource [spring/oauth/oauth2-configuration.xml]; nested exception is java.lang.ClassNotFoundException: com.trafficalarm.rest.filter.spring.SpringCrossOriginResourceSharingFilter
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.trafficalarm.rest.security.OAuthRestEntryPoint] for bean with name 'oauthRestEntryPoint' defined in class path resource [spring/oauth/oauth2-configuration.xml]; nested exception is java.lang.ClassNotFoundException: com.trafficalarm.rest.security.OAuthRestEntryPoint
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
Make sure you web.xml does initialize spring context correctly:
[UPDATE]
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:app-config.xml
</param-value>
</context-param>
MUST be direct child.
Then, in your app-config you can scan for all components using
<context:component-scan base-package="your.component.package.here"/>
Then you import all of your spring config files
<import resource="classpath:your-resource.xml"/>
I also noticed that the PropertiesPlaceholderConfigurer bean was not correctly configured, so I had to do something like this on one of my spring config files, It was throwing exceptions everywhere because spring did not found the file properties:
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="WEB-INF/application.properties"/>`</bean>`
There are some classes that you won't actually need, but that is up to you. Hope you can figure it out with these hints.
Regards
The essential problem regarding the exception was the build path problem. When i moved security-configuration.xml file content into business-config.xml, ide warned me about build path problem. So i checked the build path of project, maven dependecies seem to be unchecked. I had changed version of JDK previously, so i think that caused unchecked situation. Unfortunatelly, noticing took for a while...

How can i add spring mail api to my project

I am getting below error. org.springframework.mail.javamail.JavaMailSenderImpl is already defined in lib folder. Is spring using javax.mail? Do I need to also add the javax.mail library to my lib folder?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSender' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/mail/MessagingException
My bean;
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
You have to download javax.mail.jar and add it to your classpath.

Resources