Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

where to put properties filesthat are being used by external customized jar files

Avatar

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
rasikawanjari
Level 2

05-04-2019

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

Replies

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

05-04-2019

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?

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

05-04-2019

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.

Avatar

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
rasikawanjari
Level 2

07-04-2019

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...

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

08-04-2019

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

cq5 - Using properties file in osgi bundle - Stack Overflow

Adobe CQ/Adobe AEM: How to work with Configurations in CQ

Avatar

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile
BrijeshYadav
Level 4

08-04-2019

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?

Avatar

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
rasikawanjari
Level 2

08-04-2019

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

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

08-04-2019

Avatar

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile
BrijeshYadav
Level 4

08-04-2019

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");