persistence@glassfish.java.net

Re: Entities Jar in my project

From: Roan Brasil Monteiro <roanbrasil_at_gmail.com>
Date: Tue, 20 Oct 2009 10:49:10 -0200

Where can I find this JPA 2.0 spec section 8.2.1.6 . I really didn't
understand, my persistence.xml is in classpath as well in my project.


2009/10/19 Mitesh Meswani <Mitesh.Meswani_at_sun.com>

>
>
> Roan Brasil Monteiro wrote:
>
>> hello everybody,
>>
>> i have a question, I have a maven project with glassfish, jpa/hibernate
>> and jersey and the entities were developed on J2SE project then I needed to
>> generate a jar file from this project and import on my maven project addind
>> a line on pom.xml that worked and persistence.xml that looks not worked.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>> <persistence-unit name="citespacePU" transaction-type="JTA">
>> <provider>org.hibernate.ejb.HibernatePersistence</provider>
>> <jta-data-source>jdbc/TestDS</jta-data-source>
>> *
>> <jar-file>/home/roan/Desktop/MyWorkspaces/workspace2/lib/citespace-persistence.jar</jar-file>*
>> *<!-- my entities are over here -->*
>>
> According to the spec, <jar-file> is specified using URL relative to
> current Persitence Unit Root and it also has to be on the classpath. See
> section 8.2.1.6 of JPA 2.0 spec for more details.
>
> -Mitesh
>
> <properties> <property name="hibernate.hbm2ddl.auto"
>> value="update"/>
>> <property name="hibernate.connection.characterEncoding"
>> value="UTF-8"/> </persistence-unit>
>> </persistence>
>>
>>
>> If I create a entity in my project thats work very well but if I import a
>> jar with entities I am getting the follow erros: Can someone help me, please
>> to resolve it?
>>
>> [#|2009-10-19T17:26:29.728-0200|SEVERE|sun-appserver2.1|javax.enterprise.system.container.web|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-2;_RequestID=761422a8-75a1-4a48-8d70-6722f4306fe6;|StandardWrapperValve[Jersey
>> Web Application]: PWC1406: Servlet.service() for servlet Jersey Web
>> Application threw exception
>> java.lang.IllegalArgumentException:
>> org.hibernate.hql.ast.QuerySyntaxException: Country is not mapped [Select c
>> from Country c ]
>> at
>> org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
>> at
>> org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
>> at com.citespace.citespacerest.Test.getIt(Test.java:50)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:156)
>> at
>> com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
>> at
>> com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:163)
>> at
>> com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
>> at
>> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
>> at
>> com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
>> at
>> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:654)
>> at
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:612)
>> at
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:603)
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:590)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
>> at
>> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
>> at
>> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
>> at
>> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
>> at
>> com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
>> at
>> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
>> at
>> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
>> Caused by: org.hibernate.hql.ast.QuerySyntaxException: Country is not
>> mapped [Select c from Country c ]
>> at
>> org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
>> at
>> org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
>> at
>> org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
>> at
>> org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
>> at
>> org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
>> at
>> org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
>> at
>> org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
>> at
>> org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
>> at
>> org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
>> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
>> at
>> org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
>> at
>> org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
>> at
>> org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
>> at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
>> at
>> org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
>> ... 46 more
>> |#]
>>
>>
>> --
>> Atenciosamente,
>>
>> Roan Brasil Monteiro
>> http://roanbrasil.wordpress.com/
>>
>


-- 
Atenciosamente,
Roan Brasil Monteiro
http://roanbrasil.wordpress.com/