This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Run-time error with useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Run-time error with useBean" Watch "Run-time error with useBean" New topic
Author

Run-time error with useBean

Ajem Jehi
Greenhorn

Joined: Sep 06, 2013
Posts: 10
When I tried to follow J2SE tutorial on JSP and instantiated a bean on line 28 with



the project (consisting of ejb and web app) compiled, but I got a run time error.
When I used NetBeans code completion to build the above command, it saw the packagebame package, ejbClassName within that package, and even saw the property under classId variable.
Then it threw the error, like I said:



What am I doing wrong?
Ajem Jehi
Greenhorn

Joined: Sep 06, 2013
Posts: 10
Actually, it seems to me that the error is run-time. But being new to JSP I might be mistaken.
The error is thrown when I access JSP in the browser.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Hi Ajem!

Welcome to Javaranch!!

Can you tell us how the structure of you war file looks like?

When you start studying web components it is advisable to build you war files by hand. This way you will learn and understand where to put files in the standard war structure. When you use an IDE like Netbeans or Eclipse a lot of details are hidden from you.

Just have a look at How to create a Web Application without an IDE.

Regards,
Frits
Ajem Jehi
Greenhorn

Joined: Sep 06, 2013
Posts: 10
Someone told me that in order for the package to be found, it has to be under WEB-INF/classes
I created WEB-INF/classes/packagename directory and copied over the *.class files (or simply copied entire package directory over).
Was still getting error instantiating EJB.
What I found was that both



and



were required for the class to be instantiated while package folder was under WEB-INF.
Everything is working now even though I am getting annoying errors from NetBeans about WAR deployment failing.
Those can be solved by Clean/Build on the whole app and re-copying the package folder. What a mess!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Someone told me that in order for the package to be found, it has to be under WEB-INF/classes

That is correct, and you don't have to import them in your jsp.

Things get messy if you interfere (by copying the class files yourself) with the normal NetBeans setup. Just follow my advice and build your war by hand by using notepad and tomcat.

Regards,
Frits

Ajem Jehi
Greenhorn

Joined: Sep 06, 2013
Posts: 10
Frits Walraven wrote:
Things get messy if you interfere (by copying the class files yourself) with the normal NetBeans setup. Just follow my advice and build your war by hand by using notepad and tomcat.


Quite amazingly, once I added a servlet to the web application of that project, I no longer need to copy over the package directory with the EJB classes and everything works without them under WEB-INF. The project just requires clean/build every time I change something (i.e. autodeploy does not work).
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

I guess by adding the Servlet, NetBeans decided that it had to be deployed as a war file...

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run-time error with useBean
 
Similar Threads
EJB 3.0 and jsp
package com.sun.faces.taglib.html_basic does not exist
Netbeans, Glassfish don't want to access my enterprise beans
netbeans 6.1......jsp......java beans package
JSP - Unable to solve error