Running stanford-openie from eclipse, the following exception occurred:
Could not load clause splitter model at edu/stanford/nlp/models/naturalli/clauseSearcherModel.ser.gz: class java.io.InvalidClassException: edu.stanford.nlp.naturalli.ClauseSplitterSearchProblem$8; local class incompatible: stream classdesc serialVersionUID = 4145523451314579506, local class serialVersionUID = -7360029270983346606
Both openie code and openie models are latest, downloaded from http://nlp.stanford.edu/software/openie.shtml.
Related
The situation is : I have a Pojo DEVICE, which has a pojo Namespace pojo inside. :
#Entity
#Table(name = "device")
public class Device implements java.io.Serializable {
private long deviceId;
private long timestamp;
private NamespaceMaster namespaceMaster;
..................
#ManyToOne(fetch = FetchType.EAGER)
#JoinColumn(name = "namespace_id")
#Cascade(value = CascadeType.ALL)
public NamespaceMaster getNamespaceMaster() {
return this.namespaceMaster;
}
When i am persisting Device, I am querying database to find the appropriate namespace and then setting the namespace pojo to device. Up to this part there is no isse.
NamespaceMaster namespaceMaster=null;
try {
namespaceMaster = namespaceDAOImpl.queryAllByName(namespace, AZURE_CLOUDTYPE).get(0);
} catch (DaoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LOG.info("Namespace object from cache :{}",namespaceMaster);
device.setNamespaceMaster(namespaceMaster);
Now when am trying persist Device, the namespace table in DB also has new row inserted with the same value that I initially queried namespace table. This is happening due to
#Cascade(value = CascadeType.ALL)
The reason is : Hibernate is unable to recognise the namespace object as already persisted one. So it cascades all the pojo inside and hense inserts a new one.
My question is simple. How to insert device object in table such that the namespace is not generated new. It is the one that is already present in namespace table. I tried removing #Cascade(value = CascadeType.ALL), but then i get a error :
object references an unsaved transient instance - save the transient instance before flushing
Note
I have added #version in NamespaceMaster table
#Version
private Long version;
private static final long serialVersionUID = 1L;
I am struck guys!! Please suggest.
Thanks in advance.
Solved the above issue.
I had inserted namespace_id(primary key for namespace table) as 0 for my data. May be hibernate is unable to understand 0 as the key and resolve in this situation. Guys be aware of this fact!!
I tried giving implementation for hashcode(),equals;#Version etc but nothing worked. updating my table primary key from 0 to a higher value worked!!
Anyways!!
If I use the Lombok #Setting annotation on a field with a value of PRIVATE
#Data
#AllArgsConstructor
#NoArgsConstructor
public class Notification implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Setter(value = AccessLevel.PRIVATE)
private String id;
private long userId;
private Event event;
private long timestamp = System.currentTimeMillis();
public Notification(final String id) {
this.id = id;
}
}
The Sonar Maven plugin gives the following error:
ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project mio-events: Unable to analyze .class file tv/nativ/mio/event/model/Notification: 0 is not a valid line for a file -> [Help 1]
Changing the #Setting value to public fixes the issue, as does removing #Setting altogether and adding a manual private setter for the field.
Any idea what the issue might be?
Thanks
Nick
Sonar doesn't really support Lombok: Feature request for lombok like tools
Prior to running sonar you should delombok the source and use the generated sources for analysis. Information about this is on the page: Delombok. If you are using maven there's an example of using this technique here: Example Pom
In one of our spring batch jobs, we create additional entities (CompanyProfile) during processing and persist them to the DB (in a separate transaction). These entities are referenced by other entities (Vacancy), which will be persisted by the writer, but unfortunate the writer fails with this error:
Caused by: javax.persistence.EntityNotFoundException: Unable to find com.company.CompanyProfile with id 1409881
The model is as follows:
#Entity
public class Vacancy {
#ManyToOne(fetch = FetchType.EAGER, optional = true)
#JoinColumn(name = "company", nullable = true)
private CompanyProfile company;
...
}
#Entity
public class CompanyProfile {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
...
}
In the processor we have this:
CompanyProfile company = companyProfileService.handleCompany(compName);
vacancy.setCompany(company);
Where the method companyProfileService.handleCompany() is annotated with #Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW )
I'm sure the CompanyProfile gets persisted - I can see it in the DB, but when the Vacancy gets saved by the ItemWriter, it fails with the above exception. (also, note that the id of the persisted entity is mention in the exception above)
Do you see any reason why the writer would fail in this case?
With information you gave us my guess is that transaction opened by SB is unable to see data persisted by companyProfileService.handleCompany() method because service component uses a different transaction than SB ones; you have to check database ISOLATION_LEVEL property
The SonarQube Rule "Fields in a "Serializable" class should either be transient or serializable" is not working properly. I have a very compliant example as mentioned in their rules definition like below, but still it is reported as an issue. I found that there was a bug alreeady raised for this (https://jira.codehaus.org/browse/SONARJAVA-917) and is resolved. And I have the latest version which has this fix as well, but still it is an issue. can some one help me how to resolve this?
`public class Address implements Serializable {
private static final long serialVersionUID = 2405172041950251807L;
}
public class Person implements Serializable {
private static final long serialVersionUID = 1905122041950251207L;
private String name;
private Address address;
}`
I built an entity with id using oracle sequence like that.
#Entity
#Table(name="C_ESTIMATE")
public class Estimate implements Serializable{
private static final long serialVersionUID = 1L;
public Estimate(){}
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "estimatenoGen")
#SequenceGenerator(name="estimatenoGen",sequenceName="AUTOSERIALNO",allocationSize=1)
#Column(name="ESTIMATENO")
private long id;
}
When I call em.persist(new Estimate()),
EclipseLink prompts Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraints . Sometimes it works correctly, sometimes failure, it is so strange.
This entity was deployed several weblogic servers.
Has EclipseLink bug on generating id using oracle sequence?
There should not be any issue on Oracle.
Can recreate the issue? Enable logging, is a duplicate id being used?
How did you create your SEQUENCE object on the database?