No property type found - spring

I was working on a project but I got this no property type found error.
Please check my code and try to understand what the problem is.
package com.bisoft.staj.poi;
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class PoiApplication implements CommandLineRunner {
#Autowired
MesafeRepository mesafeRepository;
public static void main(String[] args) {
SpringApplication.run(PoiApplication.class, args);
}
#Override
public void run(String... strings) throws Exception {
System.out.println("Debug");
FileInputStream file = new FileInputStream(new File("C:/Users/MONSTER/Desktop/Hello.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
Row row;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
row = (Row) sheet.getRow(i); //sheet number
String kayitNo;
if (row.getCell(0) == null) {
kayitNo = "0";
} else {
kayitNo = row.getCell(0).toString();
}
int cihazNo = 0;
if (row.getCell(1) != null) {
cihazNo = (int) row.getCell(1).getNumericCellValue();
}
String plaka;
if (row.getCell(2) == null) {
plaka = "null";
} else {
plaka = row.getCell(2).toString(); //exceldeki isimleri
}
String surucu;
if (row.getCell(3) == null) {
surucu = "null";
} else {
surucu = row.getCell(3).toString();
}
float ilkMesafeSayaci = 0;
if (row.getCell(4) != null) {
ilkMesafeSayaci = (float)row.getCell(4).getNumericCellValue();
}
String ilkMesafeTarih;
if (row.getCell(5) == null) {
ilkMesafeTarih = "null";
} else {
ilkMesafeTarih = row.getCell(5).toString();
}
float sonMesafeSayaci = 0;
if (row.getCell(6) != null) {
sonMesafeSayaci = (float)row.getCell(6).getNumericCellValue();
}
String sonMesafeTarih;
if (row.getCell(7) == null) {
sonMesafeTarih = "null";
} else {
sonMesafeTarih = row.getCell(7).toString();
}
float toplamMesafe = 0;
if (row.getCell(8) != null) {
toplamMesafe = (float)row.getCell(8).getNumericCellValue();
}
Mesafe c = new Mesafe();
c.setCihazNo(cihazNo);
c.setPlaka(plaka);
c.setSurucu(surucu);
c.setIlkMesafeSayaci(ilkMesafeSayaci);
c.setIlkMesafeTarih(ilkMesafeTarih);
c.setSonMesafeSayaci(sonMesafeSayaci);
c.setSonMesafeTarih(sonMesafeTarih);
c.setToplamMesafe(toplamMesafe);
mesafeRepository.save(c);
System.out.println(cihazNo + " " + plaka + " " + surucu);
}
mesafeRepository.findByName("Berkin").forEach(System.out::println);
file.close();
System.out.println("Completed!");
}
}
Repository
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.bisoft.staj.poi;
import java.io.Serializable;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
/**
*
* #author MONSTER
*/
public interface MesafeRepository extends JpaRepository<Mesafe, Long>{
public List<Mesafe> findByName(String name);
}
Class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.bisoft.staj.poi;
import javax.annotation.Generated;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
/**
*
* #author MONSTER
*/
#Entity
public class Mesafe {
#Id
#SequenceGenerator(name = "customersequence", sequenceName = "customersequence", allocationSize = 1)
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "customersequence")
private Long kayitNo;
private int cihazNo;
private String plaka;
private String surucu;
private float ilkMesafeSayaci;
private String ilkMesafeTarih;
private float sonMesafeSayaci;
private String SonMesafeTarih;
private float toplamMesafe;
public Long getKayitNo() {
return kayitNo;
}
public void setKayitNo(Long kayitNo) {
this.kayitNo = kayitNo;
}
public int getCihazNo() {
return cihazNo;
}
public void setCihazNo(int cihazNo) {
this.cihazNo = cihazNo;
}
public String getPlaka() {
return plaka;
}
public void setPlaka(String plaka) {
this.plaka = plaka;
}
public String getSurucu() {
return surucu;
}
public void setSurucu(String surucu) {
this.surucu = surucu;
}
public float getIlkMesafeSayaci() {
return ilkMesafeSayaci;
}
public void setIlkMesafeSayaci(float ilkMesafeSayaci) {
this.ilkMesafeSayaci = ilkMesafeSayaci;
}
public String getIlkMesafeTarih() {
return ilkMesafeTarih;
}
public void setIlkMesafeTarih(String ilkMesafeTarih) {
this.ilkMesafeTarih = ilkMesafeTarih;
}
public float getSonMesafeSayaci() {
return sonMesafeSayaci;
}
public void setSonMesafeSayaci(float sonMesafeSayaci) {
this.sonMesafeSayaci = sonMesafeSayaci;
}
public String getSonMesafeTarih() {
return SonMesafeTarih;
}
public void setSonMesafeTarih(String SonMesafeTarih) {
this.SonMesafeTarih = SonMesafeTarih;
}
public float getToplamMesafe() {
return toplamMesafe;
}
public void setToplamMesafe(float toplamMesafe) {
this.toplamMesafe = toplamMesafe;
}
#Override
public String toString() {
return "Mesafe{" + "kayitNo=" + kayitNo + ", cihazNo=" + cihazNo + ", plaka=" + plaka + ", surucu=" + surucu + ", ilkMesafeSayaci=" + ilkMesafeSayaci + ", ilkMesafeTarih=" + ilkMesafeTarih + ", sonMesafeSayaci=" + sonMesafeSayaci + ", SonMesafeTarih=" + SonMesafeTarih + ", toplamMesafe=" + toplamMesafe + '}';
}
}
Error
by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mesafeRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property name found for type Mesafe!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
... 18 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type Mesafe!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:247) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:378) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:89) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:64) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:214) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
... 28 common frames omitted
my pom.xml and application.properties files are working OK so where can the problem be? Thanks...

