Eclipselink with MongoDB java.lang.ClassCastException -
i'm trying configure nosql persistence unit using eclipselink , mongodb im getting following stack exception during deployment;
... severe: java.lang.classcastexception: org.eclipse.persistence.nosql.adapters.mongo.mongoplatform cannot cast org.eclipse.persistence.internal.databaseaccess.databaseplatform @ org.eclipse.persistence.sequencing.tablesequence.onconnect(tablesequence.java:168) @ org.eclipse.persistence.sequencing.sequence.onconnect(sequence.java:270) @ org.eclipse.persistence.internal.sequencing.sequencingmanager.onconnectsequences(sequencingmanager.java:927) @ org.eclipse.persistence.internal.sequencing.sequencingmanager.onconnectinternal(sequencingmanager.java:747) @ org.eclipse.persistence.internal.sequencing.sequencingmanager.onconnect(sequencingmanager.java:700) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.initializesequencing(databasesessionimpl.java:281) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.initializedescriptors(databasesessionimpl.java:629) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.initializedescriptors(databasesessionimpl.java:625) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.initializedescriptors(databasesessionimpl.java:565) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.postconnectdatasource(databasesessionimpl.java:792) @ org.eclipse.persistence.internal.sessions.databasesessionimpl.login(databasesessionimpl.java:749) @ org.eclipse.persistence.internal.jpa.entitymanagerfactoryprovider.login(entitymanagerfactoryprovider.java:241) @ org.eclipse.persistence.internal.jpa.entitymanagersetupimpl.deploy(entitymanagersetupimpl.java:681) @ org.eclipse.persistence.internal.jpa.entitymanagerfactorydelegate.getabstractsession(entitymanagerfactorydelegate.java:204) @ org.eclipse.persistence.internal.jpa.entitymanagerfactorydelegate.createentitymanagerimpl(entitymanagerfactorydelegate.java:304) @ org.eclipse.persistence.internal.jpa.entitymanagerfactoryimpl.createentitymanagerimpl(entitymanagerfactoryimpl.java:336) @ org.eclipse.persistence.internal.jpa.entitymanagerfactoryimpl.createentitymanager(entitymanagerfactoryimpl.java:302) @ org.glassfish.persistence.jpa.jpadeployer$2.visitpud(jpadeployer.java:451) @ org.glassfish.persistence.jpa.jpadeployer$persistenceunitdescriptoriterator.iteratepuds(jpadeployer.java:510) @ org.glassfish.persistence.jpa.jpadeployer.iterateinitializedpusatapplicationprepare(jpadeployer.java:492) @ org.glassfish.persistence.jpa.jpadeployer.event(jpadeployer.java:395) @ org.glassfish.kernel.event.eventsimpl.send(eventsimpl.java:131) @ com.sun.enterprise.v3.server.applicationlifecycle.deploy(applicationlifecycle.java:484) @ com.sun.enterprise.v3.server.applicationlifecycle.deploy(applicationlifecycle.java:219) @ org.glassfish.deployment.admin.deploycommand.execute(deploycommand.java:491) @ com.sun.enterprise.v3.admin.commandrunnerimpl$2$1.run(commandrunnerimpl.java:527) @ com.sun.enterprise.v3.admin.commandrunnerimpl$2$1.run(commandrunnerimpl.java:523) @ java.security.accesscontroller.doprivileged(native method) @ javax.security.auth.subject.doas(subject.java:356) @ com.sun.enterprise.v3.admin.commandrunnerimpl$2.execute(commandrunnerimpl.java:522) @ com.sun.enterprise.v3.admin.commandrunnerimpl.docommand(commandrunnerimpl.java:546) @ com.sun.enterprise.v3.admin.commandrunnerimpl.docommand(commandrunnerimpl.java:1423) @ com.sun.enterprise.v3.admin.commandrunnerimpl.access$1500(commandrunnerimpl.java:108) @ com.sun.enterprise.v3.admin.commandrunnerimpl$executioncontext.execute(commandrunnerimpl.java:1762) @ com.sun.enterprise.v3.admin.commandrunnerimpl$executioncontext.execute(commandrunnerimpl.java:1674) @ com.sun.enterprise.v3.admin.adminadapter.docommand(adminadapter.java:534) @ com.sun.enterprise.v3.admin.adminadapter.onmissingresource(adminadapter.java:224) @ org.glassfish.grizzly.http.server.statichttphandler.service(statichttphandler.java:297) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:246) @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:191) @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:168) @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:189) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:288) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:206) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:136) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:114) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:838) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:113) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:115) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:55) @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:135) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:564) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:544) @ java.lang.thread.run(thread.java:722)
the connection seems established java.lang.classcastexception , connection gets closed.
my pu in persistence.xml looks this:
<persistence-unit name="nosql_pu" transaction-type="jta"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.mongoplatform"/> <property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.mongoconnectionspec"/> <property name="eclipselink.nosql.property.mongo.port" value="27017"/> <property name="eclipselink.nosql.property.mongo.host" value="localhost"/> <property name="eclipselink.nosql.property.mongo.db" value="dev"/> <property name="eclipselink.logging.level" value="finest"/> </properties> </persistence-unit>
my nosql entity class;
@namedqueries({ @namedquery(name = "comment.findall", query = "select e comment e"), @namedquery(name = "comment.findbypk", query = "select e comment e e.id = :id"),}) @entity @nosql(dataformat = dataformattype.mapped) public class comment implements serializable { // serial------------------------------------------------------------------- private static final long serialversionuid = 1l; // variables---------------------------------------------------------------- @id @generatedvalue @field(name="_id") private string id; @basic private long created; @basic private string commenterid; @basic private string comment; // constructors------------------------------------------------------------- // getters------------------------------------------------------------------ // setters------------------------------------------------------------------ }
im using ctm im calling pu in stateless session bean;
@stateless public class ticketdaoimpl implements ticketdao { @persistencecontext(unitname = "nosql_pu") private entitymanager em; }
ive been following eclipselink guide can't find pertaining this.
the problem persistence unit. default entity classes included, both nosql , sql entities being passed both sql , nosql persistence units. solution specify entities inside persistence.xml persistence unit.
<persistence-unit name="dastrax_nosql_pu" transaction-type="jta"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <class>declare_your_entity_1</class> <class>declare_your_entity_2</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.mongoplatform"/> <property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.mongoconnectionspec"/> <property name="eclipselink.nosql.property.mongo.port" value="27017"/> <property name="eclipselink.nosql.property.mongo.host" value="localhost"/> <property name="eclipselink.nosql.property.mongo.db" value="dev"/> <property name="eclipselink.logging.level" value="finest"/> </properties> </persistence-unit>
Comments
Post a Comment