Unable to setup Kundera for MongoDB

64 views
Skip to first unread message

Ratesh Bansal

unread,
May 2, 2014, 2:56:14 AM5/2/14
to kundera...@googlegroups.com
Hi,

I am trying to set up a simple service to use Kundera with MongoDB. I keep getting NullPointerException for the AppMetaModel.

Attached is a sample code. It looks like Kundera is unable to read my persistence.xml. But I not sure what am I missing in the configuration.

Can you have a look?

Regards,
babybook.rar

Vivek Mishra

unread,
May 2, 2014, 2:59:10 AM5/2/14
to kundera...@googlegroups.com

Possible to share error trace?

 

-Vivek

--
You received this message because you are subscribed to the Google Groups "kundera-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kundera-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.









NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.

Ratesh Bansal

unread,
May 2, 2014, 3:00:02 AM5/2/14
to kundera...@googlegroups.com

Stacktraces

java.lang.NullPointerException
    com.impetus.kundera.configure.SchemaConfiguration.getEntityMetadataCol(SchemaConfiguration.java:438)
    com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:107)
    com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:45)
    com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:352)
    com.impetus.kundera.persistence.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:116)
    com.babybook.signup.service.SignUpService.signup(SignUpService.java:23)
    com.babybook.signup.action.SignUpAction.add(SignUpAction.java:46)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:546)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)

Vivek Mishra

unread,
May 2, 2014, 3:09:10 AM5/2/14
to kundera...@googlegroups.com

Placing META-INF/persistence.xml under domain/src/main/resources should work for you.

Also, List<Child> won’t work within Parent entity, unless  Child entity is an associated entity or embeddable entity.

 

https://github.com/impetus-opensource/Kundera/issues/543

 

https://github.com/impetus-opensource/Kundera/issues/237

Ratesh Bansal

unread,
May 2, 2014, 3:13:33 AM5/2/14
to kundera...@googlegroups.com
No it does not work.....

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
File:com/impetus/kundera/configure/SchemaConfiguration.java
Line number:438

Stacktraces

java.lang.NullPointerException
    com.impetus.kundera.configure.SchemaConfiguration.getEntityMetadataCol(SchemaConfiguration.java:438)
    com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:107)
    com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:45)
    com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:352)
    com.impetus.kundera.persistence.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:116)
    com.babybook.signup.service.SignUpService.signup(SignUpService.java:23)
    com.babybook.signup.action.SignUpAction.add(SignUpAction.java:46)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:45

I have tried keeping it in the service-manager as well. 

It seems Kundera is simply not able to find the persistence.xml


Ratesh Bansal

unread,
May 2, 2014, 3:17:29 AM5/2/14
to kundera...@googlegroups.com
oh I didnt see your comments on the Child Entity, It will be an associated Entity.


--
You received this message because you are subscribed to a topic in the Google Groups "kundera-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kundera-discuss/4TyWKEnoq5c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kundera-discu...@googlegroups.com.

Vivek Mishra

unread,
May 2, 2014, 3:19:12 AM5/2/14
to kundera...@googlegroups.com

2.6 is pretty old version of Kundera. Latest is 2.11.1.

Deploying at my end with latest version.

 

-Vivek

 

From: kundera...@googlegroups.com [mailto:kundera...@googlegroups.com] On Behalf Of Ratesh Bansal


Sent: Friday, May 02, 2014 12:44 PM
To: kundera...@googlegroups.com

--

You received this message because you are subscribed to the Google Groups "kundera-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kundera-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ratesh Bansal

unread,
May 2, 2014, 3:48:37 AM5/2/14
to kundera...@googlegroups.com
I am able to resolve that error, Now I am getting following exception:

com.impetus.kundera.KunderaException: Entitymatadata should not be null
    com.impetus.kundera.persistence.PersistenceDelegator.getMetadata(PersistenceDelegator.java:720)
    com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:139)
    com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168)


--
You received this message because you are subscribed to a topic in the Google Groups "kundera-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kundera-discuss/4TyWKEnoq5c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kundera-discu...@googlegroups.com.

Vivek Mishra

unread,
May 2, 2014, 4:03:04 AM5/2/14
to kundera...@googlegroups.com

Was looking in shared persistence.xml

You need to enable

 

<!-- <properties> <property name="kundera.nodes" value="localhost" /> <property name="kundera.port" value="27017" /> <property name="kundera.keyspace" value="babybook" /> <property name="kundera.dialect" value="mongodb" /> <property name="kundera.client" value="com.impetus.client.MongoDBClient" /> <property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory" /> </properties> -->

 

EntityMetadata null error, possible reasons:

1.       Incorrect entity mapping

2.       Invalid pu provided while creating entity manager factory

 

You may also refer https://github.com/impetus-opensource/Kundera/issues/76

 

