11package org .linkeddatafragments .servlet ;
22
3+ import java .io .File ;
4+ import java .io .FileReader ;
35import java .util .HashMap ;
46import java .util .Map .Entry ;
57import java .util .regex .Matcher ;
@@ -41,7 +43,15 @@ public class BasicLdfServlet extends HttpServlet {
4143 @ Override
4244 public void init (ServletConfig servletConfig ) throws ServletException {
4345 try {
44- config = new ConfigReader (servletConfig .getInitParameter ("configFile" ));
46+ // find the configuration file
47+ final File applicationPath = new File (servletConfig .getServletContext ().getRealPath ("/" ));
48+ final File serverHome = applicationPath .getParentFile ().getParentFile ();
49+ final File configFile = new File (serverHome , "conf/ldf-server.json" );
50+ if (!configFile .exists ())
51+ throw new Exception ("Configuration file " + configFile + " not found." );
52+
53+ // load the configuration
54+ config = new ConfigReader (new FileReader (configFile ));
4555 for (Entry <String , String > dataSource : config .getDataSources ().entrySet ())
4656 dataSources .put (dataSource .getKey (), new HdtDataSource (dataSource .getValue ()));
4757 }
@@ -59,7 +69,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
5969 final String dataSourceName = path .substring (1 );
6070 final DataSource dataSource = dataSources .get (dataSourceName );
6171 if (dataSource == null )
62- throw new Exception ("data source not found" );
72+ throw new Exception ("Data source not found. " );
6373
6474 // query the fragment
6575 final Resource subject = parseAsResource (request .getParameter ("subject" ));
0 commit comments