JPA Problem beim Speichern eines Users

Rallenaldo

Mitglied
Hallo.

Ich versuche über Events eine lose Koppelung herzustellen. Allerdings kann ich die em.persist Methode nicht ausführen, da eine NullPointerException geworfen wird. Zum vereinfachten Testen inwieweit der User übergeben wird, habe ich in jeder Methode die verwendet wird, eine System.out.println Ausgabe eingefügt. Laut Ausgabe, wird der User korrekt übergeben. Bis zu dem Zeitpunkt, an dem er in die Datenbank gespeichert werden soll.

Hier die Klassen:

User:

Code:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;


@Entity
@Table(name = "user")
@TableGenerator(name="userPkGen", table ="id_gen", pkColumnName ="gen_name",
            valueColumnName ="gen_value", pkColumnValue="user_id_gen", allocationSize = 1)
public class User implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE, generator="userPkGen")
    @Basic(optional = false)
    @Column(name = "userId")
    private Integer userId;
    
    @Column(name = "userRegistrationDate")
    @Temporal(TemporalType.DATE)
    private Date userRegistrationDate;
    
    @Basic(optional = false)
    @Column(name = "username")
    private String username;
    
    @Basic(optional = false)
    @Column(name = "password")
    private String password;
    
    @Column(name = "userTitle")
    @Enumerated(EnumType.STRING)
    private UserTitle userTitle;
   
    @Column(name = "userFirstName")
    private String userFirstName;
    

    @Column(name = "userLastName")
    private String userLastName;
    

    @Column(name = "userAdress")
    private String userAdress;
    
    @Column(name = "userHouseNumber")
    private Integer userHouseNumber;
    
    @Column(name = "userZipCode")
    private Integer userZipCode;
    
    @Size(max = 55)
    @Column(name = "userCity")
    private String userCity;
    
    @Size(max = 75)
    @Column(name = "userEmail")
    private String userEmail;
    
    @Column(name = "userState")
    private Integer userState;
    
    @OneToMany(mappedBy="user")
    private List<Company> companyList = new ArrayList<>();
    
    @OneToMany(mappedBy="user")
    private List<Purchaser> purchaserList = new ArrayList<>();

    public User() {
        
    }

    public User(Integer userId) {
        this.userId = userId;
    }

    public User(Integer userId, String username, String password, String userFirstName) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.userFirstName = userFirstName;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Date getUserRegistrationDate() {
        return userRegistrationDate;
    }

    public void setUserRegistrationDate(Date userRegistrationDate) {
        this.userRegistrationDate = userRegistrationDate;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public UserTitle getUserTitle() {
        return userTitle;
    }

    public void setUserTitle(UserTitle userTitle) {
        this.userTitle = userTitle;
    }

    public String getUserFirstName() {
        return userFirstName;
    }

    public void setUserFirstName(String userFirstName) {
        this.userFirstName = userFirstName;
    }

    public String getUserLastName() {
        return userLastName;
    }

    public void setUserLastName(String userLastName) {
        this.userLastName = userLastName;
    }

    public String getUserAdress() {
        return userAdress;
    }

    public void setUserAdress(String userAdress) {
        this.userAdress = userAdress;
    }

    public Integer getUserHouseNumber() {
        return userHouseNumber;
    }

    public void setUserHouseNumber(Integer userHouseNumber) {
        this.userHouseNumber = userHouseNumber;
    }

    public Integer getUserZipCode() {
        return userZipCode;
    }

    public void setUserZipCode(Integer userZipCode) {
        this.userZipCode = userZipCode;
    }

    public String getUserCity() {
        return userCity;
    }

    public void setUserCity(String userCity) {
        this.userCity = userCity;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public Integer getUserState() {
        return userState;
    }

    public void setUserState(Integer userState) {
        this.userState = userState;
    }

    public List<Company> getCompanyList() {
        return companyList;
    }

    public void setCompanyList(List<Company> companyList) {
        this.companyList = companyList;
    }

    public List<Purchaser> getPurchaserList() {
        return purchaserList;
    }

    public void setPurchaserList(List<Purchaser> purchaserList) {
        this.purchaserList = purchaserList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.zerrenda.zerrenda.User[ userId=" + userId + " ]";
    }
    
}

UserListController:

Code:
import de.zerrenda.zerrendaee6.controller.UserEditController.Mode;
import de.zerrenda.zerrendaee6.entities.User;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

@Named
@SessionScoped
public class UserListController implements Serializable{
        
    @Inject
    private UserEditController userEditController;
    
    public String doAddUser(){
        System.out.println("doAddUser ruft die Methode SetUserToEdit mit Parameter Add auf.");
        userEditController.setUserToEdit(Mode.ADD);
        return "registerSuccess" ;
    }
    
    public String doUpdateUser (User user){
        
        userEditController.setUserToEdit(Mode.EDIT);
        System.out.println("setUserToEdit wird mit EDIT aufgerufen");
        return null;
    }
    
    public void doDeleteUser(User user){
        userEditController.setUserToDelete(user);
    }
    
}

UserEditController:

Code:
package de.zerrenda.zerrendaee6.controller;

import de.zerrenda.zerrendaee6.entities.User;
import de.zerrenda.zerrendaee6.qualifiers.Added;
import de.zerrenda.zerrendaee6.qualifiers.Updated;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;

@Named
@SessionScoped
public class UserEditController implements Serializable{
    
    @Added
    @Inject
    private Event<User> userAddEventSrc;
    
    @Updated
    @Inject
    private Event<User> userUpdateEventSrc;
    
    private Mode mode;
    private User user;
    
    @PostConstruct
    public void init(){
        user = new User();
    }
    
    public enum Mode {
        
        ADD, EDIT;
    }
    
    public void setUserToEdit(Mode mode){
        setUserToEdit(mode, getUser());
    }
    
    public void setUserToEdit(Mode mode, User user){
        this.mode = mode;
        this.user = user;
        doSave();
    }
    
    public String doSave() {
        
        if(getMode() == Mode.ADD){
            System.out.println("doSave Methode des UserEdtController wird mit ADD gefired");
            System.out.println(user.getUserFirstName());
            userAddEventSrc.fire(user);
        }else {
            System.out.println("doSave Methode des UserEdtController wird mit EDIT gefired");
            userUpdateEventSrc.fire(user);
        }
        return "registerSuccess";
    }
    
    public void setUserToDelete(User user){
        
    }

    public Mode getMode() {
        return mode;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}

UserListProducer:

Code:
package de.zerrenda.zerrendaee6.data;

import de.zerrenda.zerrendaee6.entities.User;
import de.zerrenda.zerrendaee6.qualifiers.Added;
import de.zerrenda.zerrendaee6.qualifiers.Deleted;
import de.zerrenda.zerrendaee6.qualifiers.Updated;
import de.zerrenda.zerrendaee6.services.UserService;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

@RequestScoped
public class UserListProducer {
    
    @Inject
    private UserService userService;
    
    public void onUserAdded(@Observes @Added User user){
        System.out.println("onUserAdded des UserListProducer wird ausgeführt");
        System.out.println(user.getUserFirstName());
        userService.addUser(user); 
    }
    
    public void onUserUpdated(@Observes @Updated User user){
        userService.updateUser(user);
        System.out.println("onUserUpdated des UserListProducer wird ausgeführt");
    }
    
    public void onUserDeleted(@Observes @Deleted User user){
        userService.deleteUser(user);
        System.out.println("onUserDeleted des UserListProducer wird ausgeführt");
    }
    
}

UserServiceBean:

Code:
package de.zerrenda.zerrendaee6.beans;

import de.zerrenda.zerrendaee6.entities.User;
import de.zerrenda.zerrendaee6.services.UserService;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;

@Stateless
public class UserServiceBean implements UserService{
 
   EntityManager em;

    @Override
    public User addUser(User user) {
        
        em.persist(user);
        System.out.println("addUser der UserServiceBean wird aufgerufen");
        return user;
    }

    @Override
    public User updateUser(User user) {
        
        return em.merge(user);
    }

    @Override
    public void deleteUser(User user) {
        
        User userToDelete = em.find(User.class, user.getUserId());
        em.remove(userToDelete);
    }

    @Override
    public <List>User getAllUsers() {
      
        return null;
    }
}

persistence.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="ZerrendaPU" transaction-type="JTA">
    <jta-data-source>jdbc/zerrendadb</jta-data-source>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

Der EntityManager wird in einer anderen Klasse injiziert, weshalb die @Inject Annotation nicht vorhanden ist.

In einer JSF Datei wird zuerst die Methode doAddUser des UserListControllers aufgerufen.
 
Zuletzt bearbeitet:

stg

Top Contributor
Wie wärs, wenn du auch den Stacktrace der Exception posten würdest, dann müsste man nicht so im Dunkeln tappen bzw ziellos suchen :)

Aber vorab: Woher soll deine UserServiceBean denn eine Instanz vom EM bekommen? Da sehe ich gerade nichts. Vielleicht ist das ja schon das Problem?!

Um den EM in deiner UserServiceBean zu nutzen solltest du ihn etwa so annotieren:

Java:
@PersistenceContext(unitName = "ZerrendaPU")
private EntityManager entityManager ;
 
Zuletzt bearbeitet:

Rallenaldo

Mitglied
Heidenei. Total vergessen :D

Hier der Stacktrace:

Code:
Information:   doAddUser ruft die Methode SetUserToEdit mit Parameter Add auf.
Information:   doSave Methode des UserEdtController wird mit ADD gefired
Information:   Vorname
Information:   onUserAdded des UserListProducer wird ausgeführt
Information:   Vorname
Warnung:   EJB5184:A system exception occurred during an invocation on EJB UserServiceBean, method: public de.zerrenda.zerrendaee6.entities.User de.zerrenda.zerrendaee6.beans.UserServiceBean.addUser(de.zerrenda.zerrendaee6.entities.User)
Warnung:   javax.ejb.EJBException
	at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
	at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
	at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
	at com.sun.proxy.$Proxy301.addUser(Unknown Source)
	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:606)
	at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:396)
	at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:108)
	at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
	at org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:63)
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:101)
	at de.zerrenda.zerrendaee6.beans.UserService$-783436158$Proxy$_$$_Weld$EnterpriseProxy$.addUser(Unknown Source)
	at de.zerrenda.zerrendaee6.data.UserListProducer.onUserAdded(UserListProducer.java:21)
	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:606)
	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:274)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:261)
	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:170)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:166)
	at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:44)
	at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:120)
	at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:113)
	at org.jboss.weld.event.EventImpl.fire(EventImpl.java:79)
	at de.zerrenda.zerrendaee6.controller.UserEditController.doSave(UserEditController.java:53)
	at de.zerrenda.zerrendaee6.controller.UserEditController.setUserToEdit(UserEditController.java:45)
	at de.zerrenda.zerrendaee6.controller.UserEditController.setUserToEdit(UserEditController.java:39)
	at de.zerrenda.zerrendaee6.controller.UserEditController$Proxy$_$$_WeldClientProxy.setUserToEdit(Unknown Source)
	at de.zerrenda.zerrendaee6.controller.UserListController.doAddUser(UserListController.java:19)
	at de.zerrenda.zerrendaee6.controller.UserListController$Proxy$_$$_WeldClientProxy.doAddUser(Unknown Source)
	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:606)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
	at de.zerrenda.zerrendaee6.beans.UserServiceBean.addUser(UserServiceBean.java:16)
	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:606)
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
	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:606)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
	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:606)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
	... 81 more

Warnung:   #{userListController.doAddUser()}: javax.ejb.EJBException
javax.faces.FacesException: #{userListController.doAddUser()}: javax.ejb.EJBException
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:744)
Caused by: javax.faces.el.EvaluationException: javax.ejb.EJBException
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	... 34 more
Caused by: javax.ejb.EJBException
	at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
	at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
	at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
	at com.sun.proxy.$Proxy301.addUser(Unknown Source)
	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:606)
	at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:396)
	at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:108)
	at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
	at org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:63)
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:101)
	at de.zerrenda.zerrendaee6.beans.UserService$-783436158$Proxy$_$$_Weld$EnterpriseProxy$.addUser(Unknown Source)
	at de.zerrenda.zerrendaee6.data.UserListProducer.onUserAdded(UserListProducer.java:21)
	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:606)
	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:274)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:261)
	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:170)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:166)
	at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:44)
	at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:120)
	at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:113)
	at org.jboss.weld.event.EventImpl.fire(EventImpl.java:79)
	at de.zerrenda.zerrendaee6.controller.UserEditController.doSave(UserEditController.java:53)
	at de.zerrenda.zerrendaee6.controller.UserEditController.setUserToEdit(UserEditController.java:45)
	at de.zerrenda.zerrendaee6.controller.UserEditController.setUserToEdit(UserEditController.java:39)
	at de.zerrenda.zerrendaee6.controller.UserEditController$Proxy$_$$_WeldClientProxy.setUserToEdit(Unknown Source)
	at de.zerrenda.zerrendaee6.controller.UserListController.doAddUser(UserListController.java:19)
	at de.zerrenda.zerrendaee6.controller.UserListController$Proxy$_$$_WeldClientProxy.doAddUser(Unknown Source)
	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:606)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	... 35 more
Caused by: java.lang.NullPointerException
	at de.zerrenda.zerrendaee6.beans.UserServiceBean.addUser(UserServiceBean.java:16)
	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:606)
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
	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:606)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
	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:606)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
	... 81 more

Ok. Hab die Annotation hinzugefügt und es klappt. Vielen Dank für die Hilfe!
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
S MessageDrivenBean Problem beim Zugriff auf Stateful EJB Allgemeines EE 2
B Problem beim Lesen des Codes... Allgemeines EE 2
B Problem beim einbinden einer CSS in eine JSP Allgemeines EE 8
S Embedded JBoss Problem beim Deployment Allgemeines EE 4
H GWT Problem beim Ausführen Allgemeines EE 8
E Performance-Problem beim ersten Request Allgemeines EE 4
M servlet --> jsp - problem beim umstrukturieren Allgemeines EE 5
A Problem / Fehler beim Einbinden einer Klasse in ein JSP Allgemeines EE 20
B Problem beim Deployen auf Sun AS 8.1 Allgemeines EE 12
R Problem beim hochladen einer Web Application Allgemeines EE 16
H Problem beim Umstieg von 1.3 auf 1.4 Allgemeines EE 5
D Problem mit Update von ApacheHttpClient von 5.2 auf 5.3 Allgemeines EE 10
D Problem mit redundanten Servern Allgemeines EE 7
Azemaria JSF: Problem bei der einfachsten Applikation Allgemeines EE 2
P JPA Internal Problem Nullpointer Allgemeines EE 10
M Glassfish Deployment-Problem unter Eclipse Allgemeines EE 0
S WebSocket Problem Allgemeines EE 0
F Eclipse/Java EE Debug-Problem Allgemeines EE 1
G Problem: Servlet in JSP einbinden mit <jsp:include> Allgemeines EE 3
Raidri [SEAM] rich:dataTable sortBy Problem Allgemeines EE 6
T Problem mit den Beispielen von Apache Allgemeines EE 5
W JSF Validator Problem HTTP Status 500 Allgemeines EE 2
E JBoss 7.1 Datasource Problem Allgemeines EE 2
M JSP Problem -unbestimmte Anzahl von Werten Transportieren Allgemeines EE 9
S Problem mit EJB Verständnis Allgemeines EE 4
F JSP Problem mit Datenbankanbindung über Glassfishserver Allgemeines EE 4
S java Entities Problem Allgemeines EE 19
E Session Problem Allgemeines EE 9
F problem mit nullpointer bei DB zugriff Allgemeines EE 2
A Erste Schritte... Problem mit Hibernate Allgemeines EE 15
ruutaiokwu jboss problem - work-verzeichnis muss manuell gelöscht werden??? Allgemeines EE 5
Stillmatic sendRedirect Problem! Allgemeines EE 3
M Problem mit Lookup auf EJB3 mit Glassfish Allgemeines EE 11
0 Problem mit librarys javax.servlet.http.HttpServletRequest cannot be resolved Allgemeines EE 1
X JBoss InitialContext problem Allgemeines EE 5
LordZed Problem mit dem einbinden von Bibliotheken, die sich gegenseitig verwenden Allgemeines EE 5
Q Problem mit JMS und Weblogic 10 Allgemeines EE 5
G Multi User Problem Allgemeines EE 8
G Datasource Problem Allgemeines EE 1
J OOP Java Array Problem Allgemeines EE 2
T Problem mit Java Transaction API Allgemeines EE 2
D Problem mit EJB: Bean soll Objekt eigener Klasse zurückgeben Allgemeines EE 2
N JavaMail Problem Allgemeines EE 4
N JBoss Problem mit Bibliothek in unterschiedlichen Versionen Allgemeines EE 2
A Tomcat -- JSP: komisches Problem Allgemeines EE 11
W Speicher-Problem bei WebApp unter Tomcat, Struts, Hibernate Allgemeines EE 3
B Problem mit ActionListener Allgemeines EE 13
G Simples JSF-Projekt in Eclipse - Problem Allgemeines EE 9
O eclipse - tomcat: Problem bei einfachem Webservice Allgemeines EE 16
J Problem mit EJB Aufruf und DualCore Rechner Allgemeines EE 4
J ejb3.0 datenbank problem Allgemeines EE 2
J Problem mit Zurück-Button Allgemeines EE 2
T Tomcat: JNDI + JDBC Problem Allgemeines EE 3
J problem mit jsp/js Allgemeines EE 2
B Help - EJB2 - Problem mit Hybernate und "LIMIT" Allgemeines EE 6
B JSTL Problem Allgemeines EE 8
byte Tomcat Deployment Problem (HTTP Status 503) Allgemeines EE 8
S Problem mit t:selectOneRadio und ValueChangeListener Allgemeines EE 2
S Problem mit Struts und tiles Allgemeines EE 4
B Problem mit JBoss-4.2.1.GA Allgemeines EE 8
N Tiles - JSF Problem Allgemeines EE 3
M JSF & EJB "Bean not bound" Problem Allgemeines EE 4
V MYSQL JDBC;java.lang.ClassNotFoundException; Problem Eclipse Allgemeines EE 3
megachucky JMS - Problem mit TemporaryQueue Allgemeines EE 2
G Problem mit MimeType/ContentType Allgemeines EE 4
E Java Mail problem Allgemeines EE 5
Y XFire - Maven Build Problem Allgemeines EE 2
D JSP Problem mit equals? Allgemeines EE 2
A Eclipse Start-Problem Allgemeines EE 5
S JSF - Custom converter Problem Allgemeines EE 3
Y JSF Uhrzeitausgabe Problem Allgemeines EE 4
Y JSF - rendered Problem Allgemeines EE 1
D Servlet Problem über Server Allgemeines EE 26
Zed JSF h:inputText h:outputText update Problem Allgemeines EE 2
K mysql treiber problem wenn import java.sql.* bei _servlet_ Allgemeines EE 2
S JDBC Mysql Connection Problem - datasource null Allgemeines EE 3
T Session-Problem Allgemeines EE 2
R Tiles - Layout-Problem wegen Leerzeichen Allgemeines EE 6
G Tomcat / Eclipse oder Web.xml Problem Allgemeines EE 11
S Netbeans 5.5 Visual Web Pack Problem mit INSERT und PK Allgemeines EE 4
D JSF Problem mit Action Allgemeines EE 2
F Klassen und zugriffs Problem "Help wanted"! Allgemeines EE 16
D <input type="file"> Problem Allgemeines EE 6
N Struts - Problem mit <html:link> Action Allgemeines EE 3
G Session Problem Allgemeines EE 5
T Ant Compiler Problem Allgemeines EE 9
T Problem dem Zaehler in mein Java - Code Allgemeines EE 2
A Hibernate-Problem mit MySQL-Cluster Allgemeines EE 6
H Servlet problem Allgemeines EE 10
G Problem mit Benutzerverwaltung Allgemeines EE 3
S Hibernate Mapping Problem Allgemeines EE 3
S Hibernate INSERT Problem Allgemeines EE 11
S Dummes JSP-Problem Allgemeines EE 8
P EJB-Installations-Problem Allgemeines EE 4
S CSS Problem in JSP Allgemeines EE 16
C Problem mit html:optionsCollection Allgemeines EE 4
R HILFE: Problem mit JSF examples Allgemeines EE 10
R Problem mit value-expression Allgemeines EE 7
R Problem mit for-schleife in JSP tag Allgemeines EE 8
B Struts Problem: Array in JSP ausgeben (logic:iterate) Allgemeines EE 12

Ähnliche Java Themen

Neue Themen


Oben