I think the problem is in your repo:
public interface MesafeRepository extends JpaRepository<Mesafe, Long>{
public List<Mesafe> findByName(String name);
}
According to method findByName, your entity should have a property name, but there is no such property in Mesafe entity
You can just remove this method from repo, or add corresponding property to the entity

Related

com.ibm.as400.access.AS400JDBCSQLSyntaxErrorException: An undefined column name was detected

I couldn't find why I am getting this exception. Please help me to find it.
I am using the IBM DB2/AS400 DB engine. I have checked the column names in the database with the names I declared in the java class. They are the same. After this exception, the app is not stopping but it's continued further. somewhere in the app, I am trying to save using the repository (repository.save(dailyErrorVO);) and there it's waiting for a long time and going into some deadlock.
public interface DailyErrorRepository
extends JpaRepository<DailyErrorVO, String>, CrudRepository<DailyErrorVO, String> {
}
#Entity
#Table(name = "T_DAILY_ERROR")
public class DailyErrorVO implements Comparable<DailyErrorVO>, Cloneable, Serializable{
private static final long serialVersionUID = 4917078316183458138L;
private Date EFF_DATE;
private String ERRCODE;
private String ERROR_MESSAGE;
private String EXCEPTION_MESSAGE;
private String EXTRNL_POI;
private String IMPACT_AREA;
#Column(name="LAST_MOD_TIME_DT", nullable = false)
private Timestamp LAST_MOD_TIME_DT;
#Id
#Column(nullable = true)
private String MEMBER_ID;
private String PAY_SEQ;
private String PROG_ID;
#Column(name="PROGRAM", nullable = false)
private String PROGRAM = CommonProperties.PROGRAM_NAME;
#Column(name="RUN_DATE", nullable = false)
private Date RUN_DATE;
private String SQLCODE;
private String SSN;
private String TABLE_NM;
public Date getEFF_DATE() {
return EFF_DATE;
}
public void setEFF_DATE(Date eFF_DATE) {
EFF_DATE = eFF_DATE;
}
public String getERRCODE() {
return ERRCODE;
}
public void setERRCODE(String eRRCODE) {
ERRCODE = eRRCODE;
}
public String getERROR_MESSAGE() {
return ERROR_MESSAGE;
}
public void setERROR_MESSAGE(String eRROR_MESSAGE) {
ERROR_MESSAGE = eRROR_MESSAGE;
}
public String getEXCEPTION_MESSAGE() {
return EXCEPTION_MESSAGE;
}
public void setEXCEPTION_MESSAGE(String eXCEPTION_MESSAGE) {
EXCEPTION_MESSAGE = eXCEPTION_MESSAGE;
}
public String getEXTRNL_POI() {
return EXTRNL_POI;
}
public void setEXTRNL_POI(String eXTRNL_POI) {
EXTRNL_POI = eXTRNL_POI;
}
public String getIMPACT_AREA() {
return IMPACT_AREA;
}
public void setIMPACT_AREA(String iMPACT_AREA) {
IMPACT_AREA = iMPACT_AREA;
}
public Timestamp getLAST_MOD_TIME_DT() {
return LAST_MOD_TIME_DT;
}
public void setLAST_MOD_TIME_DT(Timestamp lAST_MOD_TIME_DT) {
LAST_MOD_TIME_DT = lAST_MOD_TIME_DT;
}
public String getMEMBER_ID() {
return MEMBER_ID;
}
public void setMEMBER_ID(String mEMBER_ID) {
MEMBER_ID = mEMBER_ID;
}
public String getPAY_SEQ() {
return PAY_SEQ;
}
public void setPAY_SEQ(String pAY_SEQ) {
PAY_SEQ = pAY_SEQ;
}
public String getPROG_ID() {
return PROG_ID;
}
public void setPROG_ID(String pROG_ID) {
PROG_ID = pROG_ID;
}
public String getPROGRAM() {
return PROGRAM;
}
public void setPROGRAM(String pROGRAM) {
PROGRAM = pROGRAM;
}
public Date getRUN_DATE() {
return RUN_DATE;
}
public void setRUN_DATE(Date rUN_DATE) {
RUN_DATE = rUN_DATE;
}
public String getSQLCODE() {
return SQLCODE;
}
public void setSQLCODE(String sQLCODE) {
SQLCODE = sQLCODE;
}
public String getSSN() {
return SSN;
}
public void setSSN(String sSN) {
SSN = sSN;
}
public String getTABLE_NM() {
return TABLE_NM;
}
public void setTABLE_NM(String tABLE_NM) {
TABLE_NM = tABLE_NM;
}
#Override
public String toString() {
return "TDailyErrorVO [EFF_DATE=" + EFF_DATE + ", ERRCODE=" + ERRCODE + ", ERROR_MESSAGE=" + ERROR_MESSAGE
+ ", EXCEPTION_MESSAGE=" + EXCEPTION_MESSAGE + ", EXTRNL_POI=" + EXTRNL_POI + ", IMPACT_AREA="
+ IMPACT_AREA + ", LAST_MOD_TIME_DT=" + LAST_MOD_TIME_DT + ", MEMBER_ID=" + MEMBER_ID + ", PAY_SEQ="
+ PAY_SEQ + ", PROG_ID=" + PROG_ID + ", PROGRAM=" + PROGRAM + ", RUN_DATE=" + RUN_DATE + ", SQLCODE="
+ SQLCODE + ", SSN=" + SSN + ", TABLE_NM=" + TABLE_NM + "]";
}
#Override
public int compareTo(DailyErrorVO o) {
return 0;
}
}
com.ibm.as400.access.AS400JDBCSQLSyntaxErrorException: An undefined column name was detected.
at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:897) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:421) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:397) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.ibm.as400.access.JDServerRow.findField(JDServerRow.java:519) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.ibm.as400.access.AS400JDBCResultSet.findColumn(AS400JDBCResultSet.java:575) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3424) ~[jt400-jdk8-9.5.jar:JTOpen 9.5]
at com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java) ~[HikariCP-3.4.5.jar:?]
at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.resultSetSchemaName(SequenceInformationExtractorLegacyImpl.java:124) ~[hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:53) ~[hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.sequenceInformationList(JdbcEnvironmentImpl.java:403) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:268) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255) [hibernate-core-5.4.25.Final.jar:5.4.25.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) [spring-orm-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391) [spring-orm-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:378) [spring-orm-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$148/0000000000000000.getObject(Unknown Source) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) [spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) [spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.7.RELEASE.jar:2.3.7.RELEASE]
at com.benefeds.batch.ABWReversalFileValidationStarter.main(ABWReversalFileValidationStarter.java:9) [classes/:?]
According to the stack trace that you posted, Hibernate is unable to determine the current value of some sequence which happens at boot time. Maybe you configured the wrong dialect or the dialect has a bug. Please share the dialect that you use and the Hibernate version, as well as the exact database name and version. Chances are, you can simply subclass a dialect and fix the bug yourself.

hbase co-processor failing to load from shell

I am trying to add a coprocessor with one hbase table and it is failing with error -
2016-03-15 14:40:14,130 INFO org.apache.hadoop.hbase.regionserver.RSRpcServices: Open PRODUCT_DETAILS,,1457953190424.f687dd250bfd1f18ffbb8075fd625145.
2016-03-15 14:40:14,173 ERROR org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost: Failed to load coprocessor com.optymyze.coprocessors.ProductObserver
java.io.IOException: Failed on local exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.; Host Details : local host is: "mylocalhost/mylocalhostip"; destination host is: "mydestinationhost":9000;
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:772)
to add co processor I did following -
hbase> disable 'PRODUCT_DETAILS'
hbase> alter 'PRODUCT_DETAILS', METHOD => 'table_att', 'coprocessor'=>'hdfs://mydestinationhost:9000/hbase-coprocessors-0.0.3-SNAPSHOT.jar|com.optymyze.coprocessors.ProductObserver|1001|arg1=1,arg2=2'
now enable 'PRODUCT_DETAILS' won't work.
co processor code is as follows-
package com.optymyze.coprocessors;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.slf4j.LoggerFactory.*;
/**
*
* Created by adnan on 14-03-2016.
*/
public class ProductObserver extends BaseRegionObserver {
private static final Logger LOGGER = getLogger(ProductObserver.class);
private static final String PRODUCT_DETAILS_TABLE = "PRODUCT_DETAILS";
public static final String COLUMN_FAMILY = "CF";
#Override
public void postPut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit, boolean writeToWAL) throws IOException {
List<KeyValue> kvs = put.getFamilyMap().get(Bytes.toBytes(COLUMN_FAMILY));
LOGGER.info("key values {}", kvs);
Map<String, Integer> qualifierVsValue = getMapForQualifierVsValuesForRequiredOnes(kvs);
LOGGER.info("qualifier values {}", qualifierVsValue);
List<Put> puts = createPuts(kvs, qualifierVsValue);
LOGGER.info("puts values {}", puts);
updateProductTable(e, puts);
LOGGER.info("puts done");
}
private void updateProductTable(ObserverContext<RegionCoprocessorEnvironment> e, List<Put> puts) throws IOException {
HTableInterface productTable = e.getEnvironment().getTable(Bytes.toBytes(PRODUCT_DETAILS_TABLE));
try {
productTable.put(puts);
}finally {
productTable.close();
}
}
private List<Put> createPuts(List<KeyValue> kvs, Map<String, Integer> qualifierVsValue) {
int salePrice, baseline = 0, finalPrice = 0;
List<Put> puts = new ArrayList<Put>(kvs.size());
for (KeyValue kv : kvs) {
if (kv.matchingQualifier(Bytes.toBytes("BASELINE"))) {
baseline = convertToZeroIfNull(qualifierVsValue, "PRICE")
- convertToZeroIfNull(qualifierVsValue, "PRICE")
* convertToZeroIfNull(qualifierVsValue, "DISCOUNT") / 100;
puts.add(newPut(kv, baseline));
}
if (kv.matchingQualifier(Bytes.toBytes("FINALPRICE"))) {
finalPrice = baseline + baseline * convertToZeroIfNull(qualifierVsValue, "UPLIFT") / 100;
puts.add(newPut(kv, finalPrice));
}
if (kv.matchingQualifier(Bytes.toBytes("SALEPRICE"))) {
salePrice = finalPrice * convertToZeroIfNull(qualifierVsValue, "VOLUME");
puts.add(newPut(kv, salePrice));
}
}
return puts;
}
private Map<String, Integer> getMapForQualifierVsValuesForRequiredOnes(List<KeyValue> kvs) {
Map<String, Integer> qualifierVsValue = new HashMap<String, Integer>();
for (KeyValue kv : kvs) {
getValueFromQualifier(kv, "PRICE", qualifierVsValue);
getValueFromQualifier(kv, "DISCOUNT", qualifierVsValue);
getValueFromQualifier(kv, "UPLIFT", qualifierVsValue);
getValueFromQualifier(kv, "VOLUME", qualifierVsValue);
}
return qualifierVsValue;
}
private Integer convertToZeroIfNull(Map<String, Integer> qualifierVsValue, String qualifier) {
Integer v = qualifierVsValue.get(qualifier);
return v == null ? 0 : v;
}
private void getValueFromQualifier(KeyValue kv, String qualifier, Map<String, Integer> qualifierVsValue) {
if (kv.matchingQualifier(Bytes.toBytes(qualifier))) {
qualifierVsValue.put(qualifier, Bytes.toInt(convertToByteZeroIfNull(kv)));
}
}
private Put newPut(KeyValue kv, int newVal) {
Put put = new Put(kv.getValue(), kv.getTimestamp());
put.add(kv.getFamily(), kv.getQualifier(), Bytes.toBytes(newVal));
return put;
}
private byte[] convertToByteZeroIfNull(KeyValue kv) {
return kv.getValue() == null ? Bytes.toBytes(0) : kv.getValue();
}
}

