[Persistence, JBoss/CMP, Hibernate, Database] - EntityManager throws a nullpointerexception JBOSS 4.2.2GA EJ
by July Pyrra
Hola,
I'm developing web services using EJB3 and JBOSS 4.2.2.GA.
I have a NPE which seems to come from a non working EntityManager injection. I'm not very comfortable with EJB3 yet...
My web service works fine. In its method, it calls another class method which performs one part of the service. To interact with the database, it uses the methods of a class which regroups all the queries. Therefore, this is where i use an EntityManager as following:
| package bd.query;
|
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| @Stateless
| public class Query implements QueryInt{
|
| @PersistenceContext
| EntityManager em;
|
| public SystemUser AuthenticateUser(String uid, String pwd){
| SystemUser _SystemUser = (SystemUser) em.createQuery("select a.systemUser from Account ").getSingleResult();
| return _SystemUser;
|
| }
| }
|
This is my persistence.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence>
| <persistence-unit name="Query" >
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/cuoreds</jta-data-source>
| </persistence-unit>
| </persistence>
|
I package all my classes in a .jar file with the persistence.xml in a META-INF directory. It seems to deploy correctly but when I call my methods using my authentification query, I get the following error :
| 2008-05-26 15:47:06,184 ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
| javax.ejb.EJBException: java.lang.NullPointerException
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)
| at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
| at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: java.lang.NullPointerException
| at org.eu.nuadu.cuore.bd.query.Query.AuthenticateUser(Query.java:89)
| at org.eu.nuadu.cuore.ws.process.Authentication.authenticate(Authentication.java:24)
| at org.eu.nuadu.cuore.ws.services.Update.SearchEvent(Update.java:22)
| 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:585)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
| ... 39 more
|
I think the error comes from an architecture which doesn't fit EJB3 because it works with a EntityManagerFactory...
I've looked for a solution on many forums but so far, it never appeared solve my problem. Please let me know if you have any idea...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4153374#4153374
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4153374
17 years, 11 months
[JBoss Portal] - Duplicate entry '13-portal.user.last-login-date' within Port
by IronMan77
Hi,
using this setup:
* Version: jboss-portal-ha-2.6.1.GA-bundled
| * Download Version
| * JBoss AS Version: 4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)]
| * Database: Mysql 5.0.26 (SLES10)
| * JDBC Connector and Version: mysql-connector-java-5.0.5-bin.jar
| * OS Platform: SUSE Linux Enterprise Server 10 (i586)
| * Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
|
I have three jboss portal instances in a cluster setup. Sometimes a user gets a strange error when he tries to log out:
| java.sql.BatchUpdateException: Duplicate entry '13-portal.user.last-login-date' for key 1
| com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1213)
| com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:912)
| org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
| org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
| org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
| org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
| org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
| org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
| org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
| org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
| org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
| org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
| com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
| com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
| com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
| com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
| com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
| com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
| com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
| org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
| org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
| org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:262)
| org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
| org.jboss.portal.core.aspects.server.TransactionInterceptor.invoke(TransactionInterceptor.java)
| org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
| org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| org.jboss.portal.server.aspects.LockInterceptor$InternalLock.invoke(LockInterceptor.java:70)
| org.jboss.portal.server.aspects.LockInterceptor.invoke(LockInterceptor.java:131)
| org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:157)
| org.jboss.portal.server.servlet.PortalServlet.service(PortalServlet.java:380)
| javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| de.materna.sinfonia.jbossportal.portalServerWar.servletfilter.ParameterFilter.doFilter(ParameterFilter.java:107)
| org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
| org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
| org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
|
The error seems to happen randomly, but i can reproduce it (sometimes) this way:
| * Login on the three systems as the same user (e.g. "foo")
| * Logout on one system, this does work
| * Logout on a other system, this produces the above error
|
Is this a problem related to the setup or a not allowed use case? Has some else witnessed this error?
Thanks in advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4153342#4153342
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4153342
17 years, 11 months