No service implements the interface java.util.Date.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

No service implements the interface java.util.Date.

Andreas Ernst
Hi,

i got this error, and have to glue how to fix it. Because i got serveral
other T5 apps with Timestamp without this issue.

Information:   [ERROR] ioc.Registry No service implements the interface
java.util.Date.
Information:   [ERROR] ioc.Registry Operations trace:
Information:   [ERROR] ioc.Registry [ 1] Handling traditional 'action'
component event request for Tank:tankform.form.
Information:   [ERROR] ioc.Registry [ 2] Triggering event 'action' on
Tank:tankform.form
Information:   [ERROR] ioc.Registry [ 3] Instantiating new instance of
de.aeits.erda.ccis.mariadb.Tanken
Information:   [ERROR] ioc.Registry [ 4] Creating plan to instantiate
de.aeits.erda.ccis.mariadb.Tanken via public
de.aeits.erda.ccis.mariadb.Tanken(java.util.Date,int,int,java.lang.String,int,int)
Information:   [ERROR] ioc.Registry [ 5] Determining injection value for
parameter #1 (java.util.Date)
Information:   [ERROR] ioc.Registry [ 6] Resolving object of type
java.util.Date using MasterObjectProvider
Information:   [ERROR] TapestryModule.RequestExceptionHandler Processing
of request failed with uncaught exception:
org.apache.tapestry5.runtime.ComponentEventException: Exception
instantiating instance of de.aeits.erda.ccis.mariadb.Tanken (for
component 'Tank:tankform.editor'):
org.apache.tapestry5.ioc.internal.OperationException: No service
implements the interface java.util.Date. [at
classpath:org/apache/tapestry5/corelib/components/BeanEditForm.tml, line 2]
org.apache.tapestry5.runtime.ComponentEventException: Exception
instantiating instance of de.aeits.erda.ccis.mariadb.Tanken (for
component 'Tank:tankform.editor'):
org.apache.tapestry5.ioc.internal.OperationException: No service
implements the interface java.util.Date. [at
classpath:org/apache/tapestry5/corelib/components/BeanEditForm.tml, line 2]
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1126)



package de.aeits.ccis.pages;

import de.aeits.ccis.components.Layout;
import de.aeits.erda.ccis.mariadb.Tanken;
import de.aeits.erda.ccis.mssql.Adresse;
import de.aeits.erda.ccis.mssql.AuftragFahrzeug;
import de.aeits.erda.ccis.mssql.Fahrzeug;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.corelib.components.BeanEditForm;
import org.apache.tapestry5.jpa.annotations.CommitAfter;
import org.apache.tapestry5.services.BeanModelSource;
import org.slf4j.Logger;

/**
  *
  * @author andreas
  */
@RequiresAuthentication
public class Tank {


   @PersistenceContext(unitName = "de.aeits_ERDA-CCIS-EJB_ejb_1.01PU")
   private EntityManager entityManager;
   @PersistenceContext(unitName = "de.aeits_ERDA-CCIS-EJB_ejb_1.0PU")
   private EntityManager entityManagerMS;
   private Query query;

   @Component(id = "tankForm")
   private BeanEditForm tankForm;
   @InjectPage
   private Tank indexPage;

   @Property
   private Tanken tanken;

   @Property
   private Fahrzeug fahrzeug;

   private Adresse adresse;

   @Property
   private String email, fahrer;

   @Property
   @Persist
   String selectedValue;//= "UTA";
   @Property
   @Persist
   String fahrzeugValue;// = "WWFD9988";

   private final Locale locale = Locale.getDefault();
   private Calendar jetzt = Calendar.getInstance(locale);
   @Property
   private Date datzeit = new Date();

   @Property
   List<String> fahrzeuge;

