[jboss-user] [EJB 3.0] - Re: EntityManager Injection, Null Pointer Exception.

repkin do-not-reply at jboss.com
Wed Jun 18 07:42:04 EDT 2008


Hi, thanks for your reply.

I have tried a lot of possibilities. Yes, you right, at the sended log, the commented part not commented and have been worked together, but when I was trying the code parts separately, I was taking same error.

Now I am sending again the logs,

First of all deployment logs:
----------------------------------------------------------------
14:18:02,714 INFO  [TomcatDeployer] undeploy, ctxPath=/surgeonfish, warUrl=.../tmp/deploy/tmp25580surgeonfish.ear-contents/surgeonfish-exp.war/
14:18:02,730 INFO  [EJBContainer] STOPPED EJB: com.atosorigin.utils.pojo.PrGroupsHome ejbName: PrGroupsHome
14:18:02,730 WARN  [JmxKernelAbstraction] jboss.j2ee:ear=surgeonfish.ear,jar=surgeonfish.jar,name=PrGroupsHome,service=EJB3 is not registered
14:18:02,730 INFO  [EJBContainer] STOPPED EJB: com.atosorigin.utils.pojo.PrStaffHome ejbName: PrStaffHome
14:18:02,730 WARN  [JmxKernelAbstraction] jboss.j2ee:ear=surgeonfish.ear,jar=surgeonfish.jar,name=PrStaffHome,service=EJB3 is not registered
14:18:02,730 INFO  [PersistenceUnitDeployment] Stopping persistence unit persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context
14:18:02,745 ERROR [STDERR] 6708532 [ScannerThread] INFO org.hibernate.impl.SessionFactoryImpl - closing
14:18:02,745 ERROR [STDERR] 6708532 [ScannerThread] INFO org.hibernate.impl.SessionFactoryObjectFactory - Unbinding factory from JNDI name: persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,un
itName=time_report_persistence_context
14:18:02,745 ERROR [STDERR] 6708532 [ScannerThread] INFO org.hibernate.util.NamingHelper - JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.nam
ing.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
14:18:02,745 ERROR [STDERR] 6708532 [ScannerThread] INFO org.hibernate.impl.SessionFactoryObjectFactory - Unbound factory from JNDI name: persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unit
Name=time_report_persistence_context
14:18:02,761 ERROR [STDERR] 6708548 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
14:18:02,761 ERROR [STDERR] 6708548 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
14:18:02,761 ERROR [STDERR] 6708548 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
14:18:02,761 WARN  [JmxKernelAbstraction] persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context is not registered
14:18:02,777 INFO  [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=time_reporting_data_source' from JNDI name 'java:time_reporting_data_source'
14:18:02,870 INFO  [EARDeployer] Undeploying J2EE application, destroy step: file:/C:/jboss/server/default/deploy/surgeonfish.ear
14:18:02,870 INFO  [EARDeployer] Undeployed J2EE application: file:/C:/jboss/server/default/deploy/surgeonfish.ear
14:18:02,886 INFO  [EARDeployer] Init J2EE application: file:/C:/jboss/server/default/deploy/surgeonfish.ear
14:18:03,994 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=time_reporting_data_source' to JNDI name 'java:time_reporting_data_source'
14:18:03,994 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
14:18:03,994 INFO  [JmxKernelAbstraction] installing MBean: persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context with dependencies:
14:18:04,010 INFO  [JmxKernelAbstraction]       jboss.jca:name=time_reporting_data_source,service=DataSourceBinding
14:18:04,010 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context
14:18:04,072 INFO  [AnnotationBinder] Binding entity from annotated class: com.atosorigin.utils.pojo.PrGroups
14:18:04,072 INFO  [EntityBinder] Bind entity com.atosorigin.utils.pojo.PrGroups on table pr_groups
14:18:04,072 INFO  [AnnotationBinder] Binding entity from annotated class: com.atosorigin.utils.pojo.PrStaff
14:18:04,072 INFO  [EntityBinder] Bind entity com.atosorigin.utils.pojo.PrStaff on table pr_staff
14:18:04,088 INFO  [AnnotationConfiguration] Hibernate Validator not found: ignoring
14:18:04,119 ERROR [STDERR] 6709906 [ScannerThread] INFO org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectio
nProvider
14:18:04,119 INFO  [InjectedDataSourceConnectionProvider] Using provided datasource
14:18:04,135 ERROR [STDERR] 6709922 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.1.12-beta-community-nt
14:18:04,135 ERROR [STDERR] 6709922 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
14:18:04,135 ERROR [STDERR] 6709922 [ScannerThread] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.transaction.TransactionManagerLookupFactory - instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionM
anagerLookup
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.transaction.TransactionManagerLookupFactory - instantiated TransactionManagerLookup
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
14:18:04,150 ERROR [STDERR] 6709937 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
14:18:04,166 ERROR [STDERR] 6709953 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
14:18:04,182 ERROR [STDERR] 6709969 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge - Cache provider: org.hibernate.cache.HashtableCacheProvider
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Cache region prefix: surgeonfish_ear,surgeonfish_jar,time_report_persistence_context
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
14:18:04,197 ERROR [STDERR] 6709984 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
14:18:04,213 ERROR [STDERR] 6710000 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
14:18:04,213 ERROR [STDERR] 6710000 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
14:18:04,213 ERROR [STDERR] 6710000 [ScannerThread] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
14:18:04,213 ERROR [STDERR] 6710000 [ScannerThread] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
14:18:04,260 ERROR [STDERR] 6710047 [ScannerThread] INFO org.hibernate.impl.SessionFactoryObjectFactory - Factory name: persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_p
ersistence_context
14:18:04,260 ERROR [STDERR] 6710047 [ScannerThread] INFO org.hibernate.util.NamingHelper - JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.nam
ing.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
14:18:04,260 ERROR [STDERR] 6710047 [ScannerThread] INFO org.hibernate.impl.SessionFactoryObjectFactory - Bound factory to JNDI name: persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName
=time_report_persistence_context
14:18:04,275 ERROR [STDERR] 6710062 [ScannerThread] WARN org.hibernate.impl.SessionFactoryObjectFactory - InitialContext did not implement EventContext
14:18:04,275 ERROR [STDERR] 6710062 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
14:18:04,275 ERROR [STDERR] 6710062 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
14:18:04,306 ERROR [STDERR] 6710093 [ScannerThread] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
14:18:04,306 ERROR [STDERR] 6710093 [ScannerThread] INFO org.hibernate.util.NamingHelper - JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.nam
ing.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
14:18:04,306 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
14:18:04,322 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=surgeonfish.ear,jar=surgeonfish.jar,name=PrGroupsHome,service=EJB3 with dependencies:
14:18:04,322 INFO  [JmxKernelAbstraction]       persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context
14:18:04,338 INFO  [EJBContainer] STARTED EJB: com.atosorigin.utils.pojo.PrGroupsHome ejbName: PrGroupsHome
14:18:04,353 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
14:18:04,353 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=surgeonfish.ear,jar=surgeonfish.jar,name=PrStaffHome,service=EJB3 with dependencies:
14:18:04,353 INFO  [JmxKernelAbstraction]       persistence.units:ear=surgeonfish.ear,jar=surgeonfish.jar,unitName=time_report_persistence_context
14:18:04,369 INFO  [EJBContainer] STARTED EJB: com.atosorigin.utils.pojo.PrStaffHome ejbName: PrStaffHome
14:18:04,385 INFO  [EJB3Deployer] Deployed: file:/C:/jboss/server/default/tmp/deploy/tmp25581surgeonfish.ear-contents/surgeonfish.jar
14:18:04,385 INFO  [TomcatDeployer] deploy, ctxPath=/surgeonfish, warUrl=.../tmp/deploy/tmp25581surgeonfish.ear-contents/surgeonfish-exp.war/
14:18:04,509 INFO  [EARDeployer] Started J2EE application: file:/C:/jboss/server/default/deploy/surgeonfish.ear

the bean code is exactly this:


  | @Stateless
  | @Local(value=PrStaffInterface.class)
  | public class PrStaffHome {
  | 
  | 	private static final Log log = LogFactory.getLog(PrStaffHome.class);
  | 
  | 	@PersistenceContext(unitName="time_report_persistence_context")
  | 	private EntityManager entityManager;
  | 
  | 	public PrStaff findById(Integer id) {
  | 		log.debug("getting PrStaff instance with id: " + id);
  | 		try {
  | 			System.out.println("-------------entityManager-------------:"+entityManager);
  | 			PrStaff instance = entityManager.find(PrStaff.class, id);
  | 			log.debug("get successful");
  | 			return instance;
  | 		} catch (RuntimeException re) {
  | 			log.error("get failed", re);
  | 			throw re;
  | 		}
  | 	}
  | }
  | 


And the code's log:

14:31:39,747 INFO  [STDOUT] -------------entityManager-------------:null
14:31:39,763 ERROR [PrStaffHome] get failed
java.lang.NullPointerException
        at com.atosorigin.utils.pojo.PrStaffHome.findById(PrStaffHome.java:75)
        at com.atosorigin.jdbc.DBSecurity.checkUserPassword(DBSecurity.java:102)
        at com.atosorigin.timereport.servlet.TIMEController.doLogin(TIMEController.java:550)
        at com.atosorigin.timereport.servlet.TIMEController.service(TIMEController.java:58)
        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)
14:31:39,763 ERROR [STDERR] java.lang.NullPointerException
14:31:39,763 ERROR [STDERR]     at com.atosorigin.utils.pojo.PrStaffHome.findById(PrStaffHome.java:75)
14:31:39,763 ERROR [STDERR]     at com.atosorigin.jdbc.DBSecurity.checkUserPassword(DBSecurity.java:102)
14:31:39,763 ERROR [STDERR]     at com.atosorigin.timereport.servlet.TIMEController.doLogin(TIMEController.java:550)
14:31:39,763 ERROR [STDERR]     at com.atosorigin.timereport.servlet.TIMEController.service(TIMEController.java:58)
14:31:39,763 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:31:39,763 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
14:31:39,763 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
14:31:39,763 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:31:39,763 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:31:39,763 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
14:31:39,763 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
14:31:39,763 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
14:31:39,763 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
14:31:39,763 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)


I have tried the bean by this code, it was triggered by user request through servlet:

  | public class DBSecurity {
  |     public boolean checkUserPassword(String username, String password) throws Exception {
  |     	PrStaffHome prStaffHome = new PrStaffHome();
  |     	PrStaff prStaff = prStaffHome.findById(new Integer(username));
  |     }
  | }
  | 

I am so thanksfull for your helps, I have stucked at this point.

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

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



More information about the jboss-user mailing list