MongoDB Caused by: javax.naming.NameNotFoundException: PlaceHolderDSForOGM


I’m currently experimenting mongo datastore using hibernate-ogm v 5.4.0.Beta2. I created a project from javaee7 maven archetype and followed the configuration procedures in But when I run the Arquillian test in Wildfly13 I got:

Caused by: javax.naming.NameNotFoundException: ---PlaceHolderDSForOGM--- -- service
	at java.naming/javax.naming.InitialContext.lookup(
	at java.naming/javax.naming.InitialContext.lookup(
	at org.hibernate.orm:5.3.2.Final@5.3.2.Final//org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(
	... 30 more

Here are the most important files:


<persistence version="2.1"
	<persistence-unit name="primary"
			<property name="" value="org.hibernate:5.3" />
			<property name="" value="" />

			<property name="hibernate.ogm.datastore.provider" value="mongodb" />
			<property name="hibernate.connection.resource" value="java:jboss/mongodb/client"/>
			<property name="" value="localhost" />
			<property name="hibernate.ogm.mongodb.authentication_mechanism" value="BEST" />
			<property name="hibernate.ogm.datastore.database" value="mydb" />
			<property name="hibernate.ogm.mongodb.authentication_database" value="admin" />
			<property name="hibernate.ogm.datastore.username" value="admin" />
			<property name="hibernate.ogm.datastore.password" value="admin" />
			<property name="hibernate.ogm.datastore.create_database" value="true" />
			<property name="hibernate.ogm.mongodb.write_concern" value="JOURNALED" />
			<property name="hibernate.ogm.mongodb.read_preference" value="NEAREST" />

Parts of pom.xml:








<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">

		<feature-pack groupId="org.hibernate" artifactId="hibernate-orm-jbossmodules" version="5.3.2.Final" />
		<feature-pack groupId="org.hibernate" artifactId="hibernate-search-jbossmodules-engine" version="5.10.2.Final" />
		<feature-pack groupId="org.hibernate" artifactId="hibernate-search-jbossmodules-orm" version="5.10.2.Final" />
		<feature-pack groupId="org.hibernate.ogm" artifactId="hibernate-ogm-featurepack-core" version="5.4.0.Beta2" />
		<feature-pack groupId="org.hibernate.ogm" artifactId="hibernate-ogm-featurepack-mongodb" version="5.4.0.Beta2" />
		<feature-pack groupId="org.wildfly" artifactId="wildfly-feature-pack" version="13.0.0.Final" />


			<module name="org.hibernate.ogm" slot="5.4" services="export" />
			<module name="org.hibernate.ogm.mongodb" slot="5.4" services="export" />

Here’s the complete code:

Any idea?

in jboss-deployment-structure.xml, does the slot matters?
Because yours are not the ones of the example… (ogm and main resp. instead of 5.4)

Yes it matters. Since there is at least the packaged version of the same library in Wildfly (old), I need to make sure that I’m using the correct version. Moreover, this deployment structure is specified in OGM 5.4.0.Beta2 docs.

On page, slot is either “ogm” for module “org.hibernate” or “main” for module “org.hibernate.ogm.<%DATASTORE%>”… not a version number.

Check this latest doc:

Yes but it doesn’t work and in previous version of the docs the slot names were not the same, so may be the latest doc is buggy…
Have you tried ?

Unfortunately updating jboss-deployment-structure like that didn’t solve the issue. I guess something is broken along the dependency hierarchy. Might just have to wait for the release before trying again. On another note, hibernate search is working well on my test, while Cassandra is failing.

If someone from hibernate is reading, hopefully you could create simple projects just like what I’m doing to help us developers from setting up.

Hi, can you try using the MANIFEST.MF instead of the jboss-deployment.xml?

Basically, replacing the deployment in MemberRegistrationTest with something like:

public static Archive<?> createTestArchive() {
	String manifest = Descriptors.create( ManifestDescriptor.class )
		.attribute( "Dependencies", "org.hibernate.ogm:5.4 services, org.hibernate.ogm.mongodb:5.4 services")
	return ShrinkWrap.create( WebArchive.class, "test.war" )
                            .addClasses( Member.class, MemberRegistration.class, Resources.class )
                            .addAsResource( new StringAsset( manifest ), "META-INF/MANIFEST.MF" ) 
                            .addAsResource( "META-INF/test-persistence.xml", "META-INF/persistence.xml" )				 
                            .addAsResource( "jboss-deployment-structure.xml", "WEB-INF/jboss-deployment-structure.xml" )
                            .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" );


By the way, when using Arquillian is better to call the test classes with the -IT suffix (instead of -Test) and use the failsafe plugin.
I know we don’t do that in OGM but it’s a long story :slight_smile:

Also, in the persistence.xml, if you want to use OGM, you should remove the jta-data-source definition and the hibernate.connection.resource. They won’t be used because these are ORM properties.

@DavideD I’ve cleaned up the persistence.xml file and use the manifest rather than the jboss deployment structure. It worked after that :slight_smile:

Thanks for the help. Will update the project to use the failsafe plugin.

PS: What’s up with Cassandra? It seems it’s lagging behind in development.

at the moment we don’t have enough people to work on all the dialects.

As a result, Cassandra has been left behind.