   @Log
   void setupRender() throws Exception {
     jetzt = Calendar.getInstance();
     try {
       adresse = entityManagerMS.find(Adresse.class,
Layout.getAdresse().getIDAdresse());
       query = entityManagerMS.createNamedQuery("Fahrzeug.findByEigene");
       List<Fahrzeug> fahrzeugListe = query.getResultList();
       fahrzeuge = new ArrayList();
       for (Fahrzeug fahrzeug1 : fahrzeugListe) {
         fahrzeuge.add(fahrzeug1.getKennzeichen());
       }
adresse.getIDAdresse().intValue());
       tanken = new Tanken(datzeit, 1, 1, "UTA", 600, 109585);
       fahrer = adresse.getSuchName();
       query =
entityManagerMS.createNamedQuery("AuftragFahrzeug.findByFahrer");
       query.setParameter("iDFahrer", adresse.getIDAdresse());
       query.setParameter("datzeit", jetzt.getTime());
       List<AuftragFahrzeug> auftragFahrzeug = query.getResultList();
       for (AuftragFahrzeug at : auftragFahrzeug) {
         if (String.valueOf(at.getIDAuftragFS().getStatus()).equals("F")
| String.valueOf(at.getIDAuftragFS().getStatus()).equals("R")) {
         }
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
     selectedValue = "UTA";
   }

   @Log
   @CommitAfter
   @PersistenceContext(unitName = "de.aeits_ERDA-CCIS-EJB_ejb_1.01PU")
   void onValidateFromTankForm() {
     try {
       query =
entityManagerMS.createNamedQuery("Fahrzeug.findByKennzeichen");
       query.setParameter("kennzeichen", fahrzeug);
       int fahrzeug_nr = (int) query.getSingleResult();
       tanken.setFahrzeug(fahrzeug_nr);
       entityManager.persist(tanken);
     } catch (Exception e) {
       tankForm.recordError("Der Tankvorgang konnte nicht gespeichert!");
     }
   }

   Object onSuccess() {
     return indexPage;
   }

   public String getDateFieldFormat() {
     return "dd.MM.yyyy hh:mm:ss";
   }
}




<html t:type="layout" title="${message:title} - Tanken"
       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
       xmlns:p="tapestry:parameter">

