Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Run-time error with useBean

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess by adding the Servlet, NetBeans decided that it had to be deployed as a war file...

Regards,
Frits
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic