# MongoDB Caused by: javax.naming.NameNotFoundException: PlaceHolderDSForOGM

**URL:** <https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215>\
**Category:** Hibernate OGM\
**Created:** [August 12, 2018, 9:21am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215 "2018-08-12T09:21:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![czetsuya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/czetsuya/32/245_2.png) [@czetsuya](https://discourse.hibernate.org/u/czetsuya)\
**Post date:** [August 12, 2018, 9:21am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/1 "2018-08-12T09:21:12Z")

</div>

Hi,

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 [https://docs.jboss.org/hibernate/ogm/5.4/reference/en-US/html\_single/#mongodb-built-in-types](https://docs.jboss.org/hibernate/ogm/5.4/reference/en-US/html_single/#mongodb-built-in-types). But when I run the Arquillian test in Wildfly13 I got:

```
Caused by: javax.naming.NameNotFoundException: ---PlaceHolderDSForOGM--- -- service jboss.naming.context.java.---PlaceHolderDSForOGM---
	at org.jboss.as.naming@13.0.0.Final//org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
	at org.jboss.as.naming@13.0.0.Final//org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
	at org.jboss.as.naming@13.0.0.Final//org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:237)
	at org.jboss.as.naming@13.0.0.Final//org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
	at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:413)
	at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:413)
	at org.hibernate.orm:5.3.2.Final@5.3.2.Final//org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:97)
	... 30 more

```

Here are the most important files:

**persistence.xml**

```
<persistence version="2.1"
	xmlns="http://xmlns.jcp.org/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
		http://xmlns.jcp.org/xml/ns/persistence
		http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
	<persistence-unit name="primary"
		transaction-type="JTA">
		<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
		<jta-data-source>java:jboss/datasources/hibernate-ogm-mongodb-demoTestDS</jta-data-source>
		
		<properties>
			<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.3" />
			<property name="wildfly.jpa.hibernate.search.module" value="org.hibernate.search.orm:5.10.2.Final" />

			<property name="hibernate.ogm.datastore.provider" value="mongodb" />
			<property name="hibernate.connection.resource" value="java:jboss/mongodb/client"/>
			<property name="hibernate.ogm.datastore.host" 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" />
		</properties>
	</persistence-unit>
</persistence>

```

**Parts of pom.xml:**

```
<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-search-orm</artifactId>
	<scope>provided</scope>
	<exclusions>
		<exclusion>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
		</exclusion>
	</exclusions>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-search-engine</artifactId>
	<scope>provided</scope>
</dependency>

<dependency>
	<groupId>org.hibernate.ogm</groupId>
	<artifactId>hibernate-ogm-core</artifactId>
	<scope>provided</scope>
</dependency>

<dependency>
	<groupId>org.hibernate.ogm</groupId>
	<artifactId>hibernate-ogm-mongodb</artifactId>
	<scope>provided</scope>
</dependency>

<dependency>
	<groupId>org.mongodb</groupId>
	<artifactId>mongo-java-driver</artifactId>
</dependency>

<dependency>
	<groupId>org.hibernate.ogm</groupId>
	<artifactId>hibernate-ogm-core</artifactId>
	<type>test-jar</type>
	<scope>test</scope>
</dependency>

```

**server-provisioning.xml**

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

	<feature-packs>
		<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" />
	</feature-packs>
	
</server-provisioning>

```

**jboss-deployment-structure.xml**

```
<jboss-deployment-structure
	xmlns="urn:jboss:deployment-structure:1.1">
	<deployment>
		<dependencies>
			<module name="org.hibernate.ogm" slot="5.4" services="export" />
			<module name="org.hibernate.ogm.mongodb" slot="5.4" services="export" />
		</dependencies>
	</deployment>
</jboss-deployment-structure>

```

Here’s the complete code: [https://github.com/czetsuya/Hibernate-OGM-MongoDB-Demo](https://github.com/czetsuya/Hibernate-OGM-MongoDB-Demo)

Any idea?

---

<div class="post-metadata">

**Author:** ![p3consulting](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/p3consulting/32/565_2.png) [@p3consulting](https://discourse.hibernate.org/u/p3consulting)\
**Post date:** [August 13, 2018, 5:15am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/2 "2018-08-13T05:15:08Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![czetsuya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/czetsuya/32/245_2.png) [@czetsuya](https://discourse.hibernate.org/u/czetsuya)\
**Post date:** [August 13, 2018, 5:34am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/3 "2018-08-13T05:34:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![p3consulting](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/p3consulting/32/565_2.png) [@p3consulting](https://discourse.hibernate.org/u/p3consulting)\
**Post date:** [August 13, 2018, 9:11am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/4 "2018-08-13T09:11:02Z")

</div>

On [docs.jboss.org](http://docs.jboss.org) page, slot is either “ogm” for module “org.hibernate” or “main” for module “org.hibernate.ogm.\<%DATASTORE%\>”… not a version number.

---

<div class="post-metadata">

**Author:** ![czetsuya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/czetsuya/32/245_2.png) [@czetsuya](https://discourse.hibernate.org/u/czetsuya)\
**Post date:** [August 13, 2018, 9:23am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/5 "2018-08-13T09:23:58Z")

</div>

Check this latest doc: [https://docs.jboss.org/hibernate/ogm/5.4/reference/en-US/html\_single/#\_configuring\_hibernate\_search](https://docs.jboss.org/hibernate/ogm/5.4/reference/en-US/html_single/#_configuring_hibernate_search).

---

<div class="post-metadata">

**Author:** ![p3consulting](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/p3consulting/32/565_2.png) [@p3consulting](https://discourse.hibernate.org/u/p3consulting)\
**Post date:** [August 13, 2018, 10:00am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/6 "2018-08-13T10:00:39Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![czetsuya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/czetsuya/32/245_2.png) [@czetsuya](https://discourse.hibernate.org/u/czetsuya)\
**Post date:** [August 14, 2018, 1:12am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/7 "2018-08-14T01:12:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [August 14, 2018, 1:18am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/8 "2018-08-14T01:18:28Z")

</div>

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

Basically, replacing the deployment in MemberRegistrationTest with something like:

```
@Deployment
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")
		.exportAsString();
	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" );
}

```

Thanks

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 🙂

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [August 14, 2018, 1:23am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/9 "2018-08-14T01:23:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![czetsuya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/czetsuya/32/245_2.png) [@czetsuya](https://discourse.hibernate.org/u/czetsuya)\
**Post date:** [August 14, 2018, 4:49am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/10 "2018-08-14T04:49:08Z")

</div>

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

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.

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [August 14, 2018, 5:16am UTC](https://discourse.hibernate.org/t/mongodb-caused-by-javax-naming-namenotfoundexception-placeholderdsforogm/1215/11 "2018-08-14T05:16:47Z")

</div>

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

As a result, Cassandra has been left behind.

Cheers