   <h1>ERDA CCIS - Tanken - ${fahrer}</h1>
   <!--<t:form t:id="tankForm" object="tanken" t:model="model"
submitLabel="speichern">-->
   <t:form t:id="tankForm" object="tanken" submitLabel="speichern">
     <t:errors/>
     <p:datzeit>
        <t:label for="datzeit">Datum/Uhrzeit</t:label>
        <input t:id="datzeit" t:type="datefield" value="datzeit"
t:context="tanken.datzeit" t:format="prop:dateFieldFormat"/>
     </p:datzeit>
     <p:fahrzeug>
        <t:label for="fahrzeug">Fahrzeug</t:label>
        <t:Select t:id="fahrzeug" t:context="fahrzeug.kennzeichen"
model="fahrzeuge" t:value="fahrzeugValue"/>
     </p:fahrzeug>
     <p:tankkarte>
        <t:label for="tankkarte">Tankkarte</t:label>
        <t:Select t:id="tankkarte" t:model="literal:UTA, AS24, DTS,
ESSO, BAR" t:value="selectedValue"/>
     </p:tankkarte>
   </t:form>
   <br/>
</html>





package de.aeits.erda.ccis.mariadb;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
  *
  * @author andreas
  */
@Entity
@Table(name = "tanken")
@XmlRootElement
@NamedQueries({
   @NamedQuery(name = "Tanken.findAll", query = "SELECT t FROM Tanken t"),
   @NamedQuery(name = "Tanken.findByDatzeit", query = "SELECT t FROM
Tanken t WHERE t.datzeit = :datzeit"),
   @NamedQuery(name = "Tanken.findByFahrer", query = "SELECT t FROM
Tanken t WHERE t.fahrer = :fahrer"),
   @NamedQuery(name = "Tanken.findByFahrzeug", query = "SELECT t FROM
Tanken t WHERE t.fahrzeug = :fahrzeug"),
   @NamedQuery(name = "Tanken.findByTankkarte", query = "SELECT t FROM
Tanken t WHERE t.tankkarte = :tankkarte"),
   @NamedQuery(name = "Tanken.findByLiter", query = "SELECT t FROM
Tanken t WHERE t.liter = :liter"),
   @NamedQuery(name = "Tanken.findByKilometer", query = "SELECT t FROM
Tanken t WHERE t.kilometer = :kilometer")})
public class Tanken implements Serializable {

   private static final long serialVersionUID = 1L;
   @Id
   @Basic(optional = false)
   @NotNull
   @Column(name = "datzeit")
   @Temporal(TemporalType.TIMESTAMP)
   private Date datzeit;
   @Basic(optional = false)
   @NotNull
   @Column(name = "fahrer")
   private int fahrer;
   @Basic(optional = false)
   @NotNull
   @Column(name = "fahrzeug")
   private int fahrzeug;
   @Basic(optional = false)
   @NotNull
   @Size(min = 1, max = 10)
   @Column(name = "tankkarte")
   private String tankkarte;
   @Basic(optional = false)
   @NotNull
   @Column(name = "liter")
   private int liter;
   @Basic(optional = false)
   @NotNull
   @Column(name = "kilometer")
   private int kilometer;

   public Tanken() {
   }

   public Tanken(Date datzeit) {
     this.datzeit = datzeit;
   }

   public Tanken(Date datzeit, int fahrer, int fahrzeug, String
tankkarte, int liter, int kilometer) {
     this.datzeit = datzeit;
     this.fahrer = fahrer;
     this.fahrzeug = fahrzeug;
     this.tankkarte = tankkarte;
     this.liter = liter;
     this.kilometer = kilometer;
   }

   public Date getDatzeit() {
     return datzeit;
   }

   public void setDatzeit(Date datzeit) {
     this.datzeit = datzeit;
   }

   public int getFahrer() {
     return fahrer;
   }

   public void setFahrer(int fahrer) {
     this.fahrer = fahrer;
   }

   public int getFahrzeug() {
     return fahrzeug;
   }

   public void setFahrzeug(int fahrzeug) {
     this.fahrzeug = fahrzeug;
   }

   public String getTankkarte() {
     return tankkarte;
   }

   public void setTankkarte(String tankkarte) {
     this.tankkarte = tankkarte;
   }

   public int getLiter() {
     return liter;
   }

   public void setLiter(int liter) {
     this.liter = liter;
   }

   public int getKilometer() {
     return kilometer;
   }

   public void setKilometer(int kilometer) {
     this.kilometer = kilometer;
   }

   @Override
   public int hashCode() {
     int hash = 0;
     hash += (datzeit != null ? datzeit.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 Tanken)) {
       return false;
     }
     Tanken other = (Tanken) object;
     if ((this.datzeit == null && other.datzeit != null) ||
(this.datzeit != null && !this.datzeit.equals(other.datzeit))) {
       return false;
     }
     return true;
   }

   @Override
   public String toString() {
     return "de.aeits.erda.ccis.mariadb.Tanken[ datzeit=" + datzeit + " ]";
   }
}


Do i need a ValueEncoder Class for the timestamp?

Thanks
Andy
--
ae | Andreas Ernst | IT Spektrum
Postfach 5, 65612 Beselich
Schupbacher Str. 32, 65614 Beselich, Germany
Tel: +49-6484-91002 Fax: +49-6484-91003
[hidden email] | www.ae-online.de
www.tachyon-online.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: No service implements the interface java.util.Date.

Thiago H de Paula Figueiredo
On Tue, 05 Jan 2016 09:03:59 -0200, Andreas Ernst <[hidden email]> wrote:

> Hi,

Hi!

"No service implements the interface XXX" means you're trying to inject a  
dependency of type XXX in some service or object created by  
ObjectLocator/Registry.autobuild(). The class you're editing in  
BeanEditForm, Tanken, probably has constructors other than a no-arg one  
and you're leaving the instantiation of Tanken to BeanEditForm/BeanEditor,  
which does that by calling ObjectLocator.autobuild(), which takes the  
constructor with the longest list of parameters then considers them as  
dependencies (services) to inject.

Here's my proposed fix: instantiate the object yourself in your page:

void onPrepare() {
        if (tanken == null) {
                tanken = new Tanken();
        }
}

The 'prepare' event is triggered just before a Form is rendered  
(BeanEditForm uses this component internally) and also just before a form  
submission is handled, triggering the 'validate', 'success' and 'failure'  
events as needed.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: No service implements the interface java.util.Date.

Andreas Ernst
Am 05.01.16 um 14:14 schrieb Thiago H de Paula Figueiredo:

> On Tue, 05 Jan 2016 09:03:59 -0200, Andreas Ernst <[hidden email]> wrote:
>
>> Hi,
>
> Hi!
>
> "No service implements the interface XXX" means you're trying to inject
> a dependency of type XXX in some service or object created by
> ObjectLocator/Registry.autobuild(). The class you're editing in
> BeanEditForm, Tanken, probably has constructors other than a no-arg one
> and you're leaving the instantiation of Tanken to
> BeanEditForm/BeanEditor, which does that by calling
> ObjectLocator.autobuild(), which takes the constructor with the longest
> list of parameters then considers them as dependencies (services) to
> inject.
>
> Here's my proposed fix: instantiate the object yourself in your page:
>
> void onPrepare() {
>      if (tanken == null) {
>          tanken = new Tanken();
>      }
> }
>
> The 'prepare' event is triggered just before a Form is rendered
> (BeanEditForm uses this component internally) and also just before a
> form submission is handled, triggering the 'validate', 'success' and
> 'failure' events as needed.
>

You saved my day. I think, i never would find to change setupRender to
onPrepare. The other T5 project got onPrepare ...

Thanks a lot!

--
ae | Andreas Ernst | IT Spektrum
Postfach 5, 65612 Beselich
Schupbacher Str. 32, 65614 Beselich, Germany
Tel: +49-6484-91002 Fax: +49-6484-91003
[hidden email] | www.ae-online.de
www.tachyon-online.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]