• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoSuchFieldException & IllegalArgumentException  RSS feed

 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there !

A little problem gives me headaches.

I get this error :


when running the following class:


In ObiectPersistent class the idLinieBD is defined like this



if i change from protected to public i get this error:


Can anyone help me please ?! I am new to Java and i have to do this

Thank in advance !
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

The problem is is the ObjectPersistent class, not in the code you've shown us here; what does the getObjects() method look like?
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is :

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is line 164 in ObjectPersistent? There are two calls to "set", one which looks obviously correct, and another which might not be, depending on the data we can't see. I bet the one that's failing is the one in the loop, not the one after the loop.

Note that you can (and should) leave that field private; you just have to call setAccessible(true) on the Field object before calling "set". You might need to do this on all your Field objects.

Have you considered using something like Hibernate? Why code all this stuff by hand?
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 163 and 164 :


I am really new to java and i am trying hard to do a projects using JSP Struts with Oracle Database. I have taken this code from a book, and tried to adapt it for my needs. I don't really see the problem, but maybe you'll help me...

So, you think i should declare all protected variables to private?
idLinieBD should be setAccessible(true) in getObjects() function ?

Here is the entire code for ObiectPersistent.java



Any advice is welcome ! Thank you again for your attention !

[ January 28, 2007: Message edited by: Simionu Ursache ]

[ January 28, 2007: Message edited by: Simionu Ursache ]
[ January 28, 2007: Message edited by: Simionu Ursache ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if we're trying to debug this, then your stack trace shows an error due to a call to "set" at line 371. This isn't due to "set" call that sets to the rowid attribute, but to the other one in the loop. It would help to know what the arguments to "set" were when the exception happens, yes? So at line 371, insert some debug print statements like this:

System.out.print(numeAtributTabela);
System.out.print(" ");
System.out.flush();
System.out.print(valoareAtribut.getClass().getName());
System.out.print(" ");
System.out.println(valoareAtribut);
atributObiect.set(obiectNou, valoareAtribut);

The last line of output before the stack trace will then tell you what attribute was being set, and to what value, and that should explain the "IllegalArgumentException". If you get a new NullPointerException, then that means valoareAtribut was null, which is also useful information.
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i did that and this is what i got :


So, in TestModelBD.java i am selecting the row from Compartimente table that have compartid = 1003 :

select * from compartimente where compartid = 1003;

COMPARTID NUMECOMPARTSALORARSALORARCOGRADLIBE COMPARTIDPAR
1003 Rector12.0010.00 2 1001

From the output of the ObiectPersistent class all of this info is displayed. After that in TestModelBD i am query-ing all the rows from Personal table that have compartid = 1003

select * from personal where compartid = 1003

MARCANUMEPRENCOMPARTIDDATASV
105Rector 1003 4/6/1980

As you can see in the error the output stops at the date, so this should be the problem ? In the output the variable type of datasv is java.sql.Date, and in Personal class i have declared it java.sql.Timestamp.



Could this be the problem ?
[ January 30, 2007: Message edited by: Simionu Ursache ]
 
mita baston
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[edited by fred]
Pleae remember that this is an English only site. I have removed your post for that reason.
[ February 01, 2007: Message edited by: Fred Rosenberger ]
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what post ?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simionu: Mita's original post was in Romanian. Fred has removed the content that was there, and replaced it with his own message (which was directed at Mita, not you).
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry - I should have made that clearer
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!