Integrating Cassandra with Apache Ignite - caching

I have downloaded the 2.7.5 binary of Apache Ignite. I referred to the xml file in the Cassandra-Ignite integration official docs. However, all the beans are failing to load. The configuration file is in my desktop folder. Running Ignite from the folder where I have extracted the binary zip.
The error:
Failed to instantiate Spring XML application context [springUrl=file:/C:/Users/Username/Desktop/ignite-con-new.xml, err=Configuration problem: Failed to import bean definitions from URL location
The config file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Cassandra connection settings -->
<import resource="classpath:org/apache/ignite/tests/cassandra/connection-settings.xml" />
<!-- Persistence settings for 'cache1' -->
<bean id="cache1_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
<constructor-arg type="org.springframework.core.io.Resource" value="classpath:org/apache/ignite/tests/persistence/blob/persistence-settings-1.xml" />
</bean>
<!-- Persistence settings for 'cache2' -->
<bean id="cache2_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
<constructor-arg type="org.springframework.core.io.Resource" value="classpath:org/apache/ignite/tests/persistence/blob/persistence-settings-3.xml" />
</bean>
<!-- Ignite configuration -->
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
<property name="dataSourceBean" value="cassandraAdminDataSource"/>
<property name="persistenceSettingsBean" value="cache1_persistence_settings"/>
</bean>
</property>
</bean>
<!-- Configuring persistence for "cache2" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache2"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
<property name="dataSourceBean" value="cassandraAdminDataSource"/>
<property name="persistenceSettingsBean" value="cache2_persistence_settings"/>
</bean>
</property>
</bean>
</list>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
I understand it is failing to find the bean locations. What do you think is a possible fix to this?
The full stacktrace:
C:\Users\Username\Downloads\ignitecode\s1>bin\ignite.bat C:\Users\Username\Desktop\ignite-con-new.xml
class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context [springUrl=file:/C:/Users/Username/Desktop/ignite-con-new.xml, err=Configuration problem: Failed to import bean definitions from URL location [classpath:org/apache/ignite/tests/cassandra/connection-settings.xml]
Offending resource: URL [file:/C:/Users/Username/Desktop/ignite-con-new.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist]
at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1026)
at org.apache.ignite.Ignition.start(Ignition.java:351)
at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:301)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=file:/C:/Users/Username/Desktop/ignite-con-new.xml, err=Configuration problem: Failed to import bean definitions from URL location [classpath:org/apache/ignite/tests/cassandra/connection-settings.xml]
Offending resource: URL [file:/C:/Users/Username/Desktop/ignite-con-new.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist]
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:392)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:751)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:952)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:861)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:731)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:700)
at org.apache.ignite.Ignition.start(Ignition.java:348)
... 1 more
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:org/apache/ignite/tests/cassandra/connection-settings.xml]
Offending resource: URL [file:/C:/Users/Username/Desktop/ignite-con-new.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:118)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:103)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:233)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:169)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:379)
... 9 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:227)
... 18 more
Caused by: java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
... 22 more
Failed to start grid: Failed to instantiate Spring XML application context [springUrl=file:/C:/Users/Username/Desktop/ignite-con-new.xml, err=Configuration problem: Failed to import bean definitions from URL location [classpath:org/apache/ignite/tests/cassandra/connection-settings.xml]
Offending resource: URL [file:/C:/Users/Username/Desktop/ignite-con-new.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml] cannot be opened because it does not exist]

Rule of thumb of reading Spring errors is scrolling all the way down.
nested exception is java.io.FileNotFoundException:
class path resource [org/apache/ignite/tests/cassandra/connection-settings.xml]
cannot be opened because it does not exist
Looks like the resource is not where your XML expects it to be. Please note that src/main/resources can contain arbitrary directory structure, such as src/main/resources/org/apache/ignite/tests/cassandra <-- maybe that's where the file should go?

Related

dataSource on Websphere liberty

