esgoru [
http://community.jboss.org/people/esgoru] created the discussion
"EntityManager is null, i can´t injected"
To view the discussion, visit:
http://community.jboss.org/message/610052#610052
--------------------------------------------------------------
i try using EntityManager, but i can´t instanced, i use tomcat v6.0 and mysql 4.1, i use
hibernate and spring. my config archives is:
jeveris-light-persistence.xml in web/scr/main/resources
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="test"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jar-file>j-everis-ejb.jar</jar-file>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.hbm2ddl.auto"
value="update"/>
<property name="hibernate.connection.username"
value="root"/>
<property name="hibernate.connection.password"
value="jeveris"/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/bankeveris"/>
</properties>
</persistence-unit>
</persistence>
jeveris-ligth-persistence.xml in ejb/scr/main/resource/meta-inf
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="test"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.hbm2ddl.auto"
value="update"/>
<property name="hibernate.connection.username"
value="root"/>
<property name="hibernate.connection.password"
value="jeveris"/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/bankeveris"/>
</properties>
</persistence-unit>
</persistence>
persistence.xml in ejb/scr/main/resource/meta-inf
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name ="j-everis-2.0">
<!-- jboss' default data source -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/jeveris</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property
name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"
/>
<property
name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql"
value="true"/>
<!-- Para evitar problemas con JBOSS -->
<property
name="hibernate.query.factory_class"
value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
</properties>
</persistence-unit>
</persistence>
clienteDaoImpl.java
package com.bankeveris.dao;
import java.util.List;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.springframework.stereotype.Service;
import com.bankeveris.model.Cliente;
@Stateless
@Local(ClienteDao.class)
@Service
public class ClienteDaoImpl implements ClienteDao {
/** Entity Manager */
@PersistenceContext
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public List<Cliente> findAllCliente() {
System.out.println("Dao: Accediendo a BBDD....");
return
(List<Cliente>)entityManager.createNamedQuery("findAllCliente").getResultList();
}
public Cliente findCliente(int noCli) {
Cliente cli=
(Cliente)entityManager.createNamedQuery("findCliente").setParameter("nCli",
noCli).getSingleResult();
System.out.println("Cliente name: " +
cli.getNombre());
return cli;
}
}
when i do debugging, i have a one error, when i use entityManager in this line
| |
|
| Cliente cli=
(Cliente)entityManager.createNamedQuery("findCliente").setParameter("nCli",
noCli).getSingleResult(); |
it´s the error
02882 [http-8080-1] WARN com.jeveris.pl.navigation.executor.NavigationController -
Spring-defined bean not found for action service:
com.bankeveris.flujo1DemoBankeveris.Service2F1. Instantiating brand-new action service...
902913 [http-8080-1] INFO com.jeveris.pl.navigation.model.ActionService - Before
executing ActionService: com.bankeveris.flujo1DemoBankeveris.Service2F1|flowInstanceId:
5317681774297516717|flowId: Flujo1DemoBankeveris|lastNodeId:
BuscarCliente|requiredTransitionId: mandarDatos|nextNodeId: BuscarDatos|containerId:
container_1
902913 [http-8080-1] DEBUG com.jeveris.pl.context.beans.FlowScope - view root:
org.ajax4jsf.component.AjaxViewRoot@66bb78
902913 [http-8080-1] DEBUG com.jeveris.pl.context.beans.FlowScope - attributes:
javax.faces.component.UIComponentBase$AttributesMap@b8a9dd16
java.lang.NullPointerException
at com.bankeveris.dao.ClienteDaoImpl.findCliente(ClienteDaoImpl.java:47)
at
com.bankeveris.service.ServiceClienteImpl.cliente(ServiceClienteImpl.java:29)
at com.bankeveris.flujo1DemoBankeveris.Service2F1.execute(Service2F1.java:43)
at com.jeveris.pl.navigation.model.ActionService.service(ActionService.java:41)
at
com.jeveris.pl.navigation.executor.NavigationController.processNavigation(NavigationController.java:149)
at
com.jeveris.pl.navigation.jsfintegration.PLNavigationHandler.handleNavigation(PLNavigationHandler.java:108)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
at
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
at
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
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:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
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:447)
at java.lang.Thread.run(Thread.java:595)
906366 [http-8080-1] ERROR com.jeveris.pl.navigation.executor.NavigationController -
Handle error for exception id=1308037940595: java.lang.NullPointerException
906382 [http-8080-1] ERROR com.jeveris.pl.navigation.executor.NavigationController - Flow
information for exception id=1308037940595: flowInstanceId: 5317681774297516717|flowId:
Flujo1DemoBankeveris|lastNodeId: BuscarCliente|requiredTransitionId:
mandarDatos|nextNodeId: BuscarDatos|containerId: container_1
906382 [http-8080-1] ERROR com.jeveris.pl.navigation.executor.NavigationController - Go
to error flow
906382 [http-8080-1] INFO com.jeveris.pl.navigation.executor.NavigationHelper - Access
to node errorService in flow error for resource com.jeveris.pl.core.services.ErrorService
is granted
906397 [http-8080-1] INFO com.jeveris.pl.navigation.executor.NavigationHelper - Flow
started|flowInstanceId: 3810207644419029423|flowId: error|lastNodeId:
null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
906444 [http-8080-1] DEBUG com.jeveris.pl.navigation.executor.NavigationController -
Searching for spring-defined bean errorService
906444 [http-8080-1] WARN com.jeveris.pl.businesslogic.control.BusinessLogicCaller -
Service (spring bean) with id errorService was not found. Returning null reference
906460 [http-8080-1] WARN com.jeveris.pl.navigation.executor.NavigationController -
Spring-defined bean not found for action service:
com.jeveris.pl.core.services.ErrorService. Instantiating brand-new action service...
906460 [http-8080-1] INFO com.jeveris.pl.navigation.model.ActionService - Before
executing ActionService: com.jeveris.pl.core.services.ErrorService|flowInstanceId:
3810207644419029423|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId:
errorService|containerId: container_1
906476 [http-8080-1] INFO MONITOR - PLResource:
com.jeveris.pl.core.services.ErrorService; Time: 0; Active Flow Info: flowInstanceId:
3810207644419029423|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId:
errorService|containerId: container_1
906491 [http-8080-1] INFO com.jeveris.pl.navigation.model.ActionService - Transition
received: jeveris:end from ActionService:
com.jeveris.pl.core.services.ErrorService|flowInstanceId: 3810207644419029423|flowId:
error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId:
container_1
I do conect hardcode with driverManager.getConection(), and It is good, i think this error
is in configure archives.
Please i need held.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/610052#610052]
Start a new discussion in EJB3 at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]