11 Replies Latest reply on Aug 6, 2007 1:41 PM by Matthew Lieder

    Marking Hibernate POJO's as entities without annotations?

    Matthew Lieder Apprentice

      Is it possible to tell Seam (2.0) that certain Hibernate-generated POJO classes are Entity beans without having to put @Entity annotations on every one? I tried putting an orm.xml in META-INF, but it doesn't seem to be read. I'm not using JTA or EJB3.

        • 1. Re: Marking Hibernate POJO's as entities without annotations
          Pete Muir Master

          Put orm.xml in your ejb-jar/META-INF - it does work.

          • 2. Re: Marking Hibernate POJO's as entities without annotations
            Matthew Lieder Apprentice

            "ebj-jar"? I'm not using EJB3 though...

            • 3. Re: Marking Hibernate POJO's as entities without annotations
              Matthew Lieder Apprentice

              Using the hibernate2 example, if all I did was remove the "@Entity" annotation from Hotel.java and then added an appropriate orm.xml to the META-INF folder and deployed it to Tomcat, it should work?

              • 4. Re: Marking Hibernate POJO's as entities without annotations
                Pete Muir Master

                I just tested this with the JPA example (adding an orm.xml to META-INF, alongside persistence.xml) and it works. Ok, ejb-jar was the wrong phrase - I kinda meant the jar you put your model classes in, which in a jee app would be your ejb jar...

                • 6. Re: Marking Hibernate POJO's as entities without annotations
                  Pete Muir Master

                  Hibernate Annotations/Hibernate Entity Manager is an implementation of JPA, so if you are/want to use @Entity and EntityManager then you are using JPA. Of course you can use plain Hibernate (Hibernate Session and .hbm.xml files) but then orm.xml doesn't come into the picture (it's the standardised version of .hbm.xml basically).

                  • 7. Re: Marking Hibernate POJO's as entities without annotations
                    Matthew Lieder Apprentice

                    I'm just using Hibernate and not JPA, and just hbm.xml mapping files and not annotations, but when I try to get data using an injected Session object I get an exception if I don't put the @Entity annotation on my Hibernate POJO's. Is there a way around that?

                    • 9. Re: Marking Hibernate POJO's as entities without annotations
                      Matthew Lieder Apprentice

                       

                      java.lang.IllegalArgumentException: Not an entity class: com.fl.bpm_ui.hibernate.reveng.ProjectEventReason
                      at org.jboss.seam.Entity.forClass(Entity.java:190)
                      at org.jboss.seam.security.Identity.checkEntityPermission(Identity.java:661)
                      at org.jboss.seam.security.HibernateSecurityInterceptor.onLoad(HibernateSecurityInterceptor.java:35)
                      at org.hibernate.event.def.DefaultPreLoadEventListener.onPreLoad(DefaultPreLoadEventListener.java:18)
                      at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
                      at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
                      at org.hibernate.loader.Loader.doQuery(Loader.java:729)
                      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
                      at org.hibernate.loader.Loader.doList(Loader.java:2220)
                      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
                      at org.hibernate.loader.Loader.list(Loader.java:2099)
                      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
                      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
                      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
                      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
                      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
                      at com.fl.bpm_ui.scheduler.CallManager.getPossibleReasons(CallManager.java:65)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                      at java.lang.reflect.Method.invoke(Unknown Source)
                      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:43)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
                      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
                      at com.fl.bpm_ui.scheduler.CallManager_$$_javassist_0.getPossibleReasons(CallManager_$$_javassist_0.java)
                      at com.fl.bpm_ui.scheduler.InitialCall.initCallReasonList(InitialCall.java:49)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                      at java.lang.reflect.Method.invoke(Unknown Source)
                      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
                      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
                      at com.fl.bpm_ui.scheduler.InitialCall_$$_javassist_1.initCallReasonList(InitialCall_$$_javassist_1.java)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                      at java.lang.reflect.Method.invoke(Unknown Source)
                      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                      at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
                      at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
                      at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1809)
                      at org.jboss.seam.Component.getInstance(Component.java:1746)
                      at org.jboss.seam.Component.getInstance(Component.java:1723)
                      at org.jboss.seam.Component.getInstance(Component.java:1717)
                      at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:60)
                      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:135)
                      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                      at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                      at javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
                      at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:95)
                      at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
                      at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
                      at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
                      at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
                      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
                      at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
                      at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                      at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
                      at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
                      at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
                      at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                      at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:94)
                      at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                      at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
                      at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                      at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
                      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                      at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
                      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
                      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                      at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
                      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
                      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
                      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
                      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
                      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
                      at java.lang.Thread.run(Unknown Source)


                      • 10. Re: Marking Hibernate POJO's as entities without annotations
                        Pete Muir Master

                        This is a bug in Seam. Please file an issue in JIRA with that stack trace.