• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to EJB link up error  RSS feed

 
Peter Reynolds
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have compiled an EJB and successfully run at as a console command line app but when I try and run it a JSP page and access I get the error:
500 Internal Server Error
Error parsing JSP page /peter/jsp/counter/index.jsp
Syntax error in source/jsp/counter/index.jsp.java:94: Undefined variable or class name: custom (JSP page line 55)countVal = custom.getCounterNum(); ^1 error

Also in web.xml I have a section:
<ejb-ref>
<ejb-ref-name>PRCounter</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>PRCounterHome</home>
<remote>PRCounter</remote>
</ejb-ref>
I have run a demo and it worked and then copied it for my own ejb but I can not see at all what the problem as it seems identical!
I am running Orion server as this is what's required. Hopefully there is a fair bit of standardness between servers such as required xml files.
Any ideas about this error? Thanks !
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Syntax error in source/jsp/counter/index.jsp.java:94: Undefined variable or class name: custom (JSP page line 55)countVal = custom.getCounterNum(); ^1 error

Looks like you have not defined custom. While using a class in jsp u need to define the class and associate it with the request/session/application attribute. U might be knowing this...but just make a check and see if u have defined it like..

<jsp:useBean id="custom" class="x.y.OriginalCustom" scope="session">
</jsp:useBean>

lemme know if this doesnt fix the error..along with ur jsp code..
regards
mpr
 
Peter Reynolds
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will use my hello one as i get the same error and is a session bean instead of entity.
Also there is a variable defined for the class but maybe I am using wrongly!?
I have zipped up the whole folder of code (22kb) if it helps to get that and look at http://www.preynolds.com/peter.zip

Tried pasting code with [code] tag but doesn't appear. Maybe better to get it from link above.
Code is not in any archive like .jar or .ear as it works fine without it. Like the cart demo in the zip above.
[This message has been edited by Peter Reynolds (edited July 30, 2001).]
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing wrong with the EJB. Your problem is entirely in the JSP named "index.jsp". It's looking for an undefined variable named "custom" or a "custom.class" file created from "custom.java". Don't forget Java names are case-sensitive!).
[This message has been edited by Tim Holloway (edited July 31, 2001).]
 
Peter Reynolds
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim Holloway:
There's nothing wrong with the EJB. Your problem is entirely in the JSP named "index.jsp". It's looking for an undefined variable named "custom" or a "custom.class" file created from "custom.java". Don't forget Java names are case-sensitive!).
[This message has been edited by Tim Holloway (edited July 31, 2001).]

Well I cannot say it is looking for custom.class since I have specified another name in the narrow method and also since custom is a variable.
Instead it would be the JSP not creating the EJB. This is what is driving me crazy because I followed the demo. Even copied the demo files and modified to my needs and it couldn't find EJB. The EJB is fine since it runs as a console app.
Any ideas why the JSP isn't finding the the EJB. Maybe you could checkout the cart and hello files from the zip in the previous post to compare. Cart is a demo that came with the server and works while hello is mine and not working.
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey..i tried to set ur src code up with weblogic 5.1 and since the deployment descriptors and dependencies r too much..i left it half way.
Well, i can ask you two things to do. I'm sure that the exception u r seeing is compile time exception. So why dont u see the orion docs and look at the classpath the jvm compiler is using when it tries to compile ur jsp.
Alternatively you can open the _index.java page for the corresponding index.jsp page and see the code and infer on whats missing. Something tells me the jsp compiler doesnt have the necessary classpaths to lookup the bean while compiling...
Hope i hear from u if the hunt gets worser.
thx
mpr
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer to your problem is that the variable custom is out of scope when it is being accessed on line 54 of index.jsp. If you look at your code in index.jsp, custom is declared inside a try block, and line 54, where you are trying to do countVal = custom.getCounterNum(); is outside of that try block. Unless I'm missing something here, it is just simply out of scope. Maybe try declaring custom = null outside of the try block.
 
Peter Reynolds
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by BJ Grau:
I think the answer to your problem is that the variable custom is out of scope when it is being accessed on line 54 of index.jsp. If you look at your code in index.jsp, custom is declared inside a try block, and line 54, where you are trying to do [b]countVal = custom.getCounterNum(); is outside of that try block. Unless I'm missing something here, it is just simply out of scope. Maybe try declaring custom = null outside of the try block.[/B]

Yep the variable was defined in the try block!! Arghhhh. Not even a J2EE specific error, just so easy to over look things sometimes.
Anyway thanks heaps BJ Grau for the clue and Manjunath Reddy for sticking around looking at the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!