MongoDB Caused by: javax.naming.NameNotFoundException: PlaceHolderDSForOGM


#1

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. 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

Any idea?


#2

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)


#3

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.


#4

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


#5

Check this latest doc: https://docs.jboss.org/hibernate/ogm/5.4/reference/en-US/html_single/#_configuring_hibernate_search.


#6

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 ?


#7

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.


#8

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 :slight_smile:


#9

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.


#10

@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.


#11

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