0

We had two servers writing simultaneously into one modeshape JCR (3.8.1.Final). (Which wasn't probably good idea.)

Our modeshape stores PDF documents into SQL database, probably through Infinispan. PDFs are in one level folders. After restart (and shutting down 1 server) I cannot see some folders and also PDFs stored in them.

What would you recommend to retrieve them, some recovery tool? Or some simple tool to do Modeshape Export (without too much Java coding) ?

I have SQL datasource definition from JBOSS standalone.xml so I can connect to SQL Database. I do also have repository configuration file.

Martin

mkuzela
  • 87
  • 1
  • 5

1 Answers1

0

Finally I have used modeshape-jdbc-store-example as code base.

https://github.com/ModeShape/modeshape-examples/tree/master/modeshape-jdbc-store-example

And then modified infinispan-configuration.xml and my-repository-config.json to my configuration.

Also I had to modify pom.xml so that it can be run as standalone cmd application with all libraries included.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>org.modeshape.example.jdbcstore.ModeShapeExample</mainClass>
                        <classpathPrefix>libs/</classpathPrefix>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/libs/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

and I have add some dependencies so that my SQL connection can be stored in JNDI:

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>tomcat</groupId>
        <artifactId>naming-factory</artifactId>
        <version>5.5.15</version>
    </dependency>

    <dependency>
        <groupId>tomcat</groupId>
        <artifactId>naming-resources</artifactId>
        <version>5.5.15</version>
    </dependency>

Code that puts connection into JNDI:

    try {

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
        System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
        InitialContext ic = new InitialContext();

        ic.createSubcontext("java:");
        ic.createSubcontext("java:/jdbc");

        final String PROP_DB_NAME = "java:/jdbc/DataDS";
        final String PROP_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";


        final String PROP_CONNECTION_URL = argv[0];
        final String PROP_USER = argv[1];
        final String PROP_PASWSWORD = argv[2];

        // Construct DataSource
        BasicDataSource dataSource = new BasicDataSource();

        dataSource.setDriverClassName(PROP_DRIVER);
        dataSource.setUsername(PROP_USER);
        dataSource.setPassword(PROP_PASWSWORD);
        dataSource.setUrl(PROP_CONNECTION_URL);
        dataSource.setMaxActive(5);
        dataSource.setMaxIdle(5);
        dataSource.setInitialSize(1);
        dataSource.setValidationQuery("SELECT 1");

        ic.bind(PROP_DB_NAME, dataSource);

        Connection conn = dataSource.getConnection();
    } catch (NamingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
mkuzela
  • 87
  • 1
  • 5