authsource in mongodb spring - mongodb

Hi I am using Spring MVC with MongoDB.
I would like to know where i have to mention the parameter "Authsource=admin".
same time i am not able to give mongoCredentials in mongoTemplate bean, it throwing bean create exception.
Below is my dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="54.172.243.152" />
<property name="port" value="27005" />
</bean>
<bean id="mongoCredentials" class="org.springframework.data.authentication.UserCredentials">
<constructor-arg name="username" value="smynapati" />
<constructor-arg name="password" value="smynapati" />
<!-- <constructor-arg name="authSource" value="admin" /> -->
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongo" ref="mongo" />
<!-- <constructor-arg name="mongoCredentials" ref="mongoCredentials" /> -->
<constructor-arg name="databaseName" value="test1" />
</bean>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<context:component-scan base-package="com.userlogin"/>
<bean id="ViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

Assuming you are using version 1.5.2.RELEASE of spring-data-mongodb (as I remember from a previous question of yours) and the credentials are stored in the admin database these should be your MongoDB related beans settings:
<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="54.172.243.152" />
<property name="port" value="27005" />
</bean>
<bean id="mongoCredentials" class="org.springframework.data.authentication.UserCredentials">
<constructor-arg name="username" value="smynapati" />
<constructor-arg name="password" value="smynapati" />
</bean>
These stay intact. Next come:
<bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg name="mongo" ref="mongo" />
<constructor-arg name="databaseName" value="test1" />
<constructor-arg name="credentials" ref="mongoCredentials" />
<constructor-arg name="authenticationDatabaseName" value="admin" />
</bean>
Finally comes the template:
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
Note that you'd better use the mongo XML namespace for simplicity.

Related

How config MyBatis in one Ignite XML config, without java files

I use docker ignite with install libs ignite-zookeeper,ignite-rest-http and external https://github.com/mybatis/ignite-cache/releases/download/mybatis-ignite-1.0.5/mybatis-ignite-1.0.5.jar
all nodes have this config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
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
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Configuring cache. -->
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="Person" />
<property name="cacheMode" value="PARTITIONED" />
<property name="atomicityMode" value="TRANSACTIONAL" />
<property name="writeSynchronizationMode" value="FULL_SYNC" />
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Long" />
<property name="valueType" value="Person" />
<property name="fields">
<map>
<entry key="firstName" value="java.lang.String" />
<entry key="lastName" value="java.lang.String" />
<entry key="resume" value="java.lang.String" />
<entry key="salary" value="java.lang.Integer" />
</map>
</property>
<property name="indexes">
<list>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg value="salary" />
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder">
<property name="allowDuplicateRegistrations" value="false" />
<property name="basePath" value="/ignite" />
<property name="serviceName" value="Service" />
<property name="zkConnectionString" value="zk.zookeeper:2181" />
</bean>
</property>
</bean>
</property>
</bean>
</beans>
Is it possible to create sql queries in the same configuration file and then call them via rest api?
for example:
curl http://host:port/ignite?cmd=exe&name=getUser&id=1
and rest api execute sql query SELECT * FROM PERSON WHERE _key = #{id} and return result
No, this is not possible. REST API for SQL queries is described here: https://apacheignite.readme.io/docs/rest-api#sql-query-execute

Spring SAML - Using multiple IDP certificates from keystore instead of metadata XML

I was able to integrate my application (SP) with Okta (IDP).
I will be only performing IDP-initiated logins.
But Okta will not be my only IDP and I do not want to keep adding new IDP metadata XML's to my applications (because that means I need to edit my spring XML file and add a new IDP and restart the server).
So I just want to import the IDP x509certificates (public key) into my keystore and use them to verify my SAML responses. Is that possible?
Or in other words, I want to register an IDP at runtime without making any changes to my application or restarting it.
If yes, can you provide resources on how to do that?
Currently I have provided Okta's metadata XML like below in my application's spring xml file.
<bean id="metadata" class="org.springframework.security.saml.metadata.MetadataManager">
<constructor-arg>
<list>
<bean class="org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider">
<constructor-arg>
<value type="java.io.File">C:\\DEV\\idp_metadata\\metadata.xml</value>
</constructor-arg>
<property name="parserPool" ref="parserPool" />
</bean>
</list>
</constructor-arg>
</bean>
Thanks,
Abhishek
I completed the changes to my application to make it dependent on an IDP's certificate present in a keystore.
But with a caveat, if a new IDP certificate is added in future, it requires a server restart.
I changed the securityProfile to pkix instead of the default metaIOP
<bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
<constructor-arg>
<bean class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider">
<constructor-arg>
<bean class="java.util.Timer" />
</constructor-arg>
<constructor-arg>
<bean class="org.opensaml.util.resource.FilesystemResource">
<constructor-arg value="${path.to.SP.metadata}" />
</bean>
</constructor-arg>
<property name="parserPool" ref="parserPool" />
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.saml.metadata.ExtendedMetadata">
<property name="local" value="true" />
<property name="securityProfile" value="pkix" />
<property name="sslSecurityProfile" value="pkix" />
<property name="requireArtifactResolveSigned" value="false" />
<property name="requireLogoutRequestSigned" value="false" />
<property name="requireLogoutResponseSigned" value="false" />
<property name="idpDiscoveryEnabled" value="false" />
<property name="supportUnsolicitedResponse" value="true" />
</bean>
</constructor-arg>
</bean>
Added the certificate to a .jks file: keytool -importcert -file certificate.txt -keystore keystore.jks -alias "Alias"
Implemented a SAMLContextProviderLB and injected pkixresolver
<bean id="contextProvider" class="org.springframework.security.saml.context.SAMLContextProviderLB">
<property name="scheme" value="${saml.loadBalancer.scheme}" />
<property name="serverName" value="${saml.loadBalancer.serverName}" />
<property name="serverPort" value="${saml.loadBalancer.serverPort}" />
<property name="includeServerPortInRequestURL" value="${saml.loadBalancer.includeServerPortInRequestURL}" />
<property name="contextPath" value="/contextPath" />
<property name="pkixResolver">
<bean class="org.springframework.security.saml.trust.PKIXInformationResolver">
<constructor-arg index="0" ref="metadataCredResolver" />
<constructor-arg index="1" ref="metadata" />
<constructor-arg index="2" ref="trustedKeyManager" />
</bean>
</property>
<property name="storageFactory">
<bean class="org.springframework.security.saml.storage.EmptyStorageFactory" />
</property>
</bean>
<bean id="metadataCredResolver" class="org.springframework.security.saml.trust.MetadataCredentialResolver">
<constructor-arg index="0" ref="metadata" />
<constructor-arg index="1" ref="trustedKeyManager" />
<property name="useXmlMetadata" value="false" />
</bean>
<bean id="trustedKeyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="${saml.trust.jks.filePath}" />
<constructor-arg type="java.lang.String" value="${saml.trust.jks.password}" />
<constructor-arg>
<map>
<entry key="${saml.trust.jks.defaultKey.name}" value="${saml.trust.jks.defaultKey.password}" />
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="${saml.trust.jks.defaultKey.name}" />
</bean>
Implemented a few classes to override the need of a metadata XML.
SAMLProcessorImpl and WebSSOProfileConsumerImpl
I remove the dependency on getPeerEntityID / getPeerEntityMetadata.getEntityID() and replace it with response.getIssuer().getValue() because both have to be the same for SAML to work.
The trust certificates are obtained from the keystore which is loaded once during startup.
In my next update I will try to figure out how to perform a timed refresh of the .jks file to load new certificates.

Unable to Load Entities in Jboss Fuse ESB

My META-INF/Persistence xml is as follows
<persistence-unit name="jpapoc" transaction-type="RESOURCE_LOCAL">
<class>com.xxx.jpa.PersonEntity</class>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
My META-INF/spring/beans.xml as follows
<cxf:cxfEndpoint address="/services/sm" id="sm"
serviceClass="com.xxx.jpa.MyWebService">
<cxf:properties>
<entry key="dataFormat" value="POJO" />
<entry key="setDefaultBus" value="true" />
</cxf:properties>
</cxf:cxfEndpoint>
<bean id="myProcessor" class="com.xxx.jpa.PersonProcessor">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="jpapoc" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
</bean>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:#localhost:1523:xx" />
<property name="user" value="test" />
<property name="password" value="test" />
</bean>
<camel:camelContext>
<camel:route>
<camel:from uri="cxf:bean:sm?synchronous=true" />
<camel:process ref="myProcessor" />
</camel:route>
</camel:camelContext>
When i try to deploy this application in Jboss Fuse ESB I am getting Caused by: java.lang.ClassNotFoundException: com.xxx.jpa.PersonEntity not found by org.hibernate.entitymanager
I have used #Entity in Person Entity classes and also gave dymanic import in pom.xml but still it is not working
Its hard to point out the issue without having code.However you can check your bundled jar file if it contains the com.xxx.jpa.PersonEntity class.Also try adding Meta-Persistence=META-INF/persistence.xml instruction to your pom file.

Spring Batch Caused by: java.lang.IllegalStateException: Existing transaction detected in JobRepository