Please share CRUD and entity definitions and persistence.xml if it doesn’t work for you.

 

-Vivek

From: kundera...@googlegroups.com [mailto:kundera...@googlegroups.com] On Behalf Of Ratesh Bansal


Sent: Friday, May 02, 2014 1:19 PM
To: kundera...@googlegroups.com

Ratesh Bansal

unread,
May 2, 2014, 5:20:01 AM5/2/14
to kundera...@googlegroups.com
I have tried all your suggestions:

1. Uncomment the properties in persistence.xml
2. Entity mapping is correct
3. Pu is specified correctly

Attached is the new zip file.

Regards
babybook.rar

Chhavi Gangwal

unread,
May 2, 2014, 6:55:15 AM5/2/14
to kundera...@googlegroups.com
Hi,

Had a look at your project , following are the findings :

1. Your entity is missing @Id field. Few basic rules required to run can be found at:https://github.com/impetus-opensource/Kundera/wiki/Concepts
2. with 2.6 you need to annotate with schema@pu3. i suggest to use latest kundera version(as suggested by Vivek Mishra)

For further details check out the example usage at :

https://github.com/impetus-opensource/Kundera/tree/trunk/src/kundera-mongo/src/test/java/com/impetus


Please find the changes required to get it working :

@Entity
@Table(name="PARENT", schema="babybook@babybook")
public class Parent {
   
    @Id
    @GeneratedValue
    private String id;
..........................................................

@Entity
@Table(name="CHILD" , schema="babybook@babybook")
public class Child {
   
    @Id
    @GeneratedValue
    private String id;

.................................................................

//EntityManagerFactory factory = new KunderaPersistence().createEntityManagerFactory("babybook", map);
  EntityManagerFactory factory = Persistence.createEntityManagerFactory("babybook", map);

...............................................................................

    <properties>
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="27017" />
            <property name="kundera.keyspace" value="babybook" />
            <property name="kundera.dialect" value="mongodb" />
<!--             <property name="kundera.client" value="com.impetus.client.MongoDBClient" /> -->

            <property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory" />
       </properties>


Chhavi

Vivek Mishra

unread,
May 2, 2014, 6:59:27 AM5/2/14
to kundera...@googlegroups.com

Just to add on point 2.  As suggested earlier to use latest Kundera version, no need to define

@Table(name="PARENT", schema="babybook@babybook")

 

Is optional. Which was mandatory prior to 2.9 releases.

 

HTH,

-Vivek

 

From: kundera...@googlegroups.com [mailto:kundera...@googlegroups.com] On Behalf Of Chhavi Gangwal
Sent: Friday, May 02, 2014 4:25 PM
To: kundera...@googlegroups.com
Subject: {kundera-discuss} Re: Unable to setup Kundera for MongoDB

 

Hi,

--

You received this message because you are subscribed to the Google Groups "kundera-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kundera-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ratesh Bansal

unread,
May 2, 2014, 7:56:58 AM5/2/14
to kundera...@googlegroups.com
A big thanks


--
You received this message because you are subscribed to a topic in the Google Groups "kundera-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kundera-discuss/4TyWKEnoq5c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kundera-discu...@googlegroups.com.

Ratesh Bansal

unread,
May 5, 2014, 2:57:26 AM5/5/14
to kundera...@googlegroups.com
Can somebody explain this error:

Exception in thread "main" com.impetus.kundera.KunderaException: java.lang.IllegalArgumentException: Entity object is invalid, operation failed. Please check previous log message for details
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:174)
at com.babybook.signup.service.EventService.persist(EventService.java:9)
at com.babybook.signup.service.EventService.main(EventService.java:21)
Caused by: java.lang.IllegalArgumentException: Entity object is invalid, operation failed. Please check previous log message for details
at com.impetus.kundera.graph.ObjectGraphBuilder.getNode(ObjectGraphBuilder.java:101)
at com.impetus.kundera.graph.ObjectGraphBuilder.getObjectGraph(ObjectGraphBuilder.java:75)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:135)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168)
... 2 more

Attached is the entity graph.


Comment.java
Event.java
Like.java

Vivek Mishra

unread,
May 5, 2014, 3:35:25 AM5/5/14
to kundera...@googlegroups.com

Version of Kundera?

 

-Vivek

 

From: kundera...@googlegroups.com [mailto:kundera...@googlegroups.com] On Behalf Of Ratesh Bansal


Sent: Monday, May 05, 2014 12:27 PM
To: kundera...@googlegroups.com

Ratesh Bansal

unread,
May 5, 2014, 3:45:20 AM5/5/14
to kundera...@googlegroups.com
I got passed this, I think the error message could be improved. i was missing the entry in persistence.xml
Reply all
Reply to author
Forward
0 new messages