-
1. Re: Creating URL Resource
peterj Jun 26, 2008 3:47 PM (in response to njtajboss)Here is one way (there are many others). Add something like -Dmy.property.file=<location-of-file> to the JAVA_OPTS in the run script. Then in your app, use:
String propFile = System.getProperty("my.property.file"); -
2. Re: Creating URL Resource
njtajboss Jun 26, 2008 3:59 PM (in response to njtajboss)Let me be more specific...
The code is something like this
String propertyUrl = "url/myURLFilePprocessor";
ic = new InitialContext();
java.net.URL url = (java.net.URL) ic.lookup(propertyUrl);
if (url != null) {
propertyFile = url.getPath();
logger.info(" PROPERTY FILE NAME IS : " + propertyFile);
}
In Websphere there is way to create the url resource wherein you can define the file location for the url jndi...how do u do it in jBoss? -
3. Re: Creating URL Resource
peterj Jun 26, 2008 4:14 PM (in response to njtajboss)Oh, so you are looking for a way to load values into the JNDI tree. There is no such service in JBossAS, as far as I know.
-
4. Re: Creating URL Resource
njtajboss Jun 26, 2008 4:18 PM (in response to njtajboss)There has to be something....like for defining DataSources we put the xml in the deploy folder similary for the url jndi there must be something...its a vv old technology
-
5. Re: Creating URL Resource
peterj Jun 26, 2008 11:20 PM (in response to njtajboss)I agree that JNDI is an old technology, but there is still no service within JBossAS that you can use to define generic JNDI contents.
-
6. Re: Creating URL Resource
njtajboss Jun 27, 2008 4:51 PM (in response to njtajboss)alright so what do u suggest - we need to read a property file but we donot wanna hardcode the file location in the javacode/ear
-
7. Re: Creating URL Resource
peterj Jun 27, 2008 6:44 PM (in response to njtajboss)I already gave such a suggestion - see my first reply.
-
8. Re: Creating URL Resource
njtajboss Jun 30, 2008 9:27 AM (in response to njtajboss)Peter thanks for the prompt responses. is any othet way as the above solution is specific to jboss . We plan to port our same code base to both jboss and websphere...looking for a generic solution...thanks for ur help again
-
9. Re: Creating URL Resource
peterj Jun 30, 2008 11:37 AM (in response to njtajboss)My solution is generic. It does not depend on any features found in any application server. It relies entirely on the system property capability build into the JVM itself. Thus the Java code is the same for all app servers.
True, each app server uses a different mechanism to start the server, and thus how you get the system property to the JVM is different for each one. But that is usually a script file which is easy to change.
And also, if JBossAS did have a general JNDI initialization service, you would still have to configure JBossAS differently from WebSphere. So no matter what, you will have to do something differently to configure each app server to get the property file name.