Advertisement

08.09.2007 at 10:39AM PDT, ID: 22752715 | Points: 500
[x]
Attachment Details

JBoss and JNDI using pojo javabean

Tags: jndi, jboss, pojo
Hello, this question is two part.

Part 1: How can I place a simple custom java object in jndi on jboss 4?  In Tomcat is could not be easier.  I simply have

< Context path="/myApp" ... >
   < Resource name="myPath/MyObject"
         auth="Container"
         type="com.myco.MyObject"
         factory="org.apache.naming.factory.BeanFactory"
         location="localhost"/>  // this line will call getLocation in MyObject after instantiating it.
</Context>

Now to use this I simply:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
MyObject myObj = (MyObject) envCtx.lookup("myPath/MyObject");

Part 2: The above Tomcat config is very nice since it is app context specific.  I can now take myApp.war and copy/paste it as myAppQA.war.  No app config at all.  I simply add another context to server.xml except I change the name to myAppQA and the location="localhost" to location="www.where-ever.com".  Then when ever I deploy the either myApp or myAppQA it will get the different object even though the application code points to the same name.  In JBoss, it looks like any jndi reference is to be setup as app server wide, not app context wide.

I'm really stuck on this as I'm new to JBoss.  Thanks in advance.
Dale



Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: dbronk_winscape_com
Question Asked On: 08.09.2007
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
08.13.2007 at 05:01AM PDT, ID: 19683097

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.13.2007 at 05:48AM PDT, ID: 19683441

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.13.2007 at 10:14AM PDT, ID: 19685912

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
08.13.2007 at 05:01AM PDT, ID: 19683097
HI,

I believe that what you need is an <env-entry> in your web.xml file.

Best regards,

valipotor
 
08.13.2007 at 05:48AM PDT, ID: 19683441
But is there a way to set this at the server level like Tomcat allows?  Tomcat is beautiful about this.  In the server xml I can simply add a Resource entry to the context and then when the server comes up it will instantiate the class and inject any values placed in the Resource node into the object.  It then places that object into jndi.  This is awesome with Tomcat because now I can simply place my server configs, ie: database settings, and other server specific settings that would normally change when moving through dev, qa, prod, etc.  By adding a <env-entry> in my web.xml means that I have to configure before I deploy to each environment.  My way I configure one time and never again.

Since jboss uses tomcat I was hoping there was a way to do this.

Thanks,
Dale
 
08.13.2007 at 10:14AM PDT, ID: 19685912
Well, in this case you should use a similar approach.

http://www.codechimp.net/?p=13

Basically, in the above example, the Spring configuration is loaded and added to JNDI in order to be available to all other deployed applications.

The initial settings for the parameters can be specified in the MBean XML file.

JBoss also offers a web console which alowes you to invoke methods on the MBean you have created.

Hope this helps you,

valipotor
 
 
20080236-EE-VQP-29 / EE_QW_1_20070628