Jpa trouble

hello
can anyone help me with this problem
atm i'm making a project which uses EJBs (with JPA) and some fields in the EJBs get auto generated when persisting an EJB entity to the database
Writing to the database and reading out of it works perfectly, but when i persist a brand new entity to the table, i don't receive the brand new generated ID
(ID is a primary key in the table)
is there any way to update the persisted entity right after persisting it to the database ? so that my entity, which got persisted, gets his ID injected?
this is my code for inserting a new entity into the database:
@Transactional
public class JPAScenarioDAO implements ScenarioDAO{
    private EntityManager entityManager;
     * Spring injects entityManager
     * @param entityManager manager that handles persistence operations
    @PersistenceContext
    public void setEntityManager(EntityManager entityManager)
      this.entityManager = entityManager;
    public JPAScenarioDAO() {}
    public void createScenario(Scenario scenario){
        entityManager.persist(scenario); // <-- help?
    public void updateScenario(Scenario scenario){
        entityManager.merge(scenario);
    public void removeScenario(Scenario scenario){
        entityManager.remove(scenario);
}The scenario is an EJB that i generated from a table
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@NamedQueries({
    @NamedQuery(name = "Scenario.getScenarios",
                query = "select o from Scenario o"),
    @NamedQuery(name = "Scenario.getScenariosBetweenDates",
                query = "select o from Scenario o where o.date >= :datum1 and o.date <= :datum2"),
    @NamedQuery(name = "Scenario.getScenariosByEdition",
                query = "select o from Scenario o where o.edition = :edition"),
    @NamedQuery(name = "Scenario.getScenariosByIssue",
                query = "select o from Scenario o where o.issue = :issue"),
    @NamedQuery(name = "Scenario.getLast2ScenariosFromEdition",
                query = "select o from Scenario o where o.edition = :edition order by o.date desc")
@Table(name = "WEBE_MAKR_DRAAIBOEK")
public class Scenario implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="s_webe_makr_draaiboek")
    @Column(name="DRAAIBOEK_ID", nullable = false)
    private Long scenarioID;
    @Column(name="JAAR")
    private Long year;
    @Column(name="WEEK")
    private Long week;
    @Column(name="DATUM")
    private Timestamp date;
    @ManyToOne
    @JoinColumn(name = "EDITIE_ID", referencedColumnName = "EDITIE_ID")
    private Edition edition;
    @OneToMany(mappedBy = "scenario")
    private List<ScenarioItemStatus> scenarioItemStatusList;
    @ManyToOne
    @JoinColumn(name = "VERSCHIJNING_ID", referencedColumnName = "VERSCHIJNING_ID")
    private Issue issue;
    @OneToMany(mappedBy = "scenario")
    private List<ScenarioHistory> scenarioHistoryList;
    // CONSTRUCTOR
    public Scenario() {}
    // GETTERS
    public Long getScenarioID() {
        return scenarioID;
    public Long getYear() {
        return year;
    public Long getWeek() {
        return week;
    public Timestamp getDate() {
        return date;
    public Edition getEdition() {
        return edition;
    public Issue getIssue() {
        return issue;
    public List<ScenarioItemStatus> getScenarioItemStatusList() {
        return scenarioItemStatusList;
    public List<ScenarioHistory> getScenarioHistoryList() {
        return scenarioHistoryList;
    // SETTERS
    public void setScenarioID(Long scenarioID) {
        this.scenarioID = scenarioID;
    public void setDate(Timestamp date) {
        this.date = date;
    public void setYear(Long year) {
        this.year = year;
    public void setWeek(Long week) {
        this.week = week;
    public void setEdition(Edition edition) {
        this.edition = edition;
    public void setIssue(Issue issue) {
        this.issue = issue;
    public void setScenarioItemStatusList(List<ScenarioItemStatus> scenarioItemStatusList) {
        this.scenarioItemStatusList = scenarioItemStatusList;
    public void setScenarioHistoryList(List<ScenarioHistory> scenarioHistoryList) {
        this.scenarioHistoryList = scenarioHistoryList;
    // EXTRA METHODS
    public ScenarioItemStatus addScenarioItemStatus(ScenarioItemStatus scenarioItemStatus) {
        getScenarioItemStatusList().add(scenarioItemStatus);
        scenarioItemStatus.setScenario(this);
        return scenarioItemStatus;
    public ScenarioItemStatus removeScenarioItemStatus(ScenarioItemStatus scenarioItemStatus) {
        getScenarioItemStatusList().remove(scenarioItemStatus);
        scenarioItemStatus.setScenario(null);
        return scenarioItemStatus;
    public ScenarioHistory addScenarioHistory(ScenarioHistory scenarioHistory) {
        getScenarioHistoryList().add(scenarioHistory);
        scenarioHistory.setScenario(this);
        return scenarioHistory;
    public ScenarioHistory removeScenarioHistory(ScenarioHistory scenarioHistory) {
        getScenarioHistoryList().remove(scenarioHistory);
        scenarioHistory.setScenario(null);
        return scenarioHistory;
}Edited by: NeoSniperkiller on 17-apr-2008 14:44

public void createScenario(Scenario scenario){
        entityManager.persist(scenario); // <-- help?
    }I've seen this happen.
Changing it to
public Scenario createScenario(Scenario scenario){
        entityManager.persist(scenario); // <-- help?
        return scenario;
    }(and using the returned value) for some reason worked.
Not quite sure yet why, I'll have to do some research to figure out exactly what happens.

Similar Messages

  • JPA: trouble removing a 1:M cascade ALL relationship from entity

    I have an entity A, with a OneToMany relationship to entity B, and cascade set to ALL.  Entity B has a ManyToOne relationship to A.  In my scenario I create a new instance of B to a detached instance of A, and I add it to the 1:M of A and set the M:1 on B.
    Then I'd like to merge the changes on A using EntityManager.merge(A).  However, before I do that I need to remove a different (old) instance of B from A, and then merge my changes so that my new instance of B is persisted.
    I've tried a couple different scenarios and get different results (none favorable):
    1.  First lookup the instance of B I want to remove via EntityManager.find(id), and then call EM.remove(B).  And then I call EM.merge(A) on the instance of A with my new B.  I get the following IllegalArgumentException during the merge:
    java.lang.IllegalArgumentException: Cannot fulfill merge operation: Relationship >>outputElementInstances<< of the target entity {com.sap.eventus.wire.entity.EvtWireInstance(id=85e83543-45d1-49cd-bb90-8688699ca0d4)} has been modified
    The relationship it's talking about is actually a different (but related) one that was affected when the old instance of B was removed.  It seems reasonable that JPA has determined that my instance of A with the new B is no longer in sync with the database and is complaining that a relationship has been changed.
    Any ways around that?
    2. I also tried simply removing B from A's 1:M, and setting B's M:1 to null, and then merging in hopes that would trigger a delete on the old B.  However the old B is not removed.
    I was expecting this to trigger a delete, however, I realize that there are other relationships from B to other objects (such as a 1:M cascade ALL) that I did not remove which I suspect might cause JPA to not delete the old B.  Is this true?
    3. And finally I tried 1 & 2 together, first calling EM.remove(old B), and then removing the old B from A and then merging, which yields the following IllegalStateException:
    java.lang.IllegalStateException: Relationship >>wireInstance<< of entity {com.sap.eventus.wire.entity.EvtElementInstance(id=08ca6253-1385-45dd-9173-978ee298b55f)} contains the new entity {com.sap.eventus.wire.entity.EvtWireInstance(id=c9fbd4e7-5575-4cc9-9b7d-2a8549c43574)}
    Which is another different (but related) relationship off of object B.
    Basically, after all this, my question is: what is the correct way to remove a 1:M relationship and add a new one?  Simple enough, however I do not want to remove the old 1:M, re-query to get the new updated parent object and then add the new 1:M, as it's a fairly involved in creating and adding the new 1:M and it must be done BEFORE removing the old 1:M.
    Thanks!

    Hi Derek,
    I understand your task as follows:
    You are having three entities A, B_old and B_new. Within one transaction you want to do the following:
    - remove B_old from the database
    - remove B_old from the 1:n relationship A.bs
    - persist the B_new
    - add B_new to the 1:n relationship A.bs
    - set the n:1 relationship B_new.a to refer to A
    well, I suggest that you do this without a merge:
    - em.remove(B_old)  // you have to do this explicitly as JPA 1 does not have automatic orphan removal
    - A.bs.remove(B_old)
    - em.persist(B_new) // also, you have to make sure that the entities related to B_new are managed upon commit
    - A.bs.add(B_new)
    - B_new.a = A
    I hope this works.
    Regarding your observations:
    1. The error message is not self-explaining. We have got to improve it ;-).
    2. You have to remove the B_old explicitly as JPA 1 does not have automatic orphan removal. 
    3. This message should be self-explaining. Maybe there is one of the relationships EvtOutputElementInstance.wireInstance or EvtInputElementInstance.wireInstance still referring B_new. You'll surely find out.
    Regards,
    Adrian

  • EJB + JPA Troubles

    hello
    can anyone help me with this problem
    atm i'm making a project which uses EJBs (with JPA) and some fields in the EJBs get auto generated when persisting an EJB entity to the database
    Writing to the database and reading out of it works perfectly, but when i persist a brand new entity to the table, i don't receive the brand new generated ID
    (ID is a primary key in the table)
    is there any way to update the persisted entity right after persisting it to the database ? so that my entity, which got persisted, gets his ID injected?
    this is my code for inserting a new entity into the database:
    @Transactional
    public class JPAScenarioDAO implements ScenarioDAO{
        private EntityManager entityManager;
         * Spring injects entityManager
         * @param entityManager manager that handles persistence operations
        @PersistenceContext
        public void setEntityManager(EntityManager entityManager)
          this.entityManager = entityManager;
        public JPAScenarioDAO() {}
        public void createScenario(Scenario scenario){
            entityManager.persist(scenario); // <-- help?
        public void updateScenario(Scenario scenario){
            entityManager.merge(scenario);
        public void removeScenario(Scenario scenario){
            entityManager.remove(scenario);
    }The scenario is an EJB that i generated from a table
    import java.io.Serializable;
    import java.sql.Timestamp;
    import java.util.List;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;
    @Entity
    @NamedQueries({
        @NamedQuery(name = "Scenario.getScenarios",
                    query = "select o from Scenario o"),
        @NamedQuery(name = "Scenario.getScenariosBetweenDates",
                    query = "select o from Scenario o where o.date >= :datum1 and o.date <= :datum2"),
        @NamedQuery(name = "Scenario.getScenariosByEdition",
                    query = "select o from Scenario o where o.edition = :edition"),
        @NamedQuery(name = "Scenario.getScenariosByIssue",
                    query = "select o from Scenario o where o.issue = :issue"),
        @NamedQuery(name = "Scenario.getLast2ScenariosFromEdition",
                    query = "select o from Scenario o where o.edition = :edition order by o.date desc")
    @Table(name = "WEBE_MAKR_DRAAIBOEK")
    public class Scenario implements Serializable {
        @Id
        @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="s_webe_makr_draaiboek")
        @Column(name="DRAAIBOEK_ID", nullable = false)
        private Long scenarioID;
        @Column(name="JAAR")
        private Long year;
        @Column(name="WEEK")
        private Long week;
        @Column(name="DATUM")
        private Timestamp date;
        @ManyToOne
        @JoinColumn(name = "EDITIE_ID", referencedColumnName = "EDITIE_ID")
        private Edition edition;
        @OneToMany(mappedBy = "scenario")
        private List<ScenarioItemStatus> scenarioItemStatusList;
        @ManyToOne
        @JoinColumn(name = "VERSCHIJNING_ID", referencedColumnName = "VERSCHIJNING_ID")
        private Issue issue;
        @OneToMany(mappedBy = "scenario")
        private List<ScenarioHistory> scenarioHistoryList;
        // CONSTRUCTOR
        public Scenario() {}
        // GETTERS
        public Long getScenarioID() {
            return scenarioID;
        public Long getYear() {
            return year;
        public Long getWeek() {
            return week;
        public Timestamp getDate() {
            return date;
        public Edition getEdition() {
            return edition;
        public Issue getIssue() {
            return issue;
        public List<ScenarioItemStatus> getScenarioItemStatusList() {
            return scenarioItemStatusList;
        public List<ScenarioHistory> getScenarioHistoryList() {
            return scenarioHistoryList;
        // SETTERS
        public void setScenarioID(Long scenarioID) {
            this.scenarioID = scenarioID;
        public void setDate(Timestamp date) {
            this.date = date;
        public void setYear(Long year) {
            this.year = year;
        public void setWeek(Long week) {
            this.week = week;
        public void setEdition(Edition edition) {
            this.edition = edition;
        public void setIssue(Issue issue) {
            this.issue = issue;
        public void setScenarioItemStatusList(List<ScenarioItemStatus> scenarioItemStatusList) {
            this.scenarioItemStatusList = scenarioItemStatusList;
        public void setScenarioHistoryList(List<ScenarioHistory> scenarioHistoryList) {
            this.scenarioHistoryList = scenarioHistoryList;
        // EXTRA METHODS
        public ScenarioItemStatus addScenarioItemStatus(ScenarioItemStatus scenarioItemStatus) {
            getScenarioItemStatusList().add(scenarioItemStatus);
            scenarioItemStatus.setScenario(this);
            return scenarioItemStatus;
        public ScenarioItemStatus removeScenarioItemStatus(ScenarioItemStatus scenarioItemStatus) {
            getScenarioItemStatusList().remove(scenarioItemStatus);
            scenarioItemStatus.setScenario(null);
            return scenarioItemStatus;
        public ScenarioHistory addScenarioHistory(ScenarioHistory scenarioHistory) {
            getScenarioHistoryList().add(scenarioHistory);
            scenarioHistory.setScenario(this);
            return scenarioHistory;
        public ScenarioHistory removeScenarioHistory(ScenarioHistory scenarioHistory) {
            getScenarioHistoryList().remove(scenarioHistory);
            scenarioHistory.setScenario(null);
            return scenarioHistory;
    }Edited by: NeoSniperkiller on 17-apr-2008 14:46

    What database and JPA provider are you using? Since you are using a SEQUENCE object to generate the id, you should see it assigned after calling the persist(). Potentially you are using IDENTITY sequencing (not on Oracle), so you must first call flush() to have the id assigned.
    see,
    [http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Object.27s_id_is_not_assign_after_persist|http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Object.27s_id_is_not_assign_after_persist]
    -- James : EclipseLink

  • JPA Error:Could not get a value to be injected from the factory

    HI friends ,
    I am  trying to replicate the example JPAEXample01 using JPA in CE1 from  the blogs written by
    Sabine Heider/Adrian Görler.
    During the testing of the method create employee i am getting the following error.
    "Could not get a value to be injected from the factory."
    I tried couple of examples using the above process, still held up with same error.
    Any pointers to trouble shoot this ?
    Thanks in advance
    Chandra Dasari

    HI Isaias Cristiano Barroso,
    There are lot of enries most of them pertaining to properties set to yes or no.
    out of which therre are tow errors. the log is as follows
    Message Info: Failed (javax.management.MBeanPermission,#[:j2eeType=trace,name=EndToEndCentralMBean,],isActive,getGuidByName,getTraceLevelByName,getTraceLevelByName,importTrace,isFileExistsLocally,removeTraceFile)java.lang.reflect.InvocationTargetException
    Failed (javax.management.MBeanPermission,*,DISPLAY)java.lang.reflect.InvocationTargetException
    category: com.sap.security.core.role.PermissionData
    Location:com.sap.security.core.role.PermissionData.get(ClassLoader)
    Frankly the above log is above my understanding ,Prob it may help to you undertand my the issue
    Thanks once again

  • JPA and JSF - Problem persisting object

    Hi all.
    I'm having some trouble with JPA, persisting an object to a MySQL table.
    Let's say I have a simple bean, Message:
    package my.package
    import java.io.Serializable;
    import javax.persistence.Id;
    import javax.persistence.Entity;
    import javax.persistence.Column;
    import javax.persistence.Table;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    @Entity
    @Table(name="messages")
    public class Message implements Serializable {
         @Id
         @GeneratedValue(strategy=GenerationType.AUTO)
         private int id;
         @Column(name="message_text")
         private String message;
         @Column(name="message_author")
         private String author;
         public String getMessage() {
              return this.message;
         public void setMessage(String message) {
              this.message = message;
         public String getAuthor() {
              return this.author;
         public void setAuthor(String author) {
              this.author = author;
    }And a controller for this Message bean:
    package my.package;
    import javax.annotation.Resource;
    import javax.persistence.Query;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.PersistenceUnit;
    import javax.transaction.UserTransaction;
    public class MessageController {
         @PersistenceUnit(unitName="em1")
         private EntityManagerFactory emf;
         @Resource
         private UserTransaction utx;
         private Message message;
         public Message getMessage() {
              return this.message;
         public void setMessage(Message message) {
              this.message = message;
         public String save() {
              EntityManager em = null;
              String returnValue = "";
              try {
                   em = this.emf.createEntityManager();
                   utx.begin();
                   em.persist(this.message);
                   utx.commit();
                   returnValue = "success";
              } catch(Exception e) {
                   e.printStackTrace();
                   returnValue = "failure";
              return returnValue;
    }Relevant code from the faces-config.xml:
    <managed-bean>
         <managed-bean-name>MessageController</managed-bean-name>
         <managed-bean-class>my.package.MessageController</managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
         <managed-property>
              <property-name>message</property-name>
              <property-class>my.package.Message</property-class>
              <value>#{Message}</value>
         </managed-property>
    </managed-bean>
    <managed-bean>
         <managed-bean-name>Message</managed-bean-name>
         <managed-bean-class>my.package.Message</managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>This is my simple persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0"
         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">
        <persistence-unit name ="em1">
             <jta-data-source>jdbc/__glfish</jta-data-source>
        </persistence-unit>
    </persistence>The __glfish resource is all set up via Glassfish to point to my MySQL server, via a MySQLPool.
    Can anyone see what I'm doing wrong? The Message doesn't get added to the table in my database, and I get a NullPointerException in the method MessageController.save() on the property MessageController.message - which I have specified in the faces-config.xml. Shouldn't that be enough? What have I missed?

    Ok, I have (re-)located the problem. It's not my Message property which gets a NullPointerException - it seems like the problem is with my EntityManagerFactory instance. The PersistenceUnit don't get assigned, even though I declare it in my persistence.xml file.
    Maybe it is something wrong with my file structure?
    The .war file have this structure:
    - WEB-INF
         - classes
              - my
                   - package
                        Message.class
                        MessageController.class
         - lib
              [external jars goes here]
              - META-INF
                   persistence.xml
         faces-config.xml
         web.xml
    [*.jsp/*.xhtml goes here]Can anyone see what's wrong?

  • JPA & visual JSF problem

    Hello, everybody :),
    I'm new to Java Web Development, and I'm in big trouble, :) and I'm on the edge of despair. I'll appreciate any help.
    Here is the problem - I've been trying for hours to do something like [ this|http://www.netbeans.org/kb/60/web/web-jpa.html] tutorial example but it is not working for me!
    I've changed it a bit - I'm using MySQL, I created a few Entity classes from the database, I created controllers from them (right click -> JPA controller Classes from Entity Class). I've bounded the table (from the example) as it was said and then I tried to run the application - it started but the table was emplty and in it was written that "No items found". I 100% sure that the table in the database is not empty and there are no error messages.
    I tried to debug the application then I saw that when I go to the updateUsers() mehtod in the entity class controller and I try to get the EntityManager something crashes and I go straight to the calling SessionBean1 with NULL as a user list - can you help me?
    Something more, when I create new Web project and I create the Entity classes from the database - the one that I'm having problem with for the Persistence example, and I create JSP pages for the entity classes - (you know just right click + .....) and the CRUD application is working just fine - I don't understand what is wrong with my trial to use the Java Persistence API Within a Visual Web JSF Application?
    Thanks in advance!
    P.S. Sorry for posting this topic again - I thing is the better place to get answer.
    Edited by: GGeorgieva on Jan 1, 2009 3:40 PM

    You're right again - can you help me with finding the reason for this, I'll paste some of the server log:
    It is the database? I guess? But how could it be - I've been working with that very DB from another Web Java Application?
    So is there a RIGHT way to connect to MySQL DataBase from a JavaSE project, which we have connected to a Web Java Application?
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named aPU: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory:                     
    oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException                    
    Local Exception Stack:                     
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException                    
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader                    
    delegate: true                    
    repositories:                    
    /WEB-INF/classes/                    
    ----------> Parent Classloader:                    
    EJBClassLoader :                     
    urlSet = []                    
    doneCalled = false                     
    Parent -> java.net.URLClassLoader@f66abc                                        
    Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException                    
    Exception Description: predeploy for PersistenceUnit [aPU] failed.                    
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException                    
    Exception Description: [class classes.Person] uses a non-entity [class classes.Phone] as target entity in the relationship attribute [private java.util.Collection classes.Person.phoneCollection].                    
    "     at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)"                    
    "     at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)"                    
    "     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)"                    
    Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException                    
    Exception Description: predeploy for PersistenceUnit [aPU] failed.                    
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException                    
    Exception Description: [class classes.Person] uses a non-entity [class classes.Phone] as target entity in the relationship attribute [private java.util.Collection classes.Person.phoneCollection].                    
    "     at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:228)"                    
    "     ... 87 more"                    
    Caused by: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException                    
    Exception Description: [class classes.Person] uses a non-entity [class classes.Phone] as target entity in the relationship attribute [private java.util.Collection classes.Person.phoneCollection].                    
    "     at oracle.toplink.essentials.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1140)"                    
    "     at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwNonEntityTargetInRelationship(MetadataValidator.java:321)"                         
    "     ... 86 more"                    
    The following providers:                    
    oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider                    
    Returned null to createEntityManagerFactory.                    
    "     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)"                    
    "     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)"                    
    "     at cntrllrs.PersonJpaController.<init>(PersonJpaController.java:33)"

  • TopLink JPA join problems.

    I need a bit of help here, I hope someone can give me a few pointers...
    I've been building out an Object Relational mapping in TopLink using the bean-style interfaces. On one of my objects I have a 1:M relationship to another table, so
    One Key in T1 -> >1 Keys in T2.
    Pretty simple really. I'm doing it like this:
    @JoinTable( name=, etc. etc.)
    private Set<ObjectForTable2> variableName.
    When I call the getVariableName() method, I get back an IndirectSet (as a set) from the method as expected; however, the size of this set is either 0 or 1.
    In Table 2 I have approximately a dozen rows which correspond to the join key, and when I run the query toplink is building in my SQL shell, I get back the dozen rows. When TopLink does it, I only get to see the first row. Is there some other trick I need to use with the set returned? Right now when I call mySet.size() on the Set returned from getVariableName() I get a size of 1 or 0. (I only get 0 if I change the key to one that does not exist in table 2.)
    if I use the iterator method, such as
    for ( final Iterator i = mySet.iterator(); i.hasNext(); ) {
    ObjectForTable2 myObj = (ObjectForTable2)i.next();
    System.out.println( myObj.getXXX() );
    I still only get one result out. Help! What am I doing wrong here? Do I need to configure something to pull back more than one record from the database?
    Also, how does one use the Oracle bugtracker for this open-source product, if I don't have a service contract?
    Thanks,
    Robbie

    Exactly.
    In TopLink (and in JPA in general) you need identify the field, or combination of fields that are used to uniquely identify entities. As Doug mentioned, it is most common that these fields are the PK of the database.
    Based on your response above I assume that you had a non unique field mapped as the PK of the enitity. This could cause the trouble you are experiencing. Mapping the pk to a unique field (or combination of fields) will likely solve this problem.

  • JPA -- Don't Maintain Cache

    Hi,
    Is it possible to specify for a NamedQuery (or NamedNativeQuery) that I don't want its results to go into the cache? Something like TopLink's:
    <toplink:maintain-cache>false</toplink:maintain-cache>I have some queries which really don't need to store their results in the cache. I tried with:
    q.setHint(TopLinkQueryHints.REFRESH, HintValues.FALSE);But the results still seem to go into the cache. So, apparently TopLink Essentials puts them in the cache the first time, but simply doesn't refresh them after the subsequent database fetches.

    Thank you, James!
    The trouble is that the cast to DatabaseQuery kills the portability. If I start doing such things, there won't be any point in switching to JPA. We could just go on using TopLink.
    As for the property:
    <property name="toplink.cache.type.[[[ENTITY]]]" value="NONE"/>the trouble is that it will turn off the caching for the entire entity. Instead, I just want to turn off the cache for certain batch queries.
    I had a very similar problem with calling Stored Procedures from JPA. I was forced to do things like:
    Query q = em.createNamedQuery("some_dummy_query");
    EJBQuery eq = (EJBQuery)q;
    ValueReadQuery vrq = new ValueReadQuery();
    SQLCall c = new SQLCall("begin ####res := pkg.func(#inp); end;");
    vrq.setCall(c);
    eq.setDatabaseQuery(vrq);
    q.setParameter("res", Long.valueOf(1));
    q.setParameter("inp", Long.valueOf(2));
    Object o = q.getSingleResult();
    System.out.println(o + "    (" + o.getClass().getName() + ")");Very ugly stuff. Also, custom mappings are not available. For example, it's a pain to map an enum to a legacy database.
    I'm beginning to think that we should wait for JPA v2 before we do the switch.
    Thank you for your assistance.
    Best regards,
    Bisser

  • Need help converting SQL "OVER (PARTITION BY   )" to JPQL equivalent - JPA

    Having trouble converting this query:
    select
    sdi,
    val,
    vldtn,
    TO_CHAR(sdt, 'yyyy-mm-dd hh:mi:ss AM')
    from
    select
    sdi,
    val,
    vldtn,
    sdt,
    max(sdt) over (partition by sdi) as MaxDate1
    from
    r_ins
    ) x
    where x.sdt = x.MaxDate1
    and sdi in (1234,2345,3456,4567,5678,6789,7890);
    to JPQL equivalent using JPA
    Able to convert simple queries but I do not know how to handle the "over (partition by sdi)" portion of the query.
    Can anyone help
    TIA
    Jer

    Paul Horth wrote:
    Why have the power (and cost) of Oracle and then not use those powerful features because you are restricting yourself to a vanilla set of SQL because you are using some generic framework.You know how it is :
    1 - Application developers create code & queries but only test them on tiny database with low volume and no concurrency at all.
    2 - Application goes Live, Database grows (as expected) but stupid optimizer is not as fast as on test environment (that was mostly empty)
    3 - Queries are now 200 times slower.
    4 - Expensive DB expert comes and gathers statistics, creates indexes, rewrites queries, uses hint/outline/SQLprofile.
    Conclusion : Database is evil and prevent application from working efficiently, the proof of all that being : nothing had to be done on application's side to make things work correctly. Database is declared guilty.
    Which could translate to :
    1 - Team buy a formula one with 800HP that can reach 200mph in less than 10 seconds.
    2 - Give it a pilot that doesn't even want to understand what-the-heck is a gearbox/transmission. Pilot only drives in 1st gear.
    3 - The formula one is now doing 0.003 miles per gallon, doing the hell of a noise, and is limited to 80mph +(any $10000 family wagon is faster in average)+
    4 - Expensive expert comes and check everything in the formula one. Finally understand the problem and modify the gearbox to a sloppy automatic transmission
    Conclusion : Formula 1 is evil and prevent pilot from being fast. The proof of that being : nothing had to be changed on pilot's side to make things work correctly. Formula 1 is declared guilty.
    You cannot win race without understanding how the car/engine/transmission/physics/race rules work.
    Too much levels of abstraction is bad. Treating the database as a black box is the most seen "Bad Idea" these days (to my point of view).
    Warning: I am biased towards Oracle :-)And so am I.
    (^_^)

  • JPA/Toplink changes the query logic

    Hi,
    Iam currently using JPA with Toplink implementation , i guess that toplink has its own way of optimizing the provided JPA query ; on another words , toplink sometimes changes the way you are using joins and exists statement to what looks optimized , but unfor. this caused me troubles tracking a query that should work on a certain way but its not cause the generated query by Toplink ( can be captured on the log ) does not represent the same logic , is this a known issue or do i have to write my JPA query on a way on which can be translated correctly by toplink , i know i should provide the query it self , but the model structure is too complex.
    Thanks in advance

    Hello,
    JPQL does not directly translate to SQL, so there might be some differences in what you may be expecting due to JPA requirements on the results that are returned. If there is a problem with specific queries, please let us know and file a bug if it is not behaving the way it should. A workaround would be to use a native SQL query directly.
    Best Regards,
    Chris

  • JPA -- Best way to refresh a List association?

    Hi,
    I need to refresh a OneToMany association.
    For example, I have two entities: Header & Detail.
    @Entity
    @Table(name="HEADERS")
    public class Header implements Serializable {
        @OneToMany(mappedBy="header")
        private List<Detail> details;
    @Entity
    @Table(name="DETAILS")
    public class Detail implements Serializable {
        @ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="HDR_ID", referencedColumnName="HDR_ID")
        private Header header;
    }So, I fetch the Header along with all its Details.
    At a later point of time, I know that some Detail rows in the database have been changed behind my back. I need to re-fetch the list of Details. What should I do?
    1. I could add a cascade parameter to the @OneToMany association. I could specify:
    @OneToMany(mappedBy="header", cascade={CascadeType.REFRESH})Then I could run:
    entityManager.refresh(header);The trouble is that, since all the Details are already in the cache, the cached entities will be returned, not the ones fetched from the database. So, I won't refresh a thing. A query will be sent to the database indeed, but I will get the cached (i.e. stale) entities. I don't know of a way to specify something like
    setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE)dynamically for associations, so that the values in the cache would be replaced with the ones fetched from the database.
    2. I could try to turn off the caching for the while Entity class. The trouble is that for some reason this doesn't work (see my other question here JPA -- How can I turn off the caching for an entity? Besides, even if it worked, I don't want to turn off the caching in general. I simply want to refresh the list sometimes.
    Could anyone tell me what's the best way to refresh the association?
    Best regards,
    Bisser

    Hi Chris,
    First, let me thank you that you take the time to answer my questions. I really appreciate that. I wish to apologize for my late reply but I wasn't around the PC for a while.
    TopLink doesn't refresh an entity based on a view. I will try to explain in more detail. I hope you'll have patience with me because this might be a bit longer even than my previous post. I will oversimplify my actual business case.
    Let's assume we have two tables and a view:
    create table MASTERS
      (id number(18) not null primary key,
       master_name varchar2(50));
    create table DETAILS
      (id number(18) not null primary key,
       master_id number(18) not null,   -- FK to MASTER.ID
       price number(7,2));
    create view DETAILS_VW as
      select id, master_id, price
      from details;Of course, in real life the view is useful and actually peforms complex aggregate calculations on the details. But at the moment I wish to keep things as simple as possible.
    So, I create Entities for the tables and the view. Here are the entities for MASTERS and DETAILS_VW, only the essential stuff (w/o getters, setters, sequence info, etc.):
    @Entity
    @Table(name="MASTERS")
    public class Master {
         @Id
         @Column(name="ID", nullable=false)
         private Long id;
         @Column(name="MASTER_NAME")
         private String masterName;
         @OneToMany(mappedBy="master", fetch=FetchType.LAZY, cascade=CascadeType.REFRESH)
         private List<DetailVw> detailsVw;
    @Entity
    @Table(name="DETAILS_VW")
    public class DetailVw {
         @Id
         @Column(name="ID")
         private Long id;
         @ManyToOne(fetch=FetchType.LAZY)
         @JoinColumn(name="MASTER_ID", referencedColumnName="ID")
         private Master master;
         @Column(name="PRICE")
         private Double price;
    }So, now we have the tables and the entities. Let's assume one master row and two detail rows exist:
    MASTER:  ID=1, MASTER_NAME='Master #1'
    DETAIL:  ID=1, MASTER_ID=1, PRICE=3
    DETAIL:  ID=2, MASTER_ID=1, PRICE=8And now let's run the following code:
    // List the initial state
    Master master = em.find(Master.class, 1L);
    List<DetailVw> detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    // Modify a detail
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    Detail d = em.find(Detail.class, 2L);
    d.setPrice(1);
    tx.commit();
    // Refresh
    System.out.println("----------------------------------------");
    em.refresh(master);
    // List the state AFTER the update
    detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    }And here are some excerpts from the console (only the essentials):
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8
    UPDATE DETAILS SET PRICE = ? WHERE (ID = ?)
         bind => [1, 2]
    SELECT ID, MASTER_NAME FROM MASTERS WHERE (ID = ?)
         bind => [1]
    SELECT ID, PRICE, MASTER_ID FROM DETAILS_VW WHERE (MASTER_ID = ?)
         bind => [1]
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8You see, the UPDATE statement changes the DETAILS row. The price was 8, but was changed to 1. I checked the database. It was indeed changed to 1.
    Furthermore, due to the refresh operation, a query was run on the view. But as you can see from the console output, the results of the query were completely ignored. The price was 8, and continued to be 8 even after the refresh. I assume it was because of the cache. If I run an explicit query on DETAILS_VW with the hint:
    q.setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE);then I see the real updated values. But if I only refresh with em.refresh(master), then the DetailVw entities do not get refreshed, even though a query against the database is run. I have tested this both in JavaSE and in OC4J. The results are the same.
    An explicit refresh on a particular DetailVw entity works, though:
    DetailVw dvw = em.find(DetailVw.class, 2L);
    em.refresh(dvw);
    System.out.println(dvw);Then the console says:
    DetailVw: id=2, price=1So, the price is indeed 1, not 8.
    If you can explain that to me, I will be really thankful!
    Best regards,
    Bisser

  • Jpa joins 3 table

    Hi!
    I have problem with my jsf 2.0 using JPA on startup. At first it was all fine and when I added up an additional
    NamedQuery ("browseItemProCom") which is having a query of 3 different tables join together (inner join),
    The first time my page loads it just wont show the results, but when I do refresh or open another browser the second time around, that's the time it shows my query.
    Below are my query, the "browseItemProCom", it gives me trouble as mentioned above. I'm saying
    it's giving me trouble because when I took it off, it works fine but I needed this "browseItemProCom" for another query.
    The Query:
    @NamedQuery(name="browseItemProCom", query="SELECT DISTINCT I,P,C FROM Items AS I
    JOIN (I.props AS P JOIN I.compatibles AS C ON P.items_itemid = C.items_itemid)
    ON I.itemid = C.items_itemid WHERE I.partnum = :partnum ORDER BY P.sequence")
    the I.props is declared as
    @OneToMany(cascade=CascadeType.ALL, mappedBy="items")
    protected Collection<Properties> props = new ArrayList<Properties>();
    and the I.compatibles is declared as
    @OneToOne(cascade=CascadeType.ALL, mappedBy="items")
    protected Compatibles compatibles;
    Hope someone will give me some light on this.
    regards, nelson

    Nelson,
    this forum is about annotation processing in general and the tools that support that. Your problem is possibly related to one specific annotation processor. You will probably get a better response if you post your question in a forum about JPA.
    Bruce

  • JPA and logging entity changes

    Good day!
    I need to log all entity property changes in scope of current transaction in j2ee application. I use Glassfish and JPA. Is there any way to do this?

    Filippo Tenaglia wrote:
    Hi all,
    I have a "simple" question:
    Should I create a class to manage entity manager and entity manager factory on JPA2?That question is far from complete, as the answer to this one is "depends on what you want to do!"
    Why do I ask that? Because I read on J2EE tutorial:
    With a container-managed entity manager, an EntityManager instance’s persistence context is automatically propagated by the container to all application components that use the EntityManager instance within a single Java Transaction Architecture (JTA) transaction.
    To obtain an EntityManager instance, inject the entity manager into the application component:
    @PersistenceContext
    EntityManager em;
    Given this information...
    I'm using JSF2, JPA2, JTA and Glassfish3.1 on the NetBeans 7.0.1.That answer to your question is "NO", because you have a container available to you that can do the work (Glassfish). It makes no sense using Glassfish and then purposely ignoring the features it has to offer.
    Lets get back to basics: you are doing something wrong here. You have to figure out what, you can only do that if you keep studying and getting a more complete understanding. If you are having trouble realizing that, perhaps you should start over without the help of any wizard at all; wizards are only useful when you are already experienced, right now the fact that code is generated is hindering you a lot because you will have a strong impulse to believe there can be no mistake; unfortunately there is no such safety net. The fact that you used the word "weird" is enough proof of this by the way. There is nothing weird here, just a mistake being made that has to be corrected.
    And for the future: what IDE (Netbeans in your case) you use to develop really makes absolutely no difference at all. What is more interesting is which version of Java your are using, which can likely be Java 6 or Java 7 nowadays.

  • Using an Oracle SQL Function from JPA/TopLink

    How do I get the return value from a simple (one string input parameter, returns a string) Oracle SQL Function?
    Thanks!

    If you mean calling a stored function in Oracle, you might try something like:
        ValueReadQuery vrq = new ValueReadQuery();
        SQLCall call = new SQLCall("begin ###res := pkg.funcInp(#inp); end;");
        vrq.setCall(call);
        Query q = em.createNativeQuery("");   // we need a Query; any query would do; we replace its contents below
        ((EJBQuery)q).setDatabaseQuery(vrq);
        q.setParameter("inp", "paramValue");
        String result = (String)q.getSingleResult();
        // #=input; ###=output; ####=input/output;
        // if you want to explicitly specify the type of an output parameter, use #### instead of ###,
        // because pure "output" parameters are always treated as java.lang.StringThis will only work in TopLink Essentials, though. I don't know how to do it in Hibernate. I have dealt mainly with TopLink, and just a little with Hibernate.
    In my opinion, it's a HUGE omission not to have support for stored procedures in JPA. Virtually every project I have worked on (in two large companies) has consisted of a large portion of code in stored procedures (sometimes as much as 50% of the overall code). It's a pain to have to go through all that trouble to call the stored procedures.
    Also, pay special attention to TopLink's shared L2 cache. If a stored procedure changes something in the database, TopLink won't know about it and chances are that you will end up with stale objects in the cache which you will either have to refresh, or you'd have to invalidate TopLink's cache for these objects.
    Best regards,
    Bisser

  • Project deployment troubles in Glassfish v3 preview

    Hi all!
    I've just started to use enterprise technologies and got trouble with deploying the java ee sample in Glassfish v3 preview server. Please, write what I'm doing wrong. Everything is ok, when I deploy a web application, but an enterprise application deployment fails.
    Here are the logs:
    [#|2009-09-12T11:19:27.718+0500|INFO|glassfish|null|_ThreadID=11;_ThreadName=Thread-1;|The Admin Console is already installed, but not yet loaded.|#]
    [#|2009-09-12T11:19:27.750+0500|INFO|glassfish|javax.enterprise.system.tools.admin.org.glassfish.server|_ThreadID=13;_ThreadName=Thread-1;|Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://ni-comp:32878/jmxrmi|#]
    [#|2009-09-12T11:19:27.750+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=11;_ThreadName=Thread-1;org.glassfish.deployment.common [45];|Started bundle org.glassfish.deployment.common [45]|#]
    [#|2009-09-12T11:19:28.703+0500|INFO|glassfish|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=11;_ThreadName=Thread-1;|GlassFish v3  startup time : Felix(2172ms) startup services(2985ms) total(5157ms)|#]
    [#|2009-09-12T11:19:28.718+0500|INFO|glassfish|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=14;_ThreadName=Thread-1;Thread[GlassFish Kernel Main Thread,5,main];|[Thread[GlassFish Kernel Main Thread,5,main]] started|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.poll  (ms)   5000|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.dir            F:\glassfishv3\glassfish\domains\vajvajvaj\autodeploy-bundles|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.debug          1|#]
    [#|2009-09-12T11:19:29.656+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.bundles.new.start          true|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=16;_ThreadName=Thread-1;org.glassfish.admin.monitoring-core [116];|Started bundle org.glassfish.admin.monitoring-core [116]|#]
    [#|2009-09-12T11:19:30.062+0500|INFO|glassfish|null|_ThreadID=17;_ThreadName=Thread-1;|Listening on port 32872|#]
    [#|2009-09-12T11:19:35.718+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=16;_ThreadName=Thread-1;org.glassfish.deployment.admin [42];|Started bundle org.glassfish.deployment.admin [42]|#]
    [#|2009-09-12T11:19:53.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.ejb.gf-ejb-connector [55];|Started bundle org.glassfish.ejb.gf-ejb-connector [55]|#]
    [#|2009-09-12T11:19:53.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.gf-web-connector [57];|Started bundle org.glassfish.web.gf-web-connector [57]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.beans-integration [149];|Started bundle org.glassfish.web.beans-integration [149]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.security [135];|Started bundle org.glassfish.security [135]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.persistence.jpa-connector [101];|Started bundle org.glassfish.persistence.jpa-connector [101]|#]
    [#|2009-09-12T11:19:53.671+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.connectors.gf-connectors-connector [54];|Started bundle org.glassfish.connectors.gf-connectors-connector [54]|#]
    [#|2009-09-12T11:19:54.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.scripting.gf-jruby-connector [56];|Started bundle org.glassfish.scripting.gf-jruby-connector [56]|#]
    [#|2009-09-12T11:19:54.640+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.extras.osgi-container [129];|Started bundle org.glassfish.extras.osgi-container [129]|#]
    [#|2009-09-12T11:19:54.640+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.extras.grizzly-container [72];|Started bundle org.glassfish.extras.grizzly-container [72]|#]
    [#|2009-09-12T11:19:54.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.war-util [142];|Started bundle org.glassfish.web.war-util [142]|#]
    [#|2009-09-12T11:19:54.671+0500|SEVERE|glassfish|javax.enterprise.system.tools.admin.org.glassfish.server|_ThreadID=18;_ThreadName=Thread-1;|Error during deployment : no container associated with application of type : ear
    java.lang.RuntimeException: no container associated with application of type : ear
         at com.sun.enterprise.glassfish.web.WarHandler.handles(WarHandler.java:89)
         at com.sun.enterprise.v3.server.ApplicationLifecycle.getArchiveHandler(ApplicationLifecycle.java:163)
         at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:174)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:419)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:137)
         at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:313)
         at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:180)
         at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:165)
         at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
         at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:208)
         at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:746)
         at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:655)
         at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:905)
         at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:161)
         at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
         at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
         at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
         at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
         at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
         at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
         at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
         at java.lang.Thread.run(Thread.java:619)

    Hi all!
    I've just started to use enterprise technologies and got trouble with deploying the java ee sample in Glassfish v3 preview server. Please, write what I'm doing wrong. Everything is ok, when I deploy a web application, but an enterprise application deployment fails.
    Here are the logs:
    [#|2009-09-12T11:19:27.718+0500|INFO|glassfish|null|_ThreadID=11;_ThreadName=Thread-1;|The Admin Console is already installed, but not yet loaded.|#]
    [#|2009-09-12T11:19:27.750+0500|INFO|glassfish|javax.enterprise.system.tools.admin.org.glassfish.server|_ThreadID=13;_ThreadName=Thread-1;|Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://ni-comp:32878/jmxrmi|#]
    [#|2009-09-12T11:19:27.750+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=11;_ThreadName=Thread-1;org.glassfish.deployment.common [45];|Started bundle org.glassfish.deployment.common [45]|#]
    [#|2009-09-12T11:19:28.703+0500|INFO|glassfish|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=11;_ThreadName=Thread-1;|GlassFish v3  startup time : Felix(2172ms) startup services(2985ms) total(5157ms)|#]
    [#|2009-09-12T11:19:28.718+0500|INFO|glassfish|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=14;_ThreadName=Thread-1;Thread[GlassFish Kernel Main Thread,5,main];|[Thread[GlassFish Kernel Main Thread,5,main]] started|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.poll  (ms)   5000|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.dir            F:\glassfishv3\glassfish\domains\vajvajvaj\autodeploy-bundles|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.debug          1|#]
    [#|2009-09-12T11:19:29.656+0500|INFO|glassfish|null|_ThreadID=15;_ThreadName=Thread-1;|felix.fileinstall.bundles.new.start          true|#]
    [#|2009-09-12T11:19:28.734+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=16;_ThreadName=Thread-1;org.glassfish.admin.monitoring-core [116];|Started bundle org.glassfish.admin.monitoring-core [116]|#]
    [#|2009-09-12T11:19:30.062+0500|INFO|glassfish|null|_ThreadID=17;_ThreadName=Thread-1;|Listening on port 32872|#]
    [#|2009-09-12T11:19:35.718+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=16;_ThreadName=Thread-1;org.glassfish.deployment.admin [42];|Started bundle org.glassfish.deployment.admin [42]|#]
    [#|2009-09-12T11:19:53.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.ejb.gf-ejb-connector [55];|Started bundle org.glassfish.ejb.gf-ejb-connector [55]|#]
    [#|2009-09-12T11:19:53.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.gf-web-connector [57];|Started bundle org.glassfish.web.gf-web-connector [57]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.beans-integration [149];|Started bundle org.glassfish.web.beans-integration [149]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.security [135];|Started bundle org.glassfish.security [135]|#]
    [#|2009-09-12T11:19:53.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.persistence.jpa-connector [101];|Started bundle org.glassfish.persistence.jpa-connector [101]|#]
    [#|2009-09-12T11:19:53.671+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.connectors.gf-connectors-connector [54];|Started bundle org.glassfish.connectors.gf-connectors-connector [54]|#]
    [#|2009-09-12T11:19:54.625+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.scripting.gf-jruby-connector [56];|Started bundle org.glassfish.scripting.gf-jruby-connector [56]|#]
    [#|2009-09-12T11:19:54.640+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.extras.osgi-container [129];|Started bundle org.glassfish.extras.osgi-container [129]|#]
    [#|2009-09-12T11:19:54.640+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.extras.grizzly-container [72];|Started bundle org.glassfish.extras.grizzly-container [72]|#]
    [#|2009-09-12T11:19:54.656+0500|INFO|glassfish|org.jvnet.hk2.osgiadapter|_ThreadID=18;_ThreadName=Thread-1;org.glassfish.web.war-util [142];|Started bundle org.glassfish.web.war-util [142]|#]
    [#|2009-09-12T11:19:54.671+0500|SEVERE|glassfish|javax.enterprise.system.tools.admin.org.glassfish.server|_ThreadID=18;_ThreadName=Thread-1;|Error during deployment : no container associated with application of type : ear
    java.lang.RuntimeException: no container associated with application of type : ear
         at com.sun.enterprise.glassfish.web.WarHandler.handles(WarHandler.java:89)
         at com.sun.enterprise.v3.server.ApplicationLifecycle.getArchiveHandler(ApplicationLifecycle.java:163)
         at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:174)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:419)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:137)
         at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:313)
         at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:180)
         at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:165)
         at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
         at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:208)
         at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:746)
         at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:655)
         at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:905)
         at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:161)
         at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
         at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
         at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
         at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
         at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
         at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
         at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
         at java.lang.Thread.run(Thread.java:619)

Maybe you are looking for

  • My iMessage is not holding checked my phone number box in preferences

    I was using imessage perfectly. But I had to change my apple ID password and now, everytime I login in my macbook, imessage is not working, because there is no box checked, nor email address, nor my iPhone number, the one that I used to use. Now, if

  • How to find the count of tables going for fts(full table scan in oracle 10g

    HI how to find the count of tables going for fts(full table scan) in oracle 10g regards

  • J2EE engine does not start correctly

    hi, after the installation of sap was v6.40 abap & j2ee, i cannot logon to the j2ee engine as described in the documentation. when i will access the engine by using a web browser, i get the following error message: "503: Service Unavailable" i had a

  • Spry textfield validation

    Hi, how can I modify this code for the spry textfield validation.js file? My text field is set to yyyy-mm-dd.  When I enter a date and hit the submit button all works well but, how can I modify this portion of the .js file so the date yyyy-mm-dd is n

  • About LOCALhost:8080

    i was using tomcat , wen i use localhost:8080 , i use to get into web_inf (TOMCAT MANAGER)in tomcat, now i installed oracle 9i but wen i use localhost:8080 i couldnt get into the previous web_inf what should i do how to change the settings