Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Metamodel not being created until after first use
Metamodel not being created until after first use [message #781008] Wed, 18 January 2012 02:54 Go to next message
Nick Padilla is currently offline Nick PadillaFriend
Messages: 16
Registered: August 2011
Location: New Mexico
Junior Member
I have this setup:

EclipseLink 2.3.2
Dali for generating metamodel classes
Spring 3.1 / Spring 3.1 MVC
Tomcat 7.0.20
Java 1.7


The problem is the first time i use my Metamodel, Account_.id, it is null. This is obviously not correct. Later calls to the same method the Account_.id correctly returns the SingularAttribute. From my understanding it is the responsibility of the JPA implementation to setup the metamodel. If I call persist first then find() I get a correct Account_.id.

Does anyone else have this problem or have seen this problem? It is pretty distinct, here is the stack trace:

Quote:
> java.lang.NullPointerException
> at org.eclipse.persistence.internal.jpa.querydef.FromImpl.get(FromImpl.java:260)
> at com.monstersoftwarellc.testApp.dao.AccountDAO.findAllOrderBy(AccountDAO.java:57)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
> at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
> at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
> at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
> at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
> at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
> at $Proxy19.findAllOrderBy(Unknown Source)
> at com.monstersoftwarellc.virtualvote.HomeController.listUsers(HomeController.java:53)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
> at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
> at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
> at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
> at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
> at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
> at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
> at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
> at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
> at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)


Here you can see the next call works as expected :

Quote:
> Connection(1243367869)--Thread(Thread[tomcat-http--37,5,main])--SELECT ID, VERSION, LOGIN_ID, PERSON_ID FROM ACCOUNT ORDER BY ID ASC


Not sure what the problem is here, but can't have this in production. Any ideas or pointers?

Thanks!
Re: Metamodel not being created until after first use [message #845410 is a reply to message #781008] Sun, 15 April 2012 03:08 Go to previous messageGo to next message
Michael Mok is currently offline Michael MokFriend
Messages: 1
Registered: April 2012
Junior Member
Hi Nick

I do not have an answer to your query. But can you provide your spring context.xml as we are having problems trying to insert a new object using Spring 3.1, Eclipselink 2.3 and MySQL. The error we found is



java.lang.IllegalArgumentException: Object: com.greenpower.bean.BaseProduct@5e0eb724 is not a known entity type.
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4158)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:440)
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 org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)


Re: Metamodel not being created until after first use [message #1746807 is a reply to message #781008] Fri, 04 November 2016 19:12 Go to previous message
Reesa Phillips is currently offline Reesa PhillipsFriend
Messages: 2
Registered: November 2016
Junior Member
I know this is an old topic so I am only including a response to this for anyone experiencing the same problem who happens to stumble here. I was seeing the same behavior in one of my retrieval methods and I came to the realization that it was happening because the metamodel classes are not injected until an entity manager is first created. I thought it would happen when the entity manager factory was created so I had a fancy method that was doing things generically and was passed a metamodel field as a parameter before an entity manager had been created. So all that to say, create the entity manager first and then use the metamodel fields. Hope that helps!
Previous Topic:Lazy loaded relation after detach with cascade detach not detached.
Next Topic:JPA with sybase kerberos
Goto Forum:
  


Current Time: Tue Mar 19 08:10:02 GMT 2024

Powered by FUDForum. Page generated in 0.02561 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top