I'm trying to setup a datasource on websphere-liberty:springBoot2 docker image. I'm shared a war file and a server.xml file that contains a jdni definition
<dataSource id="oracle" jndiName="jdbc/oracle">
<jdbcDriver libraryRef="OracleLib"/>
<properties ....... />
</dataSource>
The war file has the bean definition:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/oracle"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>
But the next error stack appears:
Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException:
JndiObjectTargetSource failed to obtain new target object;
nested exception is javax.naming.NamingException:
CWWKE0800W: An attempt was made to retrieve an initial context for [jdbc/oracle] but no JNDI feature is configured.
I'm shared both the server.xml and the ojdbc8.jar, to container. Thanks in advance.
You need to enable the JNDI feature by adding <feature>jndi-1.0</feature> to the <featureManager> element of your server.xml And you probably want to use the Oracle specific config element properties.oracle not the generic driver config element properties

Trying to deploy a Spring Service on WSO2 Application Service

I'm trying to deploy a Spring Service in WSO2 Application Service. I did THIS tutorial and the app works fine on Eclipse, but when I try to deploy it on WSO2 I get this error:
Cannot load Spring beans. Please check the Spring context
configuration file and verify that the defined Spring beans exist in
the .jar file.
I unziped de .jar file and JdbcCustomerDAO class is there with all the others.
Spring context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="customerDAO" class="com.mkyong.customer.dao.impl.JdbcCustomerDAO">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="url" />
<property name="username" value="username" />
<property name="password" value="password" />
</bean>
</beans>
I also tried to include spring and mysql-connector-java jars on /repository/components/extensions as says HERE.
EDIT:
ERROR {org.wso2.carbon.springservices.ui.SpringServiceMaker} - Cannot
load Spring beans. Please check the Spring context configuration file
and verify that the defined Spring beans exist in the .jar file.
{org.wso2.carbon.springservices.ui.SpringServiceMaker}
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class
[org.springframework.jdbc.datasource.DriverManagerDataSource] for bean
with name 'dataSource' defined in resource loaded through InputStream;
nested exception is java.lang.ClassNotFoundException:
org.springframework.jdbc.datasource.DriverManagerDataSource
Looks like it couldn't find spring-jdbc, so I added the jar to extensions but now I get this error:
ERROR {org.wso2.carbon.springservices.ui.SpringServiceMaker} - Cannot load
Spring beans. Please check the Spring context configuration file and
verify that the defined Spring beans exist in the .jar file.
{org.wso2.carbon.springservices.ui.SpringServiceMaker}
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in resource loaded
through InputStream: Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class
[org.springframework.jdbc.datasource.DriverManagerDataSource]:
Constructor threw exception; nested exception is
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
I understand that commons.logging is also missing, but when I try to add it to extensions, WSO2 doesn't start. I get a lot of
Log4j:ERROR Could not instantiate...

Struts/Spring WebSphere jndi error

I'm fairly new with WebSphere (mainly worked with Tomcat) and am trying to host a Struts/Spring/Hibernate website. The website is supposed to be able to look up data from an Oracle database and display that information.
I'm currently not able to get the website running and it seems to be a jndi error. Here is the error:
[ERROR ] Context initialization failed
Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/jdbc/test JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. [Root exception is com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/jdbc/test reference. The exception message was: CWNEN1003E: The server was unable to find the jdbc/test binding with the javax.sql.DataSource type for the java:comp/env/jdbc/test reference.]
[ERROR ] SRVE0283E: Exception caught while initializing context: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/jdbc/test JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. [Root exception is com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/jdbc/test reference. The exception message was: CWNEN1003E: The server was unable to find the jdbc/test binding with the javax.sql.DataSource type for the java:comp/env/jdbc/test reference.]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
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)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2374)
at [internal classes]
Caused by: javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/jdbc/test JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. [Root exception is com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/jdbc/test reference. The exception message was: CWNEN1003E: The server was unable to find the jdbc/test binding with the javax.sql.DataSource type for the java:comp/env/jdbc/test reference.]
at com.ibm.ws.injectionengine.osgi.internal.naming.InjectionJavaColonHelper.newCannotInstantiateObjectException(InjectionJavaColonHelper.java:134)
at [internal classes]
at javax.naming.InitialContext.lookup(Unknown Source)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
at org.springframework.jndi.JndiObjectTargetSource.afterPropertiesSet(JndiObjectTargetSource.java:97)
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.createJndiObjectProxy(JndiObjectFactoryBean.java:318)
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.access$000(JndiObjectFactoryBean.java:307)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:200)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 24 more
Caused by: com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/jdbc/test reference. The exception message was: CWNEN1003E: The server was unable to find the jdbc/test binding with the javax.sql.DataSource type for the java:comp/env/jdbc/test reference.
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1087)
... 38 more
Caused by: com.ibm.wsspi.injectionengine.InjectionException: CWNEN1003E: The server was unable to find the jdbc/test binding with the javax.sql.DataSource type for the java:comp/env/jdbc/test reference.
at com.ibm.ws.injectionengine.osgi.internal.IndirectJndiLookupObjectFactory.getObjectInstance(IndirectJndiLookupObjectFactory.java:201)
... 38 more
Here is my WebSphere server.xml
<server description="new server">
<featureManager continueOnError="false">
<feature>localConnector-1.0</feature>
<feature>servlet-3.0</feature>
<feature>jsp-2.2</feature>
<feature>jaxrs-1.1</feature>
<feature>jndi-1.0</feature>
</featureManager>
<applicationMonitor updateTrigger="disabled"/>
<application id="proxy" location="proxy.war" name="proxy" type="war">
</application>
<httpEndpoint id="defaultHttpEndpoint"
host="localhost"
httpPort="9080"
httpsPort="9443" />
<dataSource id="oracle" jndiName="jdbc/test" type="javax.sql.DataSource">
<jdbcDriver libraryRef="oracle-lib" id="oracle-driver"/>
<connectionManager numConnectionsPerThreadLocal="10" id="ConnectionManager" minPoolSize="1"/>
<properties.oracle user="test" password="test" URL="jdbc:oracle:thin:#test.local:1521:STILOG"/>
</dataSource>
<library id="oracle-lib">
<fileset dir="C:/Users/test/workspace/WebAdmin/WebContent/WEB-INF/lib/" includes="ojdbc6.jar"/>
</library>
<application context-root="WebAdmin" id="WebAdmin" location="WebAdmin.war" name="WebAdmin" type="war">
<classloader delegation="parentLast" commonLibraryRef="oracle-lib"/>
</application>
</server>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="commonService" class="com.ddvc.service.CommonServiceImpl"/>
<bean id="mainMenuService" class="com.ddvc.service.MainMenuServiceImpl"/>
<bean id="storeFilterService" class="com.ddvc.service.StoreFilterServiceImpl"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="ORACLE" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="persistenceUnitName" value="pu1" />
<property name="jpaProperties">
<props>
<prop key="org.hibernate.envers.store_data_at_delete">true</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<!-- value>java:/comp/env/IVRConfig</value -->
<!-- value>IVRConfigCluster</value -->
<value>java:comp/env/jdbc/test</value>
</property>
<property name="lookupOnStartup"
value="true"/>
<property name="cache"
value="true"/>
<property name="proxyInterface"
value="javax.sql.DataSource"/>
</bean>
<!-- <jee:jndi-lookup id="dataSource" -->
<!-- jndi-name="java:comp/env/jdbc/test" -->
<!-- cache="true" -->
<!-- resource-ref="true" -->
<!-- lookup-on-startup="true" -->
<!-- proxy-interface="javax.sql.DataSource"> -->
<!-- </jee:jndi-lookup> -->
<!-- <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> -->
<!-- <bean id="pum" -->
<!-- class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> -->
<!-- <property name="persistenceXmlLocations"> -->
<!-- <list> -->
<!-- <value>classpath:META-INF/persistence.xml</value> -->
<!-- </list> -->
<!-- </property> -->
<!-- <property name="defaultDataSource" ref="dataSource"></property> -->
<!-- </bean> -->
<!-- <bean id="emf-p" -->
<!-- class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> -->
<!-- <property name="persistenceXmlLocation" value="/WebContent/META-INF/persistence.xml" /> -->
<!-- <property name="persistenceUnitManager" ref="pum"/> -->
<!-- <property name="persistenceUnitName" value="pu1" /> -->
<!-- <property name="loadTimeWeaver"> -->
<!-- <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> -->
<!-- </property> -->
<!-- </bean> -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="loginAction" scope="prototype" class="com.ddvc.action.LoginAction">
<constructor-arg ref="commonService" />
</bean>
<bean id="userAction" scope="prototype" class="com.ddvc.action.UserAction">
<constructor-arg ref="commonService" />
</bean>
<bean id="mainMenuAction" scope="prototype" class="com.ddvc.action.MainMenuAction">
<constructor-arg ref="mainMenuService" />
</bean>
</beans>
ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host" />
<resource-ref name="jdbc/test" binding-name="jdbc/test"/>
</web-bnd>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>WebAdmin</display-name>
<!-- Include this if you are using Hibernate -->
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<resource-ref>
<description>DataSource</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<mapped-name>jdbc/test</mapped-name>
</resource-ref>
</web-app>
It was suggested to try that <jee:jndi-lookup id="dataSource">, and I got it hooked up. But it acted the exact same way as the <bean id="dataSource">.
This is not correct way to do it. Do as follows:
In Eclipse, go to Help > Eclipse Marketplace
Search for ibm liberty, you will find - WebSphere Application Server Liberty Profile Developer tools for Luna (or other Eclipse version you are using). Install the tools.
After installation, you will be able to create new server - WebSphere Application server Liberty Profile - create it. The Web Preview you were trying to use is for static files, not Java EE applications.
In the wizard creating server you will have option to download server runtime, do it. You can also download it manually from wasdev.net:
Download Liberty profile in Eclipse
Download just the Liberty profile runtime
Add your application to the server. In the Servers view, expand Liberty server and double click Server configuration. You will have feature manager there, and you will be able to add jdbc there.

Configuration Issue during spring upgrade

Below is the issue i am facing during the spring upgrade.I feel the issue is with the doctype.Please suggest
Bean 'cdqiPerformanceMonitor'; nested exception is
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Old 1.x 'singleton' attribute in use - upgrade to
'scope' declaration
Offending resource: ServletContext resource [/WEB-
INF/applicationContext.xml]
Below is the application context xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="cdqiPerformanceMonitor"
class="com.tms.cdqi.framework.aop.interceptor.CDQIPerformanceMonitorInterceptor" />
<bean id="cdqiApplicationContextFactory"class="com.tms.cdqi.framework.context.CDQIApplicationContextFactoryImpl" />
<bean id="commandInvoker"class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean"
lazy-init="true">
<property name="jndiName">
<value>ejb/CommandInvokerLocal</value>
</property>
<property name="businessInterface">
<value>
com.tms.cdqi.application.command.invoker.CommandInvoker
</value>
</property>
</bean>
</beans>
Below is the stack trace
listener org.springframework.web.context.ContextLoaderListener
failed:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unexpected failure during bean definition parsing
Offending resource: ServletContext resource [/WEB-
INF/applicationContext.xml]
Bean 'cdqiPerformanceMonitor'; nested exception is
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Old 1.x 'singleton' attribute in use - upgrade to
'scope' declaration
Offending resource: ServletContext resource [/WEB-
INF/applicationContext.xml]
See SPR-12167. Spring no longer accepts singleton="true", so you must use scope="singleton" instead.

persistence.xml - spring JPA

I have read dozens of articles, but I cant figure out, where the mistake is... it should be really simple. I'm trying to write app on appengine using Spring and JPA.
I am using JEE5 project (dont know if it matters)
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocation">
<value>classpath*:/META-INF/persistence.xml</value>
</property>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="transactions-optional" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
The persistence.xml file is located in META-INF directory (ROOT/META-INF/persistence.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
</persistence>
I still get this exception (i was trying to move meta-inf directory in src directory with no success, the exception was the same)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericJpaDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected javax.persistence.EntityManagerFactory cz.cvut.fel.pupilbook.dao.support.jpa.GenericJpaDAO.entityManagerfactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/context/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No Persistence provider for EntityManager named transactions-optional
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
Thanks for help.
The anwer consists of two parts.
denisk was correct about the location of persistence.xml, it should be under src.
I was missing some dependencies to datanucleus (I thought they are provided). After adding them I got plenty of relevant exceptions. After resolving them everything works.
So - it was coincidence of two problem, each of them masked part of the other.

Resources