Magnolia to SQL Server 2014 connection

613 views Asked by At

I am new to Magnolia world and trying to store JCR on database instead of local file system.

I am using Magnolia 5.4, SQLJDB42.jar and SQL server 2014 server for the same. I have followed all the instruction present at https://wiki.magnolia-cms.com/display/WIKI/Database-Only+Repositories+with+JNDI+Datasources and it's working with MySQL server but when I tried the same with SQL server 2014 it's giving me the follwoing error:

INFO info.magnolia.cms.beans.config.ConfigLoader 26.12.2016 17:28:29 -- Initializing content repositories INFO info.magnolia.repository.DefaultRepositoryManager 26.12.2016 17:28:29 -- Loading JCR INFO info.magnolia.repository.DefaultRepositoryManager 26.12.2016 17:28:29 -- Loading JCR magnolia INFO info.magnolia.jackrabbit.ProviderImpl 26.12.2016 17:28:29 -- Loading repository at C:\Users\665564\MagnoliaRepositories\author\repositories\magnolia (config file: C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\WEB-INF\config\repo-conf\jackrabbit-bundle-mssql-search-pm.xml) - cluster id: "<unset>" DEBUG info.magnolia.jackrabbit.ProviderImpl 26.12.2016 17:28:29 -- No JNDI bound Repository found with name magnoliaAuthor, trying to initialize a new Repository ERROR org.apache.jackrabbit.core.util.db.ConnectionHelper 26.12.2016 17:28:31 -- Failed to execute SQL (stacktrace on DEBUG log level): com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '$'

Then ,I have done the hard coding of all the path variables (like ${wsp.home}) and now I am getting the below mentioned error:

INFO info.magnolia.init.MagnoliaServletContextListener 27.12.2016 13:50:06 -- Property sources loaded [DefaultMagnoliaConfigurationProperties with sources: [SystemPropertySource][ServletContextPropertySource from WEB-INF/config/magnoliaAuthor/magnolia.properties [ServletContextPropertySource from WEB-INF/config/magnoliaAuthor/magnolia.properties [ServletContextPropertySource from WEB-INF/config/default/magnolia.properties][ModulePropertiesSource from modules [core, dam, freemarker-support, lang-el, activation, categorization-support, ce-product-descriptor, imaging-support, resource-loader, rest-client, rest-integration, cache, config, i18n, rest-services, dam-jcr, ehcache, rendering, ui-framework, appswitcher, imaging, resteasy-client, scheduler, templating, ui-mediaeditor, resources, task-management, templating-jsp, ui-admincentral, about-app, cache-app, groovy, inplace-templating, log-tools, mail, messages-app, pages, resources-app, sample-app, security-app, site, ui-contentapp, cache-browser-app, contacts, dam-app, dam-imaging, dam-templating, definitions-app, form, google-sitemap, jcr-browser-app, jcr-tools, mte-imaging, site-app, mte, public-user-registration, forum, mtk, rssaggregator, categorization, commenting, lang-da, lang-ar, lang-cs, lang-de, lang-es, lang-fi, lang-fr, lang-he, lang-hr, lang-hu, lang-id, lang-it, lang-ja, lang-nl, lang-no, lang-pl, lang-pt, lang-pt_BR, lang-ru, lang-sk, lang-sq, lang-sv, lang-tr, lang-zh_CN, lang-zh_TW, travel-demo, tours, lang-ko, webapp]][InitPathsPropertySource]] INFO info.magnolia.cms.beans.config.ConfigLoader 27.12.2016 13:50:06 -- Initializing content repositories INFO info.magnolia.repository.DefaultRepositoryManager 27.12.2016 13:50:06 -- Loading JCR INFO info.magnolia.repository.DefaultRepositoryManager 27.12.2016 13:50:06 -- Loading JCR magnolia INFO info.magnolia.jackrabbit.ProviderImpl 27.12.2016 13:50:06 -- Loading repository at C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\repositories\magnolia (config file: C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\WEB-INF\config\repo-conf\jackrabbit-bundle-mssql-search.xml) - cluster id: "<unset>" WARN org.apache.jackrabbit.core.config.ConfigurationErrorHandler 27.12.2016 13:50:06 -- Warning parsing the configuration at line 4 using system id file:/C:/Users/665564/magnolia-5.5/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/config/repo-conf/jackrabbit-bundle-mssql-search.xml: org.xml.sax.SAXParseException; systemId: file:/C:/Users/665564/magnolia-5.5/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/config/repo-conf/jackrabbit-bundle-mssql-search.xml; lineNumber: 4; columnNumber: 32; Attribute "name" must be declared for element type "DataSources". WARN org.apache.jackrabbit.core.config.ConfigurationErrorHandler 27.12.2016 13:50:06 -- Warning parsing the configuration at line 11 using system id file:/C:/Users/665564/magnolia-5.5/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/config/repo-conf/jackrabbit-bundle-mssql-search.xml: org.xml.sax.SAXParseException; systemId: file:/C:/Users/665564/magnolia-5.5/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/config/repo-conf/jackrabbit-bundle-mssql-search.xml; lineNumber: 11; columnNumber: 17; The content of element type "DataSources" must match "(DataSource)*". ERROR info.magnolia.jackrabbit.ProviderImpl 27.12.2016 13:50:07 -- Unable to initialize repository: Unable to create or lock file C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\repositories\magnolia\.lock javax.jcr.RepositoryException: **Unable to create or lock file C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\repositories\magnolia\.lock** at org.apache.jackrabbit.core.util.RepositoryLock.tryLock(RepositoryLock.java:155) at org.apache.jackrabbit.core.util.RepositoryLock.acquire(RepositoryLock.java:138).

PFB, details of my repository.xml file, it's a default file I haven't change anything in that:

 <!-- magnolia default repository -->
 <Repository name="magnolia" provider="info.magnolia.jackrabbit.ProviderImpl" loadOnStartup="true">
     <param name="configFile" value="${magnolia.repositories.jackrabbit.config}" />
     <param name="repositoryHome" value="${magnolia.repositories.home}/magnolia" />
     <!-- the default node types are loaded automatically
     <param name="customNodeTypes" value="WEB-INF/config/repo-conf/nodetypes/magnolia_nodetypes.xml" /> -->
     <param name="contextFactoryClass" value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" />
     <param name="providerURL" value="localhost" />
     <param name="bindName" value="${magnolia.webapp}" />
     <workspace name="website" />
     <workspace name="config" />
     <workspace name="users" />
     <workspace name="userroles" />
     <workspace name="usergroups" />
 </Repository> </JCR>

When I tried with the bindName="magnoliaAuthor" and absolute path for configFile & magnolia.repositories.home, it's giving me the below mentioned error:

INFO info.magnolia.cms.beans.config.ConfigLoader 28.12.2016 16:30:40 -- Initializing content repositories INFO info.magnolia.repository.DefaultRepositoryManager 28.12.2016 16:30:40 -- Loading JCR INFO info.magnolia.repository.DefaultRepositoryManager 28.12.2016 16:30:40 -- Loading JCR magnolia INFO info.magnolia.jackrabbit.ProviderImpl 28.12.2016 16:30:40 -- Loading repository at C:\Users\665564\magnolia-5.5\apache-tomcat-8.5.5\webapps\magnoliaAuthor\repositories\magnolia (config file: C:/Users/665564/magnolia-5.5/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/config/repo-conf/jackrabbit-bundle-mssql-search.xml) - cluster id: "<unset>" DEBUG info.magnolia.jackrabbit.ProviderImpl 28.12.2016 16:30:40 -- No JNDI bound Repository found with name magnoliaAuthor, trying to initialize a new Repository ERROR org.apache.jackrabbit.core.util.db.ConnectionHelper 28.12.2016 16:30:42 -- Failed to execute SQL (stacktrace on DEBUG log level): com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '$'. ERROR org.apache.jackrabbit.core.util.db.ConnectionHelper 28.12.2016 16:30:42 -- Failed to execute SQL (stacktrace on DEBUG log level): com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '$'. ERROR org.apache.jackrabbit.core.fs.db.DatabaseFileSystem 28.12.2016 16:30:42 -- failed to initialize file system com.microsoft.sqlserver.jdbc.SQLServerException: **Incorrect syntax near '$**'.

Please advice.

Thanks in advance.

1

There are 1 answers

1
Jan On

Multiple things wrong here.

First, you get

No JNDI bound Repository found with name magnoliaAuthor

so your JNDI connection can't be found. Where did you configure it? In the tomcat config file? Check this first to make sure you have it configured and named it correctly. My guess would be that you have made error either in configuring jndi or when referring to it from jackrabbit-bundle-mssql-search

Second, after removing all the variables, the error you get is

jackrabbit-bundle-mssql-search.xml; lineNumber: 4; columnNumber: 32; Attribute "name" must be declared for element type "DataSources".

so what happened is that while editing, by mistake, you have removed too much or inserted wrong character in the xml file at line 4 and file has now invalid syntax.

Another thing I've noticed is that the log files refer to two different files - jackrabbit-bundle-mssql-search-pm.xml and jackrabbit-bundle-mssql-search.xml. Unless you have done that intentionally, perhaps that is yet another mistake? Either way, content of this file is most likely crucial if the above two hints don't help in solving your issue.