Custom component - how to store java Properties object in ucm environment
Hi Experts,
I am developing a custom component.
my custom component code is reading a properties file and load in Properties object. Everytime this custom Service is called, properties file is read from file system and new Properties Object is created.
Is there any way to load the Properties object once and store somewhere in UCM context ? (just like we do in JSP using application object"
thanks!!
Edited by: user4884609 on Jul 12, 2010 3:01 PM
I'd say there are quite a few ways how to do it, but many of them have nothing in common with UCM.
- I'd opt for the only "UCM" way I' aware of: as a part of custom component you can create your own properties file (it's also called environment variables) as a part of your custom component. You can, then, easily read (and write?) properties from/to the file.
- The first option could have disadvantage, if there are too many properties. In this case you could use Java serialization - it should be UCM independent
- Another option is to create your properties in the database - it is a bit similar to the first option, but it's more robust. Plus, you may use features of the database if you want to have some additional logic in you properties.
- Note that you can also create a static object, which could be initialized e.g during class load
Similar Messages
-
How to store java objects in the database
Hi,
I am trying to store HttpSession state across Application Servers. Basically I am trying to build a sort of application cluster server on my own. I thought the best way to do this was to periodically store the HttpSession object from an application server in a database.
I created a table in Oracle 8i with a blob column. I use a PreparedStatement.setObject() method to store the HttpSession object in the database. My problem is, I don't know how to get the object back from the database.
Since ResultSet.getBlob returns the Blob locator, I need to read the BinaryInputStream to get all my data back. This tells me that getBlob basically works only for things like files, and cannot be used for Java objects.
Is there any way around this? Your input would be much appreciated.
Regards,
Somaiah.Thanks for the quick reply vramakanth.
Do I have to use a type map if I do this? Also does such a type map exist for the HttpSession class?
Thanks,
Somaiah. -
How to store Java ArrayList or any Collection object
Hi,
How Can I store Java ArrayList or any Collection object into Oracle tables.
In that case what should be the Oracle datatype of that column.
Can anybody tell me in details...
Thanks in advance.
Ashok RAshok,
Search this forum's archives for ARRAY and STRUCT.
Good Luck,
Avi. -
How to save a properties object to a file / how to create a properties file
hi,
i am writing an application in which all the database and user information is stored in a properties object and is later retreived from it when a database connection or login etc is required.
i wanna know how can i save this object / write it to a file i.e. how do i create a properties file.
so that every time the application is run to create a new dbase etc the entire info regarding that will be stored in a new property file.Load:
Properties p = new Properties();
FileInputStream in = new FileInputStream("db.properties");
p.load(p);
String username = p.getProperty("username");
String password = p.getProperty("password");
// ...Save:
String username = "user";
String password = "pw";
Properties p = new Properties();
p.setProperty("username", username);
p.setProperty("password", password);
FileOutputStream out = new FileOutputStream("db.properties");
p.store(out, null); // null or a String header as second argumentThe file will look something like
username=user
password=pw -
Custom ClassLoader - fails to load java/lang/Object
I have created a custom class loader based substantially on Jim Farley's code in "Java Distributed Computing" pp 39-44.
The code does get a URL connection, download the class file, but fails when it tries to load (re-load) java/lang/Object. My understanding is that the same (custom) class loader is also used to load dependent classes (needed by the class your are originally loading). I had assumed that this would be handled by the call to findSystemClass() I had assumed.
Any help or direction is appreciated,
Jeff.
Here is the output:
File=/tasks/Person.class
Host=n01
Trying to load:/tasks/Person
Check system :/tasks/Person
Not found in System:/tasks/Person
Check stream:/tasks/Person
Class file is 815 bytes.
Available = 815
RemoteClassLoader: Reading class from stream...
RemoteClassLoader: Defining class...
java.lang.ClassNotFoundException: Cannot find class definition:
java.lang.NoClassDefFoundError: java/lang/Object
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.lang.ClassLoader.defineClass(ClassLoader.java:426)
at RemoteClassLoader.readClass(RemoteClassLoader.java:83)
at RemoteClassLoader.loadClass(RemoteClassLoader.java:139)
at TestRemoteClassLoader.main(TestRemoteClassLoader.java:18)
Class was not loaded.Here is the code:
import java.lang.*;
import java.net.*;
import java.io.*;
import java.util.Hashtable;
public class RemoteClassLoader extends ClassLoader {
URL classURL = null;
InputStream classStream = null;
java.lang.Object o = null;
Hashtable classCache = new Hashtable();
InputStream source = null;
// Constructor
public RemoteClassLoader()
// Parse a class name from a class locator (URL, filename, etc.)
protected String parseClassName(String classLoc)
throws ClassNotFoundException
String className = null;
try { classURL = new URL(classLoc); }
catch (MalformedURLException malex) {
throw new ClassNotFoundException("Bad URL \"" + classLoc + "\"given: " + malex);
System.out.println("File=" + classURL.getFile());
System.out.println("Host=" + classURL.getHost());
String filename = classURL.getFile();
// Make sure this is a class file
if (!filename.endsWith(".class"))
throw new ClassNotFoundException("Non-class URL given.");
else
className = filename.substring(0,filename.lastIndexOf(".class"));
return className;
// Initialize the input stream from a class locator
protected void initStream(String classLoc)
throws IOException
classStream = classURL.openStream();
// Read a class from the input stream
protected Class readClass(String classLoc, String className)
throws IOException, ClassNotFoundException
//See how large the class file is.
URLConnection conn = classURL.openConnection();
int classSize = conn.getContentLength();
System.out.println("Class file is " + classSize + " bytes.");
// Read the class bytecodes from the stream
DataInputStream dataIn = new DataInputStream(classStream);
int avail = dataIn.available();
System.out.println("Available = " + avail);
System.out.println("RemoteClassLoader: Reading class from stream...");
byte[] classData = new byte[classSize];
dataIn.readFully(classData);
// Parse the class definition from the bytecodes
Class c = null;
System.out.println("RemoteClassLoader: Defining class...");
try{ c = defineClass(null, classData, 0, classData.length); }
catch (ClassFormatError cfex) {
throw new ClassNotFoundException("Format error found in class data.");
catch (NoClassDefFoundError clsdeferr) {
clsdeferr.printStackTrace();
throw new ClassNotFoundException("Cannot find class definition:\n" + clsdeferr);
return c;
// load the class
public Class loadClass(String classLoc, boolean resolve)
throws ClassNotFoundException
String className = parseClassName(classLoc);
Class c;
System.out.println("Trying to load:" + className);
//maybe already loaded
c = findLoadedClass(className);
if (c!=null) {
System.out.println("Already loaded.");
return c;
c = (Class) classCache.get(className);
if (c!=null) {
System.out.println("Class was loaded from cache...");
return c;
System.out.println("Check system :" + className);
// Not in cache, try the system class...
try {
c = findSystemClass(className);
if (c!=null) {
System.out.println("System class found...");
classCache.put(className, c);
return c;
catch (ClassNotFoundException cnfex) {
System.out.println("Not found in System:" + className);
; // keep looking
System.out.println("Check stream:" + className);
// Not in system either, so try to get from tthe stream
try {initStream(classLoc); }
catch (IOException ioe) {
throw new ClassNotFoundException("Failed opening stream to URL.");
// Read the class from the input stream
try {c = readClass(classLoc, className); }
catch (IOException ioe) {
throw new ClassNotFoundException("Failed reading class from stream: " + ioe);
// Add the new class to the cache for the next reference.
classCache.put(className, c);
// Resovle the class, if requested
if (resolve)
resolveClass(c);
return c;Never mind - I've figure it out.
The problem is that the ClassLoader calls RemoteClassLoader.loadClass() to load in java.lang.Object, which is fine. But, my code tries to first create a URL from this, which fails, eventually throwing a NoClassDefFoundError.
I have fixed it by delaying the call to parseName() until after checking loaded classes and system classes. -
How to configure Java Properties File location in WLW
How do we tell Workshop 7.0 where to look for Java properties files (loaded by
PropertyResouceBundle in code) ?
Thanks,
RayRay,
The build number indicates that you have not upgraded to Service Pack 2 of
version 7.0. I will strongly recommend you to do so. That will shield you
from the issues which were fixed in the 2 service packs.
Regards,
Anurag
"Ray Yan" <[email protected]> wrote in message
news:[email protected]...
>
Raj,
We are using WebLogic Workshop Build 7.0.1.0.0829.0 on Windows 2000.
We shut down the WebLogic Server on Solaris 2.6, log off, log back on,startWebLogic
in production nodebug mode, and re-run jwsCompile on the same source code.The
error does not occur anymore. Everything seems to be fine now.
Thanks,
Ray
"Raj Alagumalai" <[email protected]> wrote:
Hello Ray,
Can you let me know if you are using the GA version of WebLogic Workshop
or
if you have the latest Service Pack.
Thank You,
Raj Alagumalai
WebLogic Workshop Support
"Ray Yan" <[email protected]> wrote in message
news:[email protected]...
Anurag:
Thanks for your response!
By moving the property files to WEB-INF/classes from WEB-INF, we arealmost there.
But we have a follow up problem. We use a static initializer to loadthe
log4j
property file like this:
static {
try {
ClassLoader cl= (new Log()).getClass().getClassLoader();
InputStream is = cl.getResourceAsStream(logfile);
Properties props = new Properties();
props.load(is);
PropertyConfigurator.configure(props);
} catch (Exception e) {
e.printStackTrace();
When we run jwsCompile, we keep getting this:
Compiling: com/****/TestWS.jws
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[weblogic.management.Admin
may only be used on the Server ]
at weblogic.management.Admin.getInstance(Admin.java:104)
at
weblogic.security.internal.ServerPrincipalValidatorImpl.getSecret(ServerPrin
cipalValidatorImpl.java:79)
at
weblogic.security.internal.ServerPrincipalValidatorImpl.sign(ServerPrincipal
ValidatorImpl.java:59)
at
weblogic.security.service.PrivilegedActions$SignPrincipalAction.run(Privileg
edActions.java:70)
at java.security.AccessController.doPrivileged(Native Method)
at
weblogic.security.service.SecurityServiceManager.createServerID(SecurityServ
iceManager.java:1826)
at
weblogic.security.service.SecurityServiceManager.getServerID(SecurityService
Manager.java:1839)
at
weblogic.security.service.SecurityServiceManager.sendASToWire(SecurityServic
eManager.java:538)
at
weblogic.security.service.SecurityServiceManager.getCurrentSubjectForWire(Se
curityServiceManager.java:1737)
at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:434)
at
weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
88)
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:255)
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:230)
at
weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown
Source)
atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
at javax.naming.InitialContext.lookup(InitialContext.java:345)
at weblogic.knex.bean.EJBGenerator$1.run(EJBGenerator.java:101)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:780)
atweblogic.knex.bean.EJBGenerator.lookupAdminHome(EJBGenerator.java:84)
atweblogic.knex.bean.EJBGenerator.ensureAdminHome(EJBGenerator.java:122)
at weblogic.knex.bean.EJBGenerator$6.run(EJBGenerator.java:660)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:821)
atweblogic.knex.bean.EJBGenerator.generateJar(EJBGenerator.java:482)
at
weblogic.knex.dispatcher.DispJar.generateJar(DispJar.java:401)
atweblogic.knex.dispatcher.DispCache.ensureDispUnit(DispCache.java:695)
atweblogic.knex.compiler.JwsCompile.compileJws(JwsCompile.java:872)
at
weblogic.knex.compiler.JwsCompile.compile(JwsCompile.java:619)
at weblogic.knex.compiler.JwsCompile.main(JwsCompile.java:109)
ejbc successful.
Generating EAR ...
The EAR was generated and we can even deploy it on Solaris. But whatdoes
the
AssertionError mean?
Thanks,
Ray
"Anurag Pareek" <[email protected]> wrote:
Ray,
ResourceBundle looks for the properties file in the current thread's
classpath.
Since a Workshop webservice's project is nothing but a webapp, the
properties files can be kept in the WEB-INF/classes directory, which
is part
of the webapp classpath.
You can also use
Thread.currentThread().getContextClassLoader().getResourceAsStream("MyProp
s
properties"); to get access to the properties file.
Thanks,
Anurag
"Ray Yan" <[email protected]> wrote in message
news:[email protected]...
How do we tell Workshop 7.0 where to look for Java properties files(loaded by
PropertyResouceBundle in code) ?
Thanks,
Ray -
How to load Java properties file dynamically using weblogic server
Hi,
We are using Java properties file in Java code. Properties in java properties file are frequently modified. If I keep these properties file in project classpath or as part of war, I will have to redeploy application after each change.
We are using Weblogic Server.
Can you please suggest me how can this properties file be loaded at weblogic server startup. Then in that case, how to refer property file in Java code?
What is the best practice for this?
Thanks,
ParshantAnother alternative is, keep the property file in any pre-defined location. Write a class which reads the properties from the file and returns the one which is requested by caller and deploy this class. Whenever you have to change the properties just update the property file on server and next call to fetch the property should return the updated one.
Downside of this approach is file I/O everytime. To overcome that you can actually "cache" the properties in a hashmap. Basically when any property if requested, first check the hashmap, if not found then only read from property file and also update in hash map. Next time same property will be returned from hash map itself. The hash map will be cleared at every server restart since its in the memory. You will also need to build a method to clear the hashmap when you update the values in the property file on server.
This solution would be suitable for small size files and when network overhead of calling a DB needs to be avoided. -
How to store java object in oracle
Hi all,
is it possible to store jva object in oracle.
I have defined myClass. It have only data fields ( no methods).
I make myClass myObject = new myClass();
How can I store this object in oracle DB.
Many thanks in advance.1.Convert this object into stream of Bytes.
2.create a new InputStream from these Byte array.
2.Use the setBinaryStream to set the values inside the table's column.
3.Store this object as a Blob in the table (column type must be Blob).
Hope this helps.
Sudha
PS:- Somebody explained in this forum how to convert an Object into Byte array . -
How to Store java.util.Map object using JPA
Hi
I have a cache where the underlying object is just a map (HashMap for example).
I'd like to create a JPA backing store for this cache.
Is there a way to do that, or can JPA only store objects that are JPA annotated?
Thanks
Edited by: mesocyclone on Dec 11, 2008 4:22 PMHi,
I believe that the objects that the Map contains would need to be JPA annotated.
--Tom -
How data stores in info object
Hi all
How can an Infoobject characteristic created without master data and texts.And in same wayi need to store the data in the infoobject
regards
ashwinHi Ashwin,
Normally while creating(Activating) info object in background tables has been created for each one.
Suppose for example you IO name is like this ZIO_MID
for this info object the Master data table will be like this,
/BIC/MZIO_MID --> Master data view
/BIC/PZIO_MID --> Time independent object
/BIC/QZIO_MID --> Time dependent object
For SID tables will be created like this,
/BIC/SZIO_MID --> SID table view
/BIC/XZIO_MID --> Time independent sid object
/BIC/YZIO_MID --> TIme dependent object
For this object Text table will be created like this,
/BIC/TZIO_MID --> Text table view
you can directly enter these table name in SE11 and you can directly insert your values also.
While creating infoobject you can unselect those options of "WIth Master data" and " With Texts" .
If you want to maintain data within this objects , Right click your info object maintain master data and execute and click create button , Insert your values.
NOTE: Assign points if it helps
Regards,
Arun.M.D -
How To Store dom4j.Document Object in MySQL Database?
Hi Everyone, i am currently using dom4j to create an xml document object i wish to hold the object in a mysql database using jdbc, however the document object does not implement serializable, i am having difficulty in storing the document object as a BLOB object within the database, any suggestions?
any help or advice would be greatly appreciated
ThanksConvert the Document object to String and store the XML string in MySQL database.
-
Custom Component : How to detect what charset the request used?
I want to write a file upload component, this component must use the same charset as the request used to decode file name from data post from web browser, How to detect what charset the request used?
Hi Eddie,
As Arjit suggested, there are a bunch of functions available in WEBI like GetDominantPreferredViewingLocale(), GetLocale() and GetPreferredViewingLocale(), etc. that you could use.
There are no such specific functions provided within Dashboards tool.
So, you can create a WEBI report, and have one of these formulas specified in a variable in the webi report. Then, have the block published as a BIWS and use this BIWS in your dashboard. -
How to handle java.lang.IndexOutOfBoundsException in eclipse environment?
while runnig my java application, iam getting the above exception. But i am unable to find the root location, from where exactly the error is coming (when clicking on that exception in console,a popup window appearing and showing some options).. plz help me how to proceed !!
otherwise tell me where to post this!avula wrote:
i didn't write LogWorker .java. iam running my application in debug mode. but when it comes to the exception, the control simply goes into the "ArrayList.class" and stopping at the
private void RangeCheck(int index) {
if (index >= size)
throw new IndexOutOfBoundsException(
"Index: "+index+", Size: "+size);
Ok, so that's where the problem occurs. Now you should see the call stack (similar to a stack trace) of the method (usually in the upper left corner). There you can see which method called this method, which called that one ... and so on.
Follow that stack to find out why the problem occured (usually it's the first line that is in code that you wrote). -
How to call java application in Windows NT environment?
I have a JDBC application running against oracle database on NT server. There is another non-java application need to call my java application. The programs that non-java program can call are .exe, .dll, and .bat files. I wrote a Dos script and save it as .bat file. Every time this .bat file was called, the dos screen will be shown. Anything I can do to let Dos screen not shown, or anything I can do to wrap my java classes into an .exe file? Thanks in advance.
If your tool can run a .exe and supply arguments, why not simply invoke "javaw <jvm-args> <class> <class-args>"?
-
Ho to store java objects in oracle database
HI
for me the sceanario is,
i neeed to create , dynamically a table at the time of specified action.
i need to store the values retreieved from session and store it in a database..
for example
User usr=session.getAttribute("usr"); i need to store the user object.
and hashtable and hashmap values without iterating.
please suggest at the earliest
can it be done?
Regards,
Rameshmy requirement is like that,bcos of two different weblogic servers need to acess the central database.which contains user information.
The user object from first server will be stored in database.and the second server will retrieve the user information and it will set for its application.
please suggest me how to store java objects in database.
regards,
Ramesh
Maybe you are looking for
-
When I click on the print icon or file-print, nothing happens at all.
-
HP Laserjet Pro 100 MFP M175nw
Hi, I am having problems connecting the printer wirelessly to the MacBook Pro. I have downloaded the printer software and everything seems to be set up ok. In the System Preferences it reconises the printer and says the printer is ready or idol. But
-
Hello, could you please help me find the way to set default filter over a specifed colum in CRM 7.0 on a table view? It should work just like a manual created filter, but it should exists already by first call of a view with table. I tried following
-
Question about java reflection and "int" type
hi, using reflections I should invoke a Method (meth3) that have as parameter an INT type (not integer). I've tryed with this code: int num = 3; Class[] vettClax = {int.class}; Object[] vett
-
What is the security code on credit card
I am trying to purchase a book. I try to put Credit Card security card # in to no avail. What am I doing wrong?