Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share properties file among slaves in domain mode Wildfly10

In domain mode , I am able to use properties file as a module but the problem is if there is any modification in the file then i'l need to do it for all slaves in the domain. I want to centralize the file so that at one point I can change and it will be reflected on all slaves.

I know in domain.xml we can configure global level system properties but I have around 25 properties files.

So is there a way to centralized the files??

myjar.jar
-->package
   --> class
-->properties
   -->xml files

myjar.jar is an archived jar file To fetch the xml files

 URL url = Thread.currentThread().getContextClassLoader().getResource("./properties");

File queryFolder = new File(url.getFile());

for (File fileName : queryFolder.listFiles())  // null pointer exception
{
    if (fileName.getName().toUpperCase().endsWith("XML"))
    {   
            saxParser.parse(fileName, this);
     }
}

This is not working.

Tried this

How do I list the files inside a JAR file?

And facing the same problem given in below link

JBoss wildfly 8.x Provider "vfs" not installed when using java nio Paths

URL w_url = mmyClass.class.getProtectionDomain().getCodeSource().getLocation();
            JarEntry w_ze = null;
            LOGGER.info("Jar******************" + w_url.toString());
            if (w_url.toString().endsWith(".jar")) 
            {
                try (JarInputStream jar = new JarInputStream(w_url.openStream())) 
                {
                    while ((w_ze = jar.getNextJarEntry()) != null)
                    {
                        LOGGER.info("Name *******" + w_ze.getName());
                    }
                }
                catch(Exception e)
                {

                }
            }
like image 717
happy Avatar asked Nov 08 '22 18:11

happy


1 Answers

Added properties folder inside a war file and fetched the exploded folder path using below code in the servlet of the war file.

config.getServletContext().getRealPath("/");

This gives the vfs path of the folder.

and configured the same in

System.setProperty("REALPATH", config.getServletContext().getRealPath("/"));

and used the same in the jar file.

like image 95
happy Avatar answered Nov 14 '22 22:11

happy