[jboss-user] [JBoss Seam] - NamedQuery not known in Component

mirko27 do-not-reply at jboss.com
Thu Nov 29 22:41:19 EST 2007


We are trying to implement resourcebundle in database.
Everything works fine, but it seems that our entitymanager is not able to
resolve any namedqueries in resourceLoader.
Is it some kind of instancing issue with SMPC entitymanager? Or something else?

components.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <components xmlns="http://jboss.com/products/seam/components"
  |             xmlns:core="http://jboss.com/products/seam/core"
  |             xmlns:persistence="http://jboss.com/products/seam/persistence"
  |             xmlns:security="http://jboss.com/products/seam/security"
  |             xmlns:transaction="http://jboss.com/products/seam/transaction"
  |             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |             xsi:schemaLocation=
  |             "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
  |             http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
  |             http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
  |             http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
  | http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
  |     
  |     <core:init jndi-pattern="java:comp/env/soov/#{ejbName}/local" debug="true"/>    
  |     <persistence:entity-manager-factory name="entityManagerFactory" persistence-unit-name="soovPU"/>
  |     <persistence:managed-persistence-context name="em" auto-create="true" 
  |                                              entity-manager-factory="#{entityManagerFactory}"/>
  |     <transaction:ejb-transaction/>
  |     
  |     <core:manager conversation-timeout="120000" 
  |                   concurrent-request-timeout="500"
  |                   conversation-id-parameter="cid"/>
  |     
  |     <security:identity authenticate-method="#{authenticator.authenticate}"/> 
  | 
  | </components>
  | 
Messages.java (Entity)


  | @Entity
  | @Table(name = "MESSAGES")
  | @NamedQueries({
  | @NamedQuery(name = "keys", query = "select m.messagekey from Messages m where " +
  | "m.channel = :channel and " +
  | "m.locale = :locale"),
  | @NamedQuery(name="lamp",query="select m from Messages m"),
  | @NamedQuery(name = "value", query = "select m.message from Messages m where " +
  | "m.channel = :channel and " +
  | "m.locale = :locale and m.messagekey = :messagekey")
  | })
  | public class Messages implements Serializable {
  | ...
  | }
  | 
And resourceloader:

  | @Name("org.jboss.seam.core.resourceLoader")
  | @BypassInterceptors
  | public class MessageResourceLoader extends ResourceLoader {
  |    
  |     @Override
  |    public ResourceBundle loadBundle(final String bundleName) {
  |       return new ResourceBundle() {
  | 
  |          public Enumeration<String> getKeys() {
  |             Locale locale = org.jboss.seam.core.Locale.instance();
  |             EntityManager entityManager = (EntityManager) Component.getInstance("em");
  |             List resources = entityManager.createNamedQuery("keys")
  |                .setParameter("channel", "soov")
  |                .setParameter("locale", locale.toString())   
  |                .getResultList();
  |             return Collections.enumeration(resources);
  |          }
  | 
  |          protected Object handleGetObject(String key) {
  |             Locale locale = org.jboss.seam.core.Locale.instance();
  |             EntityManager entityManager = (EntityManager) Component.getInstance("em");
  |             entityManager.createNamedQuery("lamp");
  |             try {
  |               /* return entityManager.createNamedQuery("value")
  |                   .setParameter("channel", "soov")
  |                   .setParameter("locale", locale.toString())
  |                   .setParameter("messagekey", key)
  |                   .getSingleResult();*/
  |                 return null;
  |             } catch (NoResultException e) {
  |                return null;
  |             }
  |          }
  |       };
Stacktrace:

  | Problem in renderResponse: /components/main/search.xhtml: org.hibernate.MappingException: Named query not known: lamp
  | javax.el.ELException: /components/main/search.xhtml: org.hibernate.MappingException: Named query not known: lamp
  |         at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
  |         at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:581)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:588)
  |         at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:320)
  |         at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:156)
  |         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 com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
  |         at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:25)
  |         at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:146)
  |         at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
  |         at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:30)
  |         at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:48)
  |         at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
  |         at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
  |         at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
  |         at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
  |         at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:117)
  |         at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:37)
  |         at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
  |         at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
  |         at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:76)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
  |         at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  |         at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  |         at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  |         at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  |         at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  |         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
  |         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
  |         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  |         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  |         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
  |         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
  |         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  |         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  |         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
  |         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
  |         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
  |         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
  |         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: javax.persistence.PersistenceException: org.hibernate.MappingException: Named query not known: lamp
  |         at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
  |         at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:107)
  |         at org.jboss.seam.persistence.EntityManagerProxy.createNamedQuery(EntityManagerProxy.java:44)
  |         at ee.soov.resource.MessageResourceLoader$1.handleGetObject(MessageResourceLoader.java:45)
  |         at java.util.ResourceBundle.getObject(ResourceBundle.java:380)
  |         at org.jboss.seam.core.SeamResourceBundle.handleGetObject(SeamResourceBundle.java:102)
  |         at java.util.ResourceBundle.getObject(ResourceBundle.java:380)
  |         at java.util.ResourceBundle.getString(ResourceBundle.java:346)
  |         at org.jboss.seam.international.Messages$1.get(Messages.java:56)
  |         at org.jboss.seam.international.Messages$1.get(Messages.java:42)
  |         at javax.el.MapELResolver.getValue(MapELResolver.java:164)
  |         at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
  |         at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
  |         at org.jboss.el.parser.AstBracketSuffix.getValue(AstBracketSuffix.java:59)
  |         at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
  |         at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
  |         at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
  |         at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
  |         at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
  |         ... 77 more
  | Caused by: org.hibernate.MappingException: Named query not known: lamp
  |         at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:70)
  |         at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1260)
  |         at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:104)
  |         ... 94 more
  | 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109123#4109123

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109123



More information about the jboss-user mailing list