Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a managed bean from a referenced project

 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working in Eclipse on a JSF project. I have a POJO I want to reference from another project in my workspace. I've added this project to my build path in the Eclipse project properties. If I attempt to reference the class in the external project in the managed-bean-class element, it isn't found. I can create the POJO in the same project, change the namespace to the local project, and it works fine. I can only assume I'm missing a needed reference. Any help would be greatly appreciated.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse has absolutely zero to do with running a JSF webapp as far as cross-referencing projects are concerned. No matter what you define in Eclipse, it won't get referenced come runtime. The only things that your webapp container and the webapp itself can locate are items in the deployed application or in the webapp container's CLASSPATH chains.

On the other hand, if what you really mean is that you have created some sort of component that you want to deploy as part of a webapp, but the component is constructed outside of the project where you're building the webapp itself, you need to tailor the webapp build process so that the constructed component will be copied into the resulting deployable unit. In other words, if I made a Google Maps JSF tag component (which actually, I have) and made it a drop-in component in a JAR, I would copy that JAR into my webapp build. If the actual Google Maps component JAR is built in a different Eclipse project, about the only things Eclipse will do for me is allow me to get at the internal symbols for debugging purposes and ensure that any automated dependent build processes get done in the proper order (most of my deployables are built with Maven or Ant, so that's of limited use to me).
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,

That makes sense. I'm currently running my application in Tomcat using the built-in server functionality with Eclipse. I suspect I'll need to somehow alter that "run" process to include a custom Ant script. Is that the correct path to take, or is there a better way?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a "run" thing, it's a "build" thing. Doesn't matter if you use Eclipse, Ant, or even DOS batch files.

The Tomcat that Eclipse is running is still Tomcat - just launched and managed by Eclipse - and it's still subject to the same constraints that every other J2EE container is. Which is that if you want an application to be able to see something, it has to be party of the application's deployment unit (WAR). No peeking outside.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a "run" thing, it's a "build" thing. Doesn't matter if you use Eclipse, Ant, or even DOS batch files.

The Tomcat that Eclipse is running is still Tomcat - just launched and managed by Eclipse - and it's still subject to the same constraints that every other J2EE container is. Which is that if you want an application to be able to see something, it has to be party of the application's deployment unit (WAR). No peeking outside.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic