Standalone jason jar and logging properties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Standalone jason jar and logging properties

davide
This post has NOT been accepted by the mailing list yet.
Hi, i'm developing a tool using jason and i've deployed it to a standalone jar application. However, even if I included logging.properties file into the jar application (where I enabled only the console logger), executing the application still produces a java.awt.HeadlessException, so it's supposed to work with the GUI. Consider that the application must run on a linux server machine without x server.

Thanks,
davide
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Standalone jason jar and logging properties

davide
This post has NOT been accepted by the mailing list yet.
EDIT:

i noticed this piece of code into the method setupLogger in RunCentralisedMAS.java:

if (new File(logPropFile).exists()) {
                try {
                    LogManager.getLogManager().readConfiguration(new FileInputStream(logPropFile));
                } catch (Exception e) {
                    System.err.println("Error setting up logger:" + e);
                }
            } else {
                try {
                    LogManager.getLogManager().readConfiguration(RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream());
                } catch (Exception e) {
                    System.err.println("Error setting up logger:" + e);
                    e.printStackTrace();
                }
            }

So if I'm deploying application to a jar, i've to put the logging properties file into templates folder. I modified build.xml file as follow:

[...]
<target name="jar" depends="compile">
        <delete file="${ant.project.name}.jar" />
        <copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
        <copy file="${mas2j.project.file}" tofile="default.mas2j" />
        <copy file="logging.properties" tofile="templates/logging.properties" />
[...]

and now the file is contained into the templates folder (within the jar). However, this did not solved the issue.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Standalone jason jar and logging properties

davide
This post has NOT been accepted by the mailing list yet.
Hi, i've found a solution. I replaced the code into the method setupLogger into RunCentralisedMAS class with this:

try
                {
                        if (new File(logPropFile).exists()) {
                    try {
                        LogManager.getLogManager().readConfiguration(new FileInputStream(logPropFile));
                    } catch (Exception e) {
                        System.err.println("Error setting up logger:" + e);
                    }
                } else {
                    try {
                        LogManager.getLogManager().readConfiguration(RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream());
                    } catch (Exception e) {
                        System.err.println("Error setting up logger:" + e);
                        e.printStackTrace();
                    }
                }
                }
                catch(Exception e)
                {
                        e.printStackTrace();
                }

Basically I bypassed the branch related to if (readFromJAR){[...]}. Then, recompile jason using the command ant -f build.xml jar (from within the jason folder). Then, in build.xml within your jason project, ensure to add the following entry to jar target:

<copy file="logging.properties" tofile="templates/logging.properties" />

Obviously, I'm assuming that in the project's root directory there's the file logging.properties.
Loading...