私はJ2EE EJB JSFに基づいてプロジェクトを開発しています。データベースはMYsqlで、プロジェクトは先週非常にうまく機能しています。しかし、今日は実行してもデプロイできません。ここにいくつかの例外があります:
Initial deploying ECOM to C:\Users\John624\Documents\NetBeansProjects\PromoCoupon\ECOM\dist\gfdeploy\ECOM
Completed initial distribution of ECOM
Initializing...
invalid header field name: Exception Description
C:\Users\John624\Documents\NetBeansProjects\PromoCoupon\ECOM\nbproject\build-impl.xml:307: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 5 seconds)
Glassfish:
<code> SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
SEVERE: Exception while invoking class org.glassfish.javaee.full.deployment.EarDeployer prepare method
SEVERE: org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ECOM-ejbPU] failed.
Internal Exception: Exception [EclipseLink-7158] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered when building the @NamedQuery [Adresse.maxId] from entity class [class org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
Internal Exception: Java.lang.ClassCastException: org.Eclipse.persistence.jpa.jpql.parser.NullExpression cannot be cast to org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.Java:180)
at com.Sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.Java:922)
at com.Sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.Java:431)
at com.Sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.Java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.Java:491)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.Java:527)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.Java:523)
at Java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.Java:356)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.Java:522)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:546)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:1423)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.Java:108)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1762)
at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1674)
at com.Sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.Java:534)
at com.Sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.Java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.Java:297)
at com.Sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.Java:246)
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:724)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ECOM-ejbPU] failed.
Internal Exception: Exception [EclipseLink-7158] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered when building the @NamedQuery [Adresse.maxId] from entity class [class org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
Internal Exception: Java.lang.ClassCastException: org.Eclipse.persistence.jpa.jpql.parser.NullExpression cannot be cast to org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.Eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.Java:1950)
at org.Eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.Java:1941)
at org.Eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.Java:322)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.Java:199)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.Java:107)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.Java:223)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.Java:510)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.Java:230)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.Java:168)
at com.Sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.Java:922)
at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.Java:307)
at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.Java:88)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.Java:153)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.Java:150)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.Java:230)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.Java:239)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.Java:265)
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.Java:150)
... 35 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ECOM-ejbPU] failed.
Internal Exception: Exception [EclipseLink-7158] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered when building the @NamedQuery [Adresse.maxId] from entity class [class org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
Internal Exception: Java.lang.ClassCastException: org.Eclipse.persistence.jpa.jpql.parser.NullExpression cannot be cast to org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.Eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.Java:230)
... 53 more
Caused by: Exception [EclipseLink-7158] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.Eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered when building the @NamedQuery [Adresse.maxId] from entity class [class org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
Internal Exception: Java.lang.ClassCastException: org.Eclipse.persistence.jpa.jpql.parser.NullExpression cannot be cast to org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.Eclipse.persistence.exceptions.ValidationException.errorProcessingNamedQuery(ValidationException.Java:824)
at org.
SEVERE: Exception while preparing the app
SEVERE: Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.process(NamedQueryMetadata.Java:194)
at org.Eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.Java:1628)
at org.Eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.Java:148)
at org.Eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.Java:1894)
... 51 more
Caused by: Java.lang.ClassCastException: org.Eclipse.persistence.jpa.jpql.parser.NullExpression cannot be cast to org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.Eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.Java:626)
at org.Eclipse.persistence.jpa.jpql.parser.RangeVariableDeclaration.accept(RangeVariableDeclaration.Java:98)
at org.Eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.Java:577)
at org.Eclipse.persistence.jpa.jpql.parser.IdentificationVariableDeclaration.accept(IdentificationVariableDeclaration.Java:71)
at org.Eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.Java:566)
at org.Eclipse.persistence.jpa.jpql.parser.FromClause.accept(FromClause.Java:48)
at org.Eclipse.persistence.internal.jpa.jpql.DeclarationResolver.populateImp(DeclarationResolver.Java:417)
at org.Eclipse.persistence.internal.jpa.jpql.DeclarationResolver.populate(DeclarationResolver.Java:407)
at org.Eclipse.persistence.internal.jpa.jpql.JPQLQueryHelper$DescriptorCollector.collectDescriptors(JPQLQueryHelper.Java:179)
at org.Eclipse.persistence.internal.jpa.jpql.JPQLQueryHelper$DescriptorCollector.visit(JPQLQueryHelper.Java:204)
at org.Eclipse.persistence.jpa.jpql.parser.FromClause.accept(FromClause.Java:48)
at org.Eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.acceptChildren(AbstractSelectStatement.Java:93)
at org.Eclipse.persistence.jpa.jpql.parser.SelectStatement.acceptChildren(SelectStatement.Java:110)
at org.Eclipse.persistence.jpa.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.Java:32)
at org.Eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.Java:470)
at org.Eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.Java:102)
at org.Eclipse.persistence.jpa.jpql.parser.JPQLExpression.acceptChildren(JPQLExpression.Java:143)
at org.Eclipse.persistence.jpa.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.Java:32)
at org.Eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.Java:302)
at org.Eclipse.persistence.jpa.jpql.parser.JPQLExpression.accept(JPQLExpression.Java:136)
at org.Eclipse.persistence.internal.jpa.jpql.JPQLQueryHelper.getClassDescriptors(JPQLQueryHelper.Java:87)
at org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.addJPAQuery(NamedQueryMetadata.Java:105)
at org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.process(NamedQueryMetadata.Java:192)
... 54 more
<code>
エンティティBean
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package entities;
import Java.io.Serializable;
import Java.util.Collection;
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.OneToMany;
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;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author John624
*/
@Entity
@Table(name = "Adresse")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Adresse.maxId", query = "SELECT max(idAdresse) FROM Adresse"),
@NamedQuery(name = "Adresse.findAll", query = "SELECT a FROM Adresse a"),
@NamedQuery(name = "Adresse.findByIdAdresse", query = "SELECT a FROM Adresse a WHERE a.idAdresse = :idAdresse"),
@NamedQuery(name = "Adresse.findByNumEtRue", query = "SELECT a FROM Adresse a WHERE a.numEtRue = :numEtRue"),
@NamedQuery(name = "Adresse.findByComple", query = "SELECT a FROM Adresse a WHERE a.comple = :comple"),
@NamedQuery(name = "Adresse.findByCodePostale", query = "SELECT a FROM Adresse a WHERE a.codePostale = :codePostale"),
@NamedQuery(name = "Adresse.findByVille", query = "SELECT a FROM Adresse a WHERE a.ville = :ville"),
@NamedQuery(name = "Adresse.findByPays", query = "SELECT a FROM Adresse a WHERE a.pays = :pays"),
@NamedQuery(name = "Adresse.findByDateModif", query = "SELECT a FROM Adresse a WHERE a.dateModif = :dateModif")})
public class Adresse implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "idAdresse")
private Long idAdresse;
@Size(max = 100)
@Column(name = "numEtRue")
private String numEtRue;
@Size(max = 100)
@Column(name = "comple")
private String comple;
@Size(max = 5)
@Column(name = "codePostale")
private String codePostale;
@Size(max = 35)
@Column(name = "ville")
private String ville;
@Size(max = 35)
@Column(name = "pays")
private String pays;
@Column(name = "dateModif")
@Temporal(TemporalType.DATE)
private Date dateModif;
@OneToMany(mappedBy = "adrU")
private Collection<Utilisateur> utilisateurCollection;
@OneToMany(mappedBy = "adrRecep")
private Collection<Livraison> livraisonCollection;
@OneToMany(mappedBy = "adrE")
private Collection<Entreprise> entrepriseCollection;
public Adresse() {
}
public Adresse(Long idAdresse) {
this.idAdresse = idAdresse;
}
public Long getIdAdresse() {
return idAdresse;
}
public void setIdAdresse(Long idAdresse) {
this.idAdresse = idAdresse;
}
public String getNumEtRue() {
return numEtRue;
}
public void setNumEtRue(String numEtRue) {
this.numEtRue = numEtRue;
}
public String getComple() {
return comple;
}
public void setComple(String comple) {
this.comple = comple;
}
public String getCodePostale() {
return codePostale;
}
public void setCodePostale(String codePostale) {
this.codePostale = codePostale;
}
public String getVille() {
return ville;
}
public void setVille(String ville) {
this.ville = ville;
}
public String getPays() {
return pays;
}
public void setPays(String pays) {
this.pays = pays;
}
public Date getDateModif() {
return dateModif;
}
public void setDateModif(Date dateModif) {
this.dateModif = dateModif;
}
@XmlTransient
public Collection<Utilisateur> getUtilisateurCollection() {
return utilisateurCollection;
}
public void setUtilisateurCollection(Collection<Utilisateur> utilisateurCollection) {
this.utilisateurCollection = utilisateurCollection;
}
@XmlTransient
public Collection<Livraison> getLivraisonCollection() {
return livraisonCollection;
}
public void setLivraisonCollection(Collection<Livraison> livraisonCollection) {
this.livraisonCollection = livraisonCollection;
}
@XmlTransient
public Collection<Entreprise> getEntrepriseCollection() {
return entrepriseCollection;
}
public void setEntrepriseCollection(Collection<Entreprise> entrepriseCollection) {
this.entrepriseCollection = entrepriseCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idAdresse != null ? idAdresse.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 Adresse)) {
return false;
}
Adresse other = (Adresse) object;
if ((this.idAdresse == null && other.idAdresse != null) || (this.idAdresse != null && !this.idAdresse.equals(other.idAdresse))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entities.Adresse[ idAdresse=" + idAdresse + " ]";
}
}
セッションBean
/ * *このテンプレートを変更するには、[ツール]メニューから[テンプレート]を選択します。テンプレート*を開き、エディターでテンプレートを開きます。 * /パッケージセッション。
import entities.Adresse;
import Java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/**
*
* @author John624
*/
@Stateless
@LocalBean
public class AdresseManager {
@PersistenceContext(unitName = "ECOM-ejbPU")
private EntityManager em;
public List<Adresse> getAllAdresses() {
Query query=em.createNamedQuery("Adresse.findAll");
return query.getResultList();
}
public Adresse update(Adresse adresse) {
return em.merge(adresse);
}
public void persist(Object object) {
em.persist(object);
}
public Long nextId(){
Query query = em.createNamedQuery("Adresse.maxId");
long res;
res = query.getResultList().indexOf(0)+1;
return res;
}
}
JSF管理対象Bean
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package managedbeans;
import entities.Adresse;
import Java.io.Serializable;
import Java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import session.AdresseManager;
/**
*
* @author John624
*/
@Named(value="adresseMBean")
@SessionScoped
public class AdresseMBean implements Serializable{
private List<Adresse> adresses;
private Adresse adresse;
@EJB
private AdresseManager adresseManager;
public AdresseMBean() {
adresse=new Adresse();
adresseManager = new AdresseManager();
}
/**
* returns customer list for display in a datatable DataTable
* @return
*/
public List<Adresse> getAdresses() {
if((adresses == null) || (adresses.isEmpty()))
adresses = adresseManager.getAllAdresses();
return adresseManager.getAllAdresses();
}
// public void refresh() {
// tousLesComptes = compteBancaireFacade.findAll();
// }
/**
* returns details of a customer. Useful for displaying in a form a customer's details
* @return
*/
public Adresse getDetails() {
return adresse;
}
/**
* Action handler - Called when a line in the table is clicked
* @param adresse
* @return
*/
public String showDetails(Adresse adresse) {
this.adresse = adresse;
return "AdresseDetails"; // will display CustomerDetails.xml JSF page
}
/**
* Action handler - update the customer model in the database.
* called when one press the update button in the form
* @return
*/
public String update() {
System.out.println("###UPDATE###");
adresse = adresseManager.update(adresse);
return "AdresseList"; // will display the customer list in a table
}
/**
* Action handler - returns to the list of customers in the table
*/
public String list() {
System.out.println("###LIST###");
return "AdresseList";
}
public void update(Adresse adrU) {
System.out.println("###UPDATE###");
adresseManager.update(adrU);
}
}
前もって感謝します。
次の例外スタックトレースが示すように
Exception Description: Error encountered when building the @NamedQuery [Adresse.maxId] from entity class [class org.Eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
問題はここにあります:
@NamedQuery(name = "Adresse.maxId", query = "SELECT max(idAdresse) FROM Adresse"),
問題を解決するには、代わりにこれを試してください:
@NamedQuery(name = "Adresse.maxId", query = "SELECT max(a.idAdresse) FROM Adresse a"),
次の手順を試してください。
AdresseManager = new AdresseManager();を削除してみてください。 AdresseMBeanクラスから。
@EJBは既にオブジェクトを挿入して作成しています。
次に、プロジェクトの再デプロイを試み、getAdressesメソッドにデバッグブレークポイントを設定して、adresseManagerオブジェクトがnullでないか、貧弱なSysoutを実行していないかを確認します。
マネージドBeanの開始時にサービスを初期化する場合は、マネージドBean内のカスタムパブリックメソッドで@PostConstructアノテーションを使用し、そこで初期化をコーディングする必要があります(例:エンティティリストをdbからロードする)。
それがあなたを助けることを願っています。
PS:私の英語間違いはすみません、私はフランス語です。
PS2:私はそれが以前に機能していたのを見たことがないので、おそらく展開の問題です!