Shariq Roomi

Ranch Hand
+ Follow
since Oct 19, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shariq Roomi

I migrated from 3.3 to 3.5.1 and I am hitting

My code has

Any idea what is going on

Thanks Mark for your reply. The schema is sample to demonstrate the problem.
I did some research and was able to see the multiple columns for joining which you are telling me.

In teacher class, I did

@OneToMany(cascade = {CascadeType.ALL})
@JoinColumns ( {@JoinColumn(nullable=false, name="teacher_id"),
@JoinColumn(nullable=false, name="teacher_name")})
private List<Student> student;

and in student class, I did

@ManyToOne (fetch=FetchType.EAGER, cascade = {CascadeType.ALL})
@JoinColumns ( {@JoinColumn(nullable=false, name="teacher_id",
updatable=false, insertable=false),
@JoinColumn(nullable=false, name="teacher_name",
updatable=false, insertable=false)})
private Teacher teacher;

But then I got following exception

org.springframework.orm.hibernate3.HibernateSystemException: could not get a field value by reflection getter of; nested exception is org.hibernate.PropertyAccessException: could not get a field value by reflection getter of
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of

at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(
at org.hibernate.type.ComponentType.getPropertyValues(
at org.hibernate.type.ComponentType.getPropertyValues(
at org.hibernate.event.def.AbstractVisitor.processComponent(
at org.hibernate.event.def.ReattachVisitor.processComponent(
at org.hibernate.event.def.AbstractVisitor.processValue(
at org.hibernate.event.def.AbstractVisitor.processValue(
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(
at org.hibernate.event.def.AbstractVisitor.process(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(
I am getting the exception org.hibernate.AnnotationException: A Foreign key refering Teacher from Student has the wrong number of column. should be 2

The code is as follows. Can some one please help me with this code , what am I doing wrong ? :-( I have eliminated get/set from all classes

DB Schema:

Student(id , teacher_id, teacher_name)


public class Teacher implements Serializable {

private PK pk = new PK();

@OneToMany(cascade = {CascadeType.ALL})
private List<Student> student;

public List<Student> getStudent() {
return student;

public void setStudent(List<Student> student) {
this.student = student;


public class Student implements Serializable {

private int id;

@JoinColumns ( {@JoinColumn(nullable=false, name="id"),
@JoinColumn(nullable=false, name="name")})
private Teacher teacher;

public class PK implements Serializable
private int id;
private String name;

public class Teacher implements Serializable {
private int id;

private String name;

private List<Student> student;




public class Student implements Serializable {

private int id;

private String StudentName;


And to store object, I am using

Teacher t1 = new Teacher();
t1.setName("from hibernate");

Student s1 = new Student();
s1.setStudentName("Student from hibernate");

List<Student> l = new ArrayList<Student>();



The query generated by hibernate is

Hibernate: insert into Teacher (name, id) values (?, ?, ?)
Hibernate: update Student set id=? where id=?

Why am I getting update for student, this is a new object, Can any body please help me
I have simple pojos and I need to generate some other pojos based on them using annotation. Can some one please points me to some examples/resources.
16 years ago
Okay I figure out the issue but I have no solution.

If your service is implementing some interface then the parameters are named as param0 and param1 of functions from interface. It has nothing to do with debug option.

Is there any work around ??
16 years ago
Dudley, I am laso having the same issue with Axis2. I looked into sample apps of Axis2, they also have same problem. This wsdl is useless then as I can't asl client to use param0, param1 etc.Please share if you find any work around.

Arafat, this wsdl is generated by accessing
16 years ago
Thanks Guys. If the server get compromized then we would have problem so this is the reason we do not wnat to keep password in plain text.
16 years ago
I have primary keys etc stored in java key store and I have hard coded the password for keystore for now but I am thinking to store that password in text file in encrypted form. The architect of my team does not want to store password for keystore in database so now I need two way hashing algo. to store password in text file and then read it back at server start.

Any idea from where I can get two way hashing algo in java ??

Or are there any other better means to store password for key store.
16 years ago
Thanks Jan but I want to do programmatically.

There is a function in KeySTore class

setKeyEntry(String alias, Key key, char[] password, Certificate[] chain)
Assigns the given key to the given alias, protecting it with the given password.

So I am wondering hwo could I get the corresponding Certficate array for my privatekey ??
17 years ago
I can not simply make sense of this KeySTore Class.

I have private and public key and I simply want to use them in KeyStore to use later.

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keyGen.initialize(512 , random);
KeyPair keypair = keyGen.genKeyPair();
PrivateKey priKey = keypair.getPrivate();
PublicKey pubKey = keypair.getPublic();

File f = new File("c:\keystore");
// Create an empty keystore object
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());

// code to store private and public key in keystore

// Save the new keystore contents
FileOutputStream out = new FileOutputStream(keystoreFile);, password.toCharArray());

Can some one please help me with missing code.
17 years ago
I am writing a login method that will authencticate user and return token for web services. Next time user will send us token and we will validate the token but requirement is that we donot want to keep any state of token at server.What does it mean that when we receive token, we should be able to determine it is a valid token or not.(This implied token can't be forged by any user).

I have written a function using KeyPairGenerator, please have a look and let me know if you see any security issue.

Design is

token generateToken(userid) {
hash = hash(userid) ------------------- ONE
Signature = Encrypt (Private key , hash) --------------- TWO
return hash + " " + Signature

bool isValid(token) {
separate part 1 and part 2 of toekn (delimeter is space)
Signature = Encrypt (Public key , part1)
if signature == part2
token is valid
token is invalid

Code is

PublicKey privateKey ;
PrivateKey publicKey ;
KeyPairGenerator keyGen;
SecureRandom random ;
KeyPair keypair;

public String generateToken() throws Exception{

keyGen = KeyPairGenerator.getInstance("DSA");
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keyGen.initialize(512 , random);
keypair = keyGen.genKeyPair();
privateKey = keypair.getPrivate();
publicKey = keypair.getPublic();

String token = userName;
byte[] part1 = getHash(1000, token , generateSalt());

/* Create a Signature object and initialize it with the private key */
Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");

/* Update and sign the data */
dsa.update(part1, 0 , part1.length) ;

/* Generate a signature for it */
byte[] realSig = dsa.sign();

String tokenToReturn = byteToBase64(part1) + " " + byteToBase64(realSig) ;

return tokenToReturn;


public void verifyToken(String token) throws Exception{

int space = token.indexOf(" ");
String part1 = token.substring(0 , space);
String part2 = token.substring(space+1);

/* create a Signature object and initialize it with the public key */
Signature sig = Signature.getInstance("SHA1withDSA", "SUN");

byte[] bPart1 = base64ToByte(part1);
byte[] bPart2 = base64ToByte(part2);

/* Update and sign the data */
sig.update(bPart1, 0 , bPart1.length) ;

if ( sig.verify(bPart2) )
System.out.println("signature verifies: " );
System.out.println("signature does not verifies: " );

Does this code look right ??? Please let me know if you see any pitfalls or know better way to create token
17 years ago
I am trying to create Salt fo my passwords. This is my function

public byte[] generateSalt() throws Exception{

random = SecureRandom.getInstance(SECURE_RANDOM_ALGORITHM);
byte[] salt = new byte[8];
return salt;


I called this function three times in my main method , I got follwing output

Salt is [B@7d772e
Salt is [B@11b86e7
Salt is [B@35ce36

I run my program again and got same output. Every time I run my program, I get same output. What is happening, I can't understand. I set seed current time so every time I should get different numbers.
17 years ago
I have hdk 1.4 as well as jdk 1.5 in my machine.

JAVA_HOME points to jdk 1.5

I need to compile my java code using jdk 1.4.

How could I specify in build.xml to use jdk1.4 for compiling my code?

17 years ago
I am susin gnat and build id failin gwith following output

E:\axis2-1.1.1\samples\quickstartxmlbeans\build.xml:78: The system cannot find the file specified

Now I really do not know why this exception is coming. can I get the stack trace from Ant ???
17 years ago