Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity object is invalid #885

Closed
ansarrafique opened this issue Sep 21, 2016 · 5 comments
Closed

Entity object is invalid #885

ansarrafique opened this issue Sep 21, 2016 · 5 comments

Comments

@ansarrafique
Copy link

I have two different modules in my project. Module 1 contains client side code (Servlet) and the module 2 contains the business logic and uses Kundera platform. I want my module 2 to be application independent so I can use module 2 to persist data of any application (module 1) without making changes in module 2.

Therefore, all the entities are defined in module 1 and Kundera code (persistence.xml) is defined in module 2. I am using module 2 jars in module 1 to call methods of module 2 e.g., Persist. When I call Persist method of Kundera, I am getting an exception

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:180)
at com.leuven.distrinet.persist.data.access.service.DataAccessService.store(DataAccessService.java:59)
at com.leuven.distrinet.persist.data.management.services.DataManagementService.persist(DataManagementService.java:53)
at com.leuven.distrinet.lmaas.controller.LogDataStorage.doGet(LogDataStorage.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

I know that Kundera (in module 2) couldn't find the entities as they are defined in module 1. I don't want to move all entities to module 2 as it doesn't make sense + I want module 2 to be applicaiton independent. How can I solve this problem so that my module 2 is independent of module 1?

@karthikprasad13
Copy link
Collaborator

@ansarrafique

Please share your entity and persistence.xml

-Karthik

@ansarrafique
Copy link
Author

<persistence-unit name="Cassandra">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
    <properties>
        <property name="kundera.nodes" value="localhost" />
        <property name="kundera.port" value="9160" />
        <property name="kundera.keyspace" value="test" />
        <property name="kundera.dialect" value="cassandra" />
        <property name="kundera.client.lookup.class"
            value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
        <property name="kundera.pool.size.max.active" value="50" />
        <property name="kundera.pool.size.max.total" value="50" />
        <property name="kundera.ddl.auto.prepare" value="update" />
    </properties>

</persistence-unit>

@karthikprasad13
Copy link
Collaborator

@ansarrafique

If module with entities is in the classpath of module 2, Kundera should be able to pick the classes. Try adding classes to the persistence.xml as follows (under provider tag):

    <class>mypackage1.Entity1</class>
    <class>mypackage2.Entity2</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>     

-Karthik

@karthikprasad13
Copy link
Collaborator

@ansarrafique

Lets discuss more on Gitter?

-Karthik

@ansarrafique
Copy link
Author

@karthikprasad13

Thank you for your response.

Adding classes to the persistence.xml file won't help unfortunately. I want to avoid adding classes manually to the pesistence.xml file. This seems feasible for few classes, but if the number of classes increases then all needs to be defined in the persistence.xml file.

The other solution is to define the jar file in the persistence.xml file. It works fine, but as said earlier, I want my module 2 to be independent of the module 1 so ideally I don't want to make any changes in the module 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants