I am new to Java and Apache Sling as well. I've been trying to link Sling with MongoDB and these are what I've done so far:
NoSQL MongoDB Resource Provider
in Sling console:Oak Document Node Store Service
:java -Dsling.run.modes=oak_mongo -jar org.apache
.sling.launchpad-9.jar -c sling -f -
to run the sling launchpad in mongodb mode. This was the results:As a result, a database named "sling" was created in MongoDB which I could see via Robo-3T (a MongoDB management tool):
After creating some content through my maven application using the below plugin and deploying it on Sling, I was able to see my newly created nodes and resources in the Sling browser (http://localhost:8080/bin/browser.html):
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>3.3.0</version>
<configuration>
<instructions>
<Sling-Nodetypes>
SLING-INF/nodetypes/nodetypes.cnd
</Sling-Nodetypes>
<Sling-Initial-Content>
SLING-INF/scripts;overwrite:=true;uninstall:=true;path:=/apps/test1/nodes,
SLING-INF/content;overwrite:=true;uninstall:=true;path:=/content/test1
</Sling-Initial-Content>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
However, I need to to store everything inside the MongoDB database but currently, nothing stored in the database. How can I achieve this?
The simplest way is to start the Sling Launchpad with the following argument: -Dsling.run.modes=oak-mongo
. This will ensure that the Oak is configured to use Mongo. You must remove the sling
directory, otherwise the run modes will not be changes.
What you've done with your attempts is to: