Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JPAContainer duplicate method: writeReplace Netbeans + Glassfish 3.1.12
Hi there,
there is a problem with Glassfish 3.1.12, in 3.0 all works fine … see https://vaadin.com/forum/-/message_boards/view_message/622598
But thats no option for the future … ;-(
Initializing...
deploy?DEFAULT=/Users/jakob/Projekte/GUI-Test/build/web&name=GUI-Test&force=true auf GlassFish Server 3.x fehlgeschlagen
Fehler bei der Bereitstellung: Exception while loading the app : duplicate method: writeReplace in org.ba.thueringen.guitest.controller.org$jboss$weld$bean-web-NewSessionBean-FirmaSessionBean_$$_WeldProxy. Weitere Informationen finden Sie unter server.log.
/Users/jakob/Projekte/GUI-Test/nbproject/build-impl.xml:786:
The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor501.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
ERSTELLEN FEHLGESCHLAGEN (Gesamtzeit: 0 Minuten 11 Sekunden)
… also setTransactionsHandledByProvider(false); throws an Exception … so i commented it out and get duplicate method: writeReplace
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.ba.thueringen.guitest.controller;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.ba.thueringen.guitest.model.Firma;
/**
*
* @author jakob
*/
@Stateless
@TransactionManagement
public class FirmaSessionBean extends MutableLocalEntityProvider<Firma> {
@PersistenceContext
private EntityManager entityManager;
private JPAContainer<Firma> firmen;
public FirmaSessionBean() {
super(Firma.class);
//setTransactionsHandledByProvider(false);
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public Firma updateEntity(Firma entity) {
return super.updateEntity(entity);
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public Firma addEntity(Firma entity) {
return super.addEntity(entity);
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void removeEntity(Object entityId) {
super.removeEntity(entityId);
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void updateEntityProperty(Object entityId,
String propertyName, Object propertyValue)
throws IllegalArgumentException {
super.updateEntityProperty(entityId, propertyName,
propertyValue);
}
@PostConstruct
public void init() {
setEntityManager(entityManager);
/*
* The entity manager is transaction scoped, which means that
* the entities will be automatically detached when the
* transaction is closed. Therefore, we do not need to
* explicitly detach them.
*/
setEntitiesDetached(false);
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
public JPAContainer<Firma> getFirmen() {
firmen = JPAContainerFactory.make(Firma.class, entityManager);
firmen.setEntityProvider(this);
return firmen;
}
}
Hi,
You could also check out the more recent blog entry to see how you can get rid of the EJB altogether.