Search code examples
javaspringazure-sql-databasejtdsmssql-jdbc

How to fix a MZNG repository migration to MS SQL?


I'm trying to change the MashZone NG (v. 10.1) Repository from Derby DB to MSSQL in Azure. The database is up and running, the SQL scripts were executed and commited. My driver is JTDS 1.3.1 (it's recommended) and my configuration is as follows:

/opt/softwareag/MashZoneNG/apache-tomcat/conf/context.xml

<Resource name="MashzoneNextGenRepository"       auth="Container"        
type="javax.sql.DataSource"     maxTotal="200"      maxIdle="30"        
maxWaitMillis="10000"       username="USER"                
password="PASSWORD"                
driverClassName="net.sourceforge.jtds.jdbc.Driver"        
url="jdbc:jtds:sqlserver://SERVER.database.windows.net:1433/DATABASENAME"       
JtaManaged = "false"/></Context>  

/opt/softwareag/MashZoneNG/apache-tomcat/webapps/mashzone/WEB-INF/classes/rdJDBC.properties

#MSSQL  
jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver  
jdbc.url=jdbc:sqlserver://SERVER.database.windows.net:1433/DATABASENAME  
jdbc.username=USER  
jdbc.password=PASSWORD  
jdbc.schema.name=dbo  
jdbc.identifierCase=UpperCase  
pool.validationQuery=select 1  

Despite the fact, I set the configuration according to the documentation, an error is occured (see below). I expected that the driver is a problem, but yesterday I create a simple java program which can access the database. Firewall is also not a reason of this failure. The error might be coming from Spring jars which are provided with the installation by default.

Could you give me a piece of advice how to cope with this?

2018-07-26 06:13:43,225 INFO [com.jackbe.jbp.sas.rds.impl.jdo.PersistenceManagerFactoryBean] - Closing JDO PersistenceManagerFactory  
2018-07-26 06:13:43,259 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'defaultAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultAuthenticationProvider' defined in ServletContext resource [/WEB-INF/classes/userRepositoryApplicationContext-jdbc.xml]: Cannot resolve reference to bean 'userRepositoryAccessAdapter' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepositoryAccessAdapter' defined in ServletContext resource [/WEB-INF/classes/userRepositoryApplicationContext-jdbc.xml]: Cannot create inner bean 'com.jackbe.jbp.sas.security.usermgt.impl.DefaultUserRepository#6427e8b1' of type [com.jackbe.jbp.sas.security.usermgt.impl.DefaultUserRepository] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jackbe.jbp.sas.security.usermgt.impl.DefaultUserRepository#6427e8b1' defined in ServletContext resource [/WEB-INF/classes/userRepositoryApplicationContext-jdbc.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:  
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'userAttributeProvider' threw exception; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JDO PersistenceManager for transaction; nested exception is java.lang.AbstractMethodError  
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)  
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)  
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)  
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)  
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)  
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)  
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)  
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)  
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)  
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)  
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)  
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)  
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)  
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)  
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)  
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)  
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)  
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)  
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)  
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)  
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1842)  
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)  
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)  
    at java.lang.Thread.run(Thread.java:748)  

Thanks in advance


Solution

  • 2 changes were needed to make it work:

    in the context.xml added (thanks to Yogesh): validationQuery="select 1"

    in the jdbc url added: ";ssl=require"