could not initialize proxy - no Session

[ERROR] could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at com.model.dto.Distination$$EnhancerByCGLIB$$f4a8517c.getLibileDis(<generated>)
at com.business.impl.MeteobussinesImpl.afficherMeteo1(MeteobussinesImpl.java:30)
at com.test.Tester.main(Tester.java:32)
[ERROR] could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at com.model.dto.Distination$$EnhancerByCGLIB$$f4a8517c.toString(<generated>)
at com.model.dto.Distination$$EnhancerByCGLIB$$f4a8517c.getLibileDis(<generated>)
at com.business.impl.MeteobussinesImpl.afficherMeteo1(MeteobussinesImpl.java:30)
at com.test.Tester.main(Tester.java:32)
1.class main
package com.test;
import java.util.Iterator;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.business.Meteobussines;
import com.business.impl.MeteobussinesImpl;
import com.model.vo.Meteo;
public class Tester {
static public void displayList(List list)
{ Iterator iter = list.iterator();
if (!iter.hasNext())
{ System.out.println("La lsite est vide"); return; }
while (iter.hasNext()) {
Meteo ct = (Meteo) iter.next();
System.out.println("tempsMax :" + ct.getTempMax() + " pays :" + ct.getLibilePays() + " distination :" + ct.getLibileDistination()); }}
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] configArray = new String[] { "/com/resource/spring/ApplicationContext.xml",
"/com/resource/spring/ApplicationContextDao.xml","/com/resource/spring/ApplicationContextBusiness.xml"};
ApplicationContext ctx = new ClassPathXmlApplicationContext(configArray);
Meteobussines mete = (Meteobussines) ctx.getBean("MeteoBuss");
List<Meteo> m = mete.afficherMeteo1("tounes");
displayList(m);
}
}
2.Meteobussiness
package com.business.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.business.Meteobussines;
import com.dao.HistoriqueDao;
import com.dao.impl.HistoriqueDaoImpl;
import com.model.dto.Historique;
import com.model.vo.Meteo;
public class MeteobussinesImpl implements Meteobussines {
HistoriqueDao historiqueDao ;
#SuppressWarnings("null")
#Override
public List<Meteo> afficherMeteo1(String pays) {
List<Historique> hiss= historiqueDao.rechercher(pays);
List<Meteo> m = new ArrayList<Meteo>(); ;
Iterator iter = hiss.iterator();
if (!iter.hasNext())
{ System.out.println("La lsite est vide"); }
while (iter.hasNext()) {
Historique ct = (Historique) iter.next();
Meteo me =new Meteo();
me.setDateHis(ct.getDateHis());
me.setLibileDistination(ct.getDistination().getLibileDis());
me.setLibilePays(ct.getPays().getLibilePays());
me.setLibileVille(ct.getVille().getLibileVille());
me.setTempMax(ct.getTempMax());
me.setTempMin(ct.getTempMin());
m.add(me);
}
return m;
// TODO Auto-generated method stub
}
#Override
public List<Meteo> afficherMeteo2(String pays, String ville) {
// TODO Auto-generated method stub
return null;
}
#Override
public List<Meteo> afficherMeteo3(String pays, String ville,
String distination) {
// TODO Auto-generated method stub
return null;
}
public HistoriqueDao getHistoriqueDao() {
return historiqueDao;
}
public void setHistoriqueDao(HistoriqueDao historiqueDao) {
this.historiqueDao = historiqueDao;
}
}
3.HistroiqueDaao
package com.dao.impl;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.criterion.Expression;
import com.dao.HistoriqueDao;
import com.model.dto.Historique;
#SuppressWarnings("unchecked")
public class HistoriqueDaoImpl extends GenericDaoImpl implements HistoriqueDao {
#Override
public List<Historique> rechercher(String critere1, String critere2,
String critere3) {
Criteria crit = getSession().createCriteria(Historique.class);
crit.setFetchMode("pays", FetchMode.JOIN);
crit.createAlias("pays", "p");
crit.add(Expression.eq("p.libilePays", critere1));
crit.setFetchMode("ville", FetchMode.JOIN);
crit.createAlias("ville", "b");
crit.add(Expression.eq("b.libileVille", critere2));
crit.setFetchMode("distination", FetchMode.JOIN);
crit.createAlias("distination", "d");
crit.add(Expression.eq("d.libileDis", critere3));
List<Historique> his = crit.list();
return his;
}
#Override
public List<Historique> rechercher(String critere1, String critere2) {
// TODO Auto-generated method stub
Criteria crit = getSession().createCriteria(Historique.class);
crit.setFetchMode("pays", FetchMode.JOIN);
crit.createAlias("pays", "p");
crit.add(Expression.eq("p.libilePays", critere1));
crit.setFetchMode("ville", FetchMode.JOIN);
crit.createAlias("ville", "b");
crit.add(Expression.eq("b.libileVille", critere2));
List<Historique> his = crit.list();
return his;
}
#Override
public List<Historique> rechercher(String critere1) {
// TODO Auto-generated method stub
Criteria crit = getSession().createCriteria(Historique.class);
crit.setFetchMode("pays", FetchMode.JOIN);
crit.createAlias("pays", "p");
crit.add(Expression.eq("p.libilePays", critere1));
List<Historique> his = crit.list();
return his;
}
}
3.i use DaoSupport initialize in spring
The stack trace points to this line:
me.setLibileDistination(ct.getDistination().getLibileDis());
ct is a Historique proxy = a fake object whose fields (including the one you obtain through getDistination()) are not yet initiated.
Please initialize the fields you are interested in before committing the Hibernate transaction.
Hibernate.initialize(ct.getDistination());
crit.setFetchMode("pays", FetchMode.JOIN);
crit.setFetchMode("ville", FetchMode.JOIN);
crit.setFetchMode("distination", FetchMode.JOIN);
this the soultion of the problem cause i have in all the case to open the fetchmode.join

RestAPI and Neo4j

Can anyone help with these Neo4j (1.9) errors and the RestApi using JDK 1.6 and Heroku.
The objective of the code is only to demo the functionality of using cypher and Neo4j with Java. I understand that only the RestAPI works at Heroku.
package com.example;
import java.util.List;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.collection.*;
import org.neo4j.rest.graphdb.RestAPI;
import org.neo4j.rest.graphdb.RestAPIFacade;
import org.neo4j.rest.graphdb.RestGraphDatabase;
import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
import org.neo4j.rest.graphdb.util.*;
import org.springframework.stereotype.Component;
import java.util.Map;
import com.example.IDatabaseConnector;
//import org.neo4j.rest.graphdb.RestGraphDatabase;
//import org.neo4j.
#Component
//public class Neo4jDatabaseConnector implements IDatabaseConnector {
public class Neo4jDatabaseConnector implements IDatabaseConnector{
Node aNode;
Node first;
Node second;
Relationship relation;
private static GraphDatabaseService GraphDb;
private static RestAPI restAPI;
Transaction txn;
private static enum RelTypes implements RelationshipType
{
KNOWS,
USAGE
}
public void showNode( )
{
// have to add code for cypher
RestCypherQueryEngine rcqe = new RestCypherQueryEngine(restAPI);
//Then just execute your cypher statements using rcqe.query().
// int length=0;
String countNodes = "START n=node(*) RETURN count(*)";
String createNodes = "CREATE (n {name: 'Trevor Oakley'})";
rcqe.query(createNodes, null);
// QueryResult <Map<String,Object>> result = rcqe.query(countNodes, null);
//for (Map<String, Object> row:result){
// length++;
//}
//System.out.println("length="+length);
// rcqe.query(countNodes, Map<String, Object> row:result);
// rcqe.query(countNodes, Map<String,Object>:result)
// rcqe.
/* ExecutionEngine engine = new ExecutionEngine(GraphDb);
int length=-1;
try{
ExecutionResult result = engine.execute("start n=node(*) return n");
if (result == null){
length = 0;
} else
{
for (#SuppressWarnings("unused")
Map<String, Object> row:result){
length++;
}
}
} catch (NullPointerException e) {
// _log.error(e.getMessage(),e);
length=-2;
}
System.out.println("len="+length);
*/
}
public Neo4jDatabaseConnector() {
//GraphDb=new GraphDatabaseFactory().newEmbeddedDatabase(Neo4j_DBPath);
}
public int createDBRest()
{
restAPI = new RestAPIFacade(System.getenv("NEO4J_URL"),
System.getenv("NEO4J_USERNAME"),
System.getenv("NEO4J_PASSWORD"));
try{
GraphDb = new RestGraphDatabase(restAPI);
}
catch (Exception e){
return 1;
}
return 0;
}
public int createDB(String dbLoc) {
System.out.println("db loc ="+dbLoc);
int error = 0;
try{
GraphDb=new GraphDatabaseFactory().newEmbeddedDatabase(dbLoc);
//GraphDb=new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(dbLoc);
System.out.println("db loc ="+dbLoc);
String stringDB = GraphDb.toString();
System.out.println("connection ="+stringDB);
}
catch (Exception e){
System.out.println("error - ");
error = 1;
}
return erro
r;
}
Problem accessing /hello. Reason:
Error reading as JSON ''
Caused by:
java.lang.RuntimeException: Error reading as JSON ''
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:57)
at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62)
at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114)
at org.neo4j.rest.graphdb.RequestResult.toMap(RequestResult.java:120)
at org.neo4j.rest.graphdb.ExecutingRestRequest.toMap(ExecutingRestRequest.java:187)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:475)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:495)
at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:233)
at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
at com.example.Neo4jDatabaseConnector.showNode(Neo4jDatabaseConnector.java:53)
at com.example.HelloServlet.doGet(HelloServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.EOFException: No content to map to Object due to end of input
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
... 34 more
Caused by:
java.io.EOFException: No content to map to Object due to end of input
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62)
at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114)
at org.neo4j.rest.graphdb.RequestResult.toMap(RequestResult.java:120)
at org.neo4j.rest.graphdb.ExecutingRestRequest.toMap(ExecutingRestRequest.java:187)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:475)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:495)
at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:233)
at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
at com.example.Neo4jDatabaseConnector.showNode(Neo4jDatabaseConnector.java:53)
at com.example.HelloServlet.doGet(HelloServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:679)
The answer was to fill the user and password fields as shown below, in terms of the immediate error.
String neo4jURL = System.getenv("NEO4J_URL");
String user="user";
String password="password";
try{
URL url = new URL(neo4jURL);
String userInfo = url.getUserInfo();
String[] userDetails = userInfo.split(":");
user = userDetails[0];
password = userDetails[1];
} catch (MalformedURLException e) {
//
}

Error with JSF+Spring+hibernate

I am trying to integrate the JSF with spring and hibernate.
Following is my code:
LeaveBean.java
package com.nagra.bean;
import java.io.Serializable;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.annotation.Resource;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.hibernate.HibernateException;
import com.nagra.leaveapp.BO.LeaveInfoBo;
import com.nagra.leaveapp.model.LeaveInfo;
#ManagedBean(name="customer")
#SessionScoped
public class LeaveBean implements Serializable{
/**
*
*/
//private LeaveAppDo leaveAppDo=new LeaveAppDo();
LeaveInfoBo leaveinfoBo;
public LeaveInfoBo getLeaveinfoBo() {
return leaveinfoBo;
}
public void setLeaveinfoBo(LeaveInfoBo leaveinfoBo) {
this.leaveinfoBo = leaveinfoBo;
}
private String total_sick_leave;
private String total_paidoff_leave;
private String start_date;
private String end_date;
private String reason;
private String status;
private Date secondDate;
public Date getSecondDate() {
return secondDate;
}
public void setSecondDate(Date secondDate) {
this.secondDate = secondDate;
}
public String getTotal_sick_leave() {
return total_sick_leave;
}
public void setTotal_sick_leave(String total_sick_leave) {
this.total_sick_leave = total_sick_leave;
}
public String getTotal_paidoff_leave() {
return total_paidoff_leave;
}
public void setTotal_paidoff_leave(String total_paidoff_leave) {
this.total_paidoff_leave = total_paidoff_leave;
}
public String getStart_date() {
return start_date;
}
public void setStart_date(String start_date) {
this.start_date = start_date;
}
public String getEnd_date() {
return end_date;
}
public void setEnd_date(String end_date) {
this.end_date = end_date;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
private static final long serialVersionUID = 1L;
//resource injection
#Resource(name="jdbc/leaveapp")
//private DataSource ds;
//if resource inject is not support, you still can get it manually.
/*public CustomerBean(){
try {
Context ctx = new InitialContext();
ds = (DataSource)ctx.lookup("jdbc:mysql://localhost:3306/leaveapp");
} catch (NamingException e) {
e.printStackTrace();
}
}*/
public List<LeaveInfo> getCustomerList() throws SQLException{
System.out.println("Getting In " );
return null;
// return leaveinfoBo.retrieveData();
}
public String addCustomer() throws HibernateException
{
/* String url = "jdbc:mysql://localhost:3306/leaveapp";
Connection con = DriverManager.getConnection(url,"root","root");
System.out.println(con);
if(con==null)
throw new SQLException("Can't get database connection");
String sql="insert into leaveinformation(start_date,end_date,reason,status)values(?,?,?,?)";
java.util.Date utilDate = new Date();
// Convert it to java.sql.Date
java.sql.Date date = new java.sql.Date(utilDate.getTime());
java.sql.Timestamp sqlDate = new java.sql.Timestamp(new java.util.Date().getTime());*/
DateFormat formatter ;
try
{
System.out.println("Start date " + getStart_date());
formatter = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = formatter.parse(LeaveBean.this.getStart_date());
System.out.println(startDate);
Date endDate = formatter.parse(LeaveBean.this.getEnd_date());
// Days d = Days.daysBetween(startDate,endDate);
// int days = d.getDays();
#SuppressWarnings("deprecation")
java.sql.Date startdate=new java.sql.Date(startDate.getDate());
#SuppressWarnings("deprecation")
java.sql.Date enddate=new java.sql.Date(endDate.getDate());
/* System.out.println("Today is " +date );
PreparedStatement ps
= con.prepareStatement(sql);
ps.setDate(1,startdate,Calendar.getInstance(Locale.ENGLISH));
ps.setDate(2,enddate,Calendar.getInstance(Locale.ENGLISH));
ps.setString(3,CustomerBean.this.reason);
ps.setString(4,"Waiting");*/
LeaveInfo leave = new LeaveInfo();
System.out.println("Entering addCustomer() ");
leave.setEnd_date(enddate);
leave.setStart_date(startdate);
leave.setReason(reason);
leave.setStatus("Waiting");
System.out.println(leave.toString());
leaveinfoBo.save(leave);
clearall();
// Insert the row
/* ps.executeUpdate();
con.close();*/
sendmail();
}
catch(Exception e)
{
System.out.println("There is an error " + e.getStackTrace().toString());
e.printStackTrace();
}
return "";
}
private void clearall() {
// TODO Auto-generated method stub
setEnd_date("");
setStart_date("");
setReason("");
setStatus("");
}
public String sendmail()
{
// Recipient's email ID needs to be mentioned.
String to = "nsbharathi88#gmail.com";
// Sender's email ID needs to be mentioned
String from = "web#gmail.com";
// Assuming you are sending email from localhost
String host = "localhost";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
// Get the default Session object.
Session session = Session.getDefaultInstance(properties);
try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Now set the actual message
message.setText("This is actual message");
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();
}
return "";
}
}
applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- Database Configuration -->
<import resource="classes/spring/database/DataSource.xml"/>
<import resource="classes/spring/database/Hibernate.xml"/>
<!-- Beans Declaration -->
<import resource="classes/spring/bean/LeaveApp.xml"/>
</beans>
I am getting the following error when i run this on the tomcat server:
Start date 2012-02-03
java.lang.NullPointerException
at com.nagra.bean.LeaveBean.addCustomer(LeaveBean.java:167)
Fri Feb 03 00:00:00 IST 2012
Entering addCustomer()
LeaveInfo [id=0, total_sick_leave=15, total_paidoff_leave=15, start_date=1970-01- 01, end_date=1970-01-01, reason=cfklsn, status=Waiting]
There is an error [Ljava.lang.StackTraceElement;#fc644a
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
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)
I think, your startdate and enddate is of type String, Change it to java.util.Date and try
start_date=1970-01- 01
Your start date has a space in it. It wont parse.

Resources