GWT: Reading a file from the server at server's startup - gwt

I am trying to have the server read from a file, called "config.txt", in the same directory as the main .html file within the war.
In hosted mode, I can easily access the file using a Scanner object:
Scanner s = new Scanner("config.txt");
But this does not work when deployed because the file paths are somehow different. How can I get the correct file path to access config.txt in the deployed version?
I have tried getServletContext.getRealPath("config.txt"), but for some reason I get a Null Pointer Exception when I attempt to call this in the ServiceImpl's constructor...

It seems like getServletContext.getRealPath("/") is the way to go, but you just can't call the method within the constructor of the server implementation.
The way I eventually got around it was by calling it when the client first made its connection.

Related

SOAP/HTTP using different folder mappings in ColdFusion

I'm experiencing some strange behaviour with a ColdFusion 11 server, which (among other things) publishes some web services accessed via both SOAP and HTTP. The server itself is Windows 2012, running IIS. Actual folder config is as follows:
IIS has two websites configured, 'BOB' and 'BOB_Services'. Both have been configured with the CF Server Config tool so that CF handles .cfc, .cfm files. They share a common CFIDE config.
BOB's root is I:/inetpub/BOB
BOB_Services's root is I:/inetpub/BOB_Services
There is a folder mapping configured in CF Admin from '/' to 'I:/inetpub/BOB'. Don't ask me why, no one seems to know.
Normally there is a services.cfc file in BOB_Services ONLY. Yesterday we accidentally copied that same file into the BOB root folder, and all of our SOAP services using BOB_Services\services.cfc started throwing errors. Yet I can query the same webservice via HTTP (eg. using http://bob/services.cfc?method=function1&param1=0 ....etc) and get a valid result.
This is a reference answer in case anyone else comes across this strange behaviour.
It appears that when BOB_Services/services.cfc is called using HTTP GET, the folder mapping
'/' -> 'I:/inetpub/BOB'
is ignored and the actual file used to process the request is I:/inetpub/BOB_Services/services.cfc.
When a function in BOB_Services/services.cfc is called using a SOAP client, the folder mapping is invoked and the file used to process the request is I:/inetpub/BOB/services.cfc, IF IT EXISTS. If it does not exist, the file I:/inetpub/BOB_Services/services.cfc is used as expected.
This behaviour appears to be entirely repeatable - I can make a SOAP request, get one result, change the mapping, make another request and get the other result.

How can I change connection string value residing in external config file (vb 2010)

Going through MSDN and various other posts on line, I understand that we can very well do away with the older method of ini files for writing and retrieving configuration details so as to be able to change database path/connection string. (refer)
I am able to get the connection string data from an external file ("abcConnStr.config") and am able to read and write from / to the database tables as normally one would expect to.
However I am unable to crack the way I would be able to change / update the connection string value in the external file ("abcConnStr.config"). If I try to pass the value manually through a text box I get a message saying "Your step-into request resulted in an automatic step-over of a property or operator.....". When I click "Yes" the sub is completed without any further message or error. However when I open the config file ("abcConnStr.config"), I find that the value of the connection string has not changed.
May I request you to guide me as to how can I change the connection string parameter in the external config file ("abcConnStr.config").
Addl.info:
Here is the external config file that I am using:
File name: connStr.config
<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="NewConStr"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&
quot;D:\CATALOG\CATALOG_DB\CAT_DB.accdb""
providerName="System.Data.OleDb" />
</connectionStrings>
I am using the following code line in appication.exe.config (app.config) file to access the database:
<connectionStrings configSource="connStr.config" />
I am able to connect to the database if it resides in the file location as defined in the external config file. However, when I change the database location (put in another folder or change the name) as expected, the connection to the DB fails. At this point I am catching the exception and trying to call the sub to effect a change to the path value assigned to the "connectionString".
In the sub I want to call code/s to change the DB file path as selected by the user thru'"OpenFileDialog".
Kindly advise a possible way to achieve this.
I got the solution on here.
However, I will have to do away with external config file (for now, till I get a solution on it) and have ended up making changes to the application.exe.config file. It is working seamlessly.
I am using VB 2010 Pro.
Thanks.

Enterprise Library for Logging to Flat File Trace Listener

What kind of permission needs to be given to the Error.log file in the server (running IIS 7.5) so that errors are written to the Error.log file?
I have created a directory named ErrorLog and set up the listener in web.config like below.
The windows identity in play (depends on how you authenticate)
var principal = ClaimsPrincipal.Current; //normally this reverts to Thread.CurrentPrincipal, but can be changed
return principal.Identity.Name;
or
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null)
{
return windowsIdentity.Name;
}
The Executing windows identity Will need create permission in directory and write permission to the file specified in your EL config.
You can place file anywhere you like using config. Default for file without path is Start project directory containing assembly dll.
See In IIS the Application Pool used by the website. The pool determines the windows Identity. See the advanced settings tab for the Pool. The identity approach to be used is defined here.
I don't see your configuration example, but..
I find that it is best not to use Flat File outside of development. The Event Log or Database listeners are more suitable for a web application in production.
If you must use Flat File, you will need to give the account (for the application pool that is assigned to the web application) write access to the directory that the file should be created in. By default I think that is the web application's bin directory, unless you include a path in the file name in your configuration.
It probably depends on what context your app in operating in. The app pool thread is responsible for writing the log so give the read/write folder permissions for the same identity as your app pool. I think this is NETWORKSERVICE by default.

Setting moodle online

Good day everyone, I have been trying to put my moodle online so pcs from internet can access it, but until now, no luck at all. (Im using moodle 2.3.2 on Windows Server 2008 and IIS 7).
I tried to configure the moodle file config.php, setting the directive $CFG -> wwwroot = "my-public-ip/moodle". Then, when I access to moodel from the server, I can access it by "http://my-public-ip/moodle", when I try to access via localhost, it sends an error which it is OK.
But the funny part comes when I try to access the server from an outside pc. When I type "http://my-public-ip/moodle" it simply cant "see" the configuration I made to the config.php file (it says: This server cna only be accessed via localhost/moodle) it looks like the outside pcs are either ignoring it, or searching for another configuration file. I dont know what the hell is happening, this is very odd.
Any ideas?? tnx!!!
Change the following file:
lib-->setuplib.php
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
for
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 0);
I realise this is an old question, but it's also worth pointing out you may need to also run the database search and replace script, at:
http://my-public-ip/moodle/admin/tool/replace/index.php
as referenced in Method 2 here.
This is required if you change the name of the site once you have installed it. If you were already using Moodle under "localhost", then there will be a number of references to the old localhost address stored in the database that need to be updated to the new IP-based address.
It might be because the http:// part is missing?
$CFG->wwwroot = "my-public-ip/moodle"
should be
$CFG->wwwroot = "http://my-public-ip/moodle"

Coldfusion FarCry CMS error on start up after server reboot

We're using Farcry CMS which runs on top of ColdFusion. Site was running fine but we are getting this error message after a web server reboot.
"Failed to initialise core type: dmHTML.cfc"
"Parameter 1 of function IsDefined, which is now application.stcoapi.dmHTML.stWebskins.Copy of displayPageCalculatorSelector.displayname, must be a syntactically valid variable name."
Really not sure where to start, could anyone suggest a strategy for troubleshooting this type of error.
Looks like you have a file called "Copy of displayPageCalculatorSelector.cfm" in your dmHTML webskin folder.
Remove this file is the best option.
Or rename it and remove the spaces, e.g. "Copy_of_displayPageCalculatorSelector.cfm"