I am getting this error in while running the batch job. I am very much new to Spring Batch so guys plz help as i didn't knw wht to do with this error. There is no other Batch job running in my system also .
My root-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<import resource="job-context.xml"/>
<aop:aspectj-autoproxy />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg><ref bean="dataSource" /></constructor-arg>
</bean>
<bean id="dataSource" class="com.qr.jadu.tx.conpoolrouter.DataSourceRouter">
<property name="targetDataSources">
<map key-type="com.qr.jadu.tx.conpoolrouter.TransactionTypes">
<entry key="RO" value-ref="schedules-read-dataSource" />
<entry key="RW" value-ref="schedules-write-dataSource" />
</map>
</property>
<property name="defaultTargetDataSource" ref="schedules-read-dataSource" />
</bean>
<bean id="masters-read-dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/masterDatabase"/>
</bean>
<bean id="schedules-read-dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/scheduleDatabase"/>
</bean>
<bean id="schedules-write-dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/scheduleDatabase"/>
</bean>
<bean id="security-read-dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/sysDs"/>
</bean>
<bean id="csp-read-dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/cspDatabase"/>
</bean>
<bean id="schedules-punitpostprocessor" class="com.qr.jadu.entity.helper.JaduPersistenceUnitPostProcessor">
<property name="locationPatterns">
<list>
<value>classpath*:com/croamis/**/*.class</value>
</list>
</property>
</bean>
<alias name="schedules-dataSource" alias="lov-dataSource"/>
<bean id="schedules-entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<value>com.croamis.schedules</value>
</property>
<property name="persistenceUnitName" value="schedulesPU" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
</bean>
</property>
<property name="persistenceUnitPostProcessors">
<list>
<ref bean="schedules-punitpostprocessor" />
</list>
</property>
<property name="jpaProperties">
<!-- To run with MySQL -->
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
</props>
<!-- To run with Oracle -->
<!--
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
</props>
-->
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="schedules-entityManagerFactory" />
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
My job-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema /batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<job id="GenerateOperationalFlightJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1">
<tasklet task-executor="taskexecutor">
<chunk reader="ScheduleRecordsAdapter" processor="scheduleRecordProcessor" writer="operationalFlightWriter" commit-interval="1">
</chunk>
</tasklet>
</step>
<bean id="ScheduleRecordsAdapter" class="org.springframework.batch.item.adapter.ItemReaderAdapter">
<property name="targetObject" ref="scheduleRecordsRetrievalAdapter"/>
<property name="targetMethod" value="getScheduleRecord"/>
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="mysql" />
<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT"/>
</bean>
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
</beans>

Using Spring data JPA with MS SQL server

I am setting up an app using Spring data JPA, Hibernate and MS SQL Server and unfortunately, I got a beat messed up with the configurations.
I hope someone here code make things clearer:.
This is my mvc-dispatcher.xml which is the application context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:component-scan base-package="com.yyy.yyy" />
<context:property-placeholder location="classpath:db.properties"/>
<!-- DATA BASE -->
<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="generateDdl" value="true" />
<property name="database" value="SQL_SERVER" />
</bean>
</property>
<property name="persistenceUnitName" value="punit" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClass}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.user}" />
<property name="password" value="${jdbc.pwd}" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<jpa:repositories base-package="com.yyy.yyy.yyy.repository"/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
Now, I also have a persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="punit">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.connection.url" value="${jdbc.url}" />
<property name="hibernate.connection.driver_class" value="${jdbc.driverClass}" />
<property name="hibernate.connection.username" value="${jdbc.user}" />
<property name="hibernate.connection.password" value="${jdbc.pwd}" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
</persistence>
I don't understand where should I put the DB connection data?
And I also cant connect to the DB (I get connection refused) - I am getting exception at server startup.
My project runs on Tomcat and I used https://github.com/SpringSource/spring-data-jpa-examples as a template.
EDIT
I managed to overcome the problems and publish to tomcat successfully,by removing the persistence XML file and use only the spring context file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="yyy.yyy.yyy" />
<context:property-placeholder location="classpath:db.properties" />
<!-- DATA BASE -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="yyy.yyy.yyy.yyy.domain" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="false" />
<property name="showSql" value="true" />
<property name="database" value="SQL_SERVER" />
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
</bean>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<property name="url" value="jdbc:jtds:sqlserver://localhost;databaseName=db" />
<property name="username" value="yyy" />
<property name="password" value="yyyyy" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<jpa:repositories base-package="yyy.yyy.yyy.yyy.repository" />
<!-- MVC -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
The app now loads fine, but when I use my repository and call save, I get connection refused exception.
Anyone knows why?
Help please.
Idob
You are refering to db.properites file here:<context:property-placeholder location="classpath:db.properties"/>
Where is it located in the project?