One Star

[resolved] How to set the Config folder path at runtime?

Hi Shong,
While exporting the job, the source code containing the hard coded value of config folder path. How to pass the path value as a command line argument?
Code Snippet:
-----------------
Instead of this one:
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
"config/context_0_1/contexts/" + contextStr
+ ".properties");
i need the following oprtions:
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
contextStr+ ".properties");
or
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
configpath + contextStr
+ ".properties");

Thanks in advance...
1 ACCEPTED SOLUTION

Accepted Solutions
Seven Stars

Re: [resolved] How to set the Config folder path at runtime?

In the screenprint you can see that the Default values of the context have been overridden in running the job by those from c:\program files\vars.txt. The actual location of vars.txt is passed to the job from the command line.
9 REPLIES
Employee

Re: [resolved] How to set the Config folder path at runtime?

Hi,
You can set up this path value as a context, ie. context.path.
When you execute the jar file, you can directly override a context variable from a commandline using --context-param path=mypath
One Star

Re: [resolved] How to set the Config folder path at runtime?

Hi Shong,
I thought that you didn't understand my scenario. But i got your point. My scenario is to use the context variables in Context file. But path of the context file path should be passed as command line argument. It contains at the executable batch/shell file level.
instead of this one:
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=Default $*
i need the following one
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=<filepath>/Default $*
Because the source code cointains the hard coded context path as mentioned in the previous thread.
please see the screen shot below.
Community Manager

Re: [resolved] How to set the Config folder path at runtime?

Hi
i need the following one
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=<filepath>/Default $*

It is impossible, the path of .properties is fixed now. You can report a new feature on our bugtracker.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: [resolved] How to set the Config folder path at runtime?

If you use tContextLoad or implicit context loading in your jobs rather than the context group values preset within the studio you can specify the location of the file containing your context values at run-time. Within the job, set the location of the file to itself be a context variable and then set that location at run-time e.g.
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context_param contextfile="C:/my context files/contextfileA.txt"
One Star

Re: [resolved] How to set the Config folder path at runtime?

I have used tContextLoad but no luck i can't able to specify the property file i.e still java code containing the hard code of properties path Can u plz send me some screen shots
Seven Stars

Re: [resolved] How to set the Config folder path at runtime?

In the screenprint you can see that the Default values of the context have been overridden in running the job by those from c:\program files\vars.txt. The actual location of vars.txt is passed to the job from the command line.
One Star

Re: [resolved] How to set the Config folder path at runtime?

Hey can anyone out here tell me how to pass context variable value to .sh file
I mean I exported my job for UNIX platform and calling the same from my Java code.
It is unable to load Command Line Input...
Plz help.. Its urgent..
One Star

Re: [resolved] How to set the Config folder path at runtime?

Hello alevy,
Thanks for your solutions. It works for me..Problem resolved.