we have dependency on external customized jar file and that jar file is dependent on some property files. So where should we keep these property files ? We tried to keep it ..\crx-quickstart\conf on this path but its giving "Can't find bundle for base name environment, locale en_US" this exception
Views
Replies
Total Likes
Could you please explain your use case?
Are these customized jar files hosted in AEM as bundles? Are you using AEM jar or AEM war file in a container?
we have dependency on customized external jar (which is belong to some other team) .The jar is having dependency on property files which are not bundles within jar.They are sharing property files separately along with jar.They are loading property files in their jar using getBundle() from ResourceBundle Class which is java library class.Now we are facing issue where to keep those property files?
we tried with different approaches
* by keeping property files in src/main/resources in aem.core project
* placed in ..\crx-quickstart\conf
Both approaches didn't work well...
Please Do help me...
To me, that doesn't seem a recommended way of working with AEM.
You could also use BundleContext to read the properties file. Put the file in bundle classpath.
Try couple of things:
package the property file within the jar file and add relative path of file in bundle classpath entry in manifest file of that bundle.
if you want to use /conf path to read the property file then use SystemClassLoader
java - How to use a property file in an OSGi bundle - Stack Overflow
When working with OSGi bundles that use 3rd party JARs (that are located in the Maven Repository), you can embed the 3rd party JAR (for example, Simple JSON JAR) into a separate bundle and deploy to AEM. See this community article/video for details.
http://scottsdigitalcommunity.blogspot.ca/2013/06/posting-form-data-to-adobe-cq-using.html
Do not place the 3rd party JAR into a path in the JCR. Wrap it into an OSGi bundle and deploy to AEM - as we show Simple JSON JAR in the above article.
As Gaurav said it's not the recommended AEM way although would be helpful to understand more if you provide the lines of code that show how property file being accessed or read?
following code is used in dependent jar to load property files(The jar is binded with out property files)
ResourceBundle rb = ResourceBundle.getBundle("property file name");
String keyDetail = rb.getString("Key name");
we have to use dependent jar in our AEM project so we converted jar as OSGI bundle without property files, we cannot ask other team to use BundleContext to load property files since so many applications are using same jar.
is there any way to load external jar along with property files in AEM server
Use "Bundle-ClassPath"
What is the intended use case for Bundle-Classpath in OSGI bundles - Stack Overflow
If another team is not including property file in the same jar then you can try below code.
Store config.properties file somewhere on the server and read it via InputStream in your OSGi custom bundle
Properties properties = new Properties();
InputStream inputStream = new FileInputStream("D:/properties/config.properties");
properties.load(inputStream);
String departmentName = properties.getProperty("departmentName");
Views
Like
Replies
Views
Likes
Replies