commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ranbir singh (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CONFIGURATION-379) org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source null
Date Wed, 01 Apr 2009 05:55:13 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12694400#action_12694400
] 

ranbir singh commented on CONFIGURATION-379:
--------------------------------------------

We use Quartz as job schduler fraework. Following is the code snipplet to schedule a Job to
be processed by Quartz. Jobs are scheduled for our main class "CIMSystem" .

Following are the steps of execution:
1) CIMSystem is instantiated, we instantiate CIMConfiguration also. 
2) Next we call init() method, which turns call  cfg.configure() method and loads the properties.
3) When a job is scheduled, we pass the CIMSystem object as Parameter (via org.quartz.JobDetail
object)
4) When the Job is picked by Scheduler for execution, we get the CIMSystem object ("system")
from JobDetail object  and call the "system.getConfiguration().configure();" to read the properties
for properties file.


public class CIMSystem 
{
      private CIMConfiguration cfg;
      private Scheduler sched;
      private static CIMSystem instance = null;

      public static synchronized CIMSystem getInstance() {
            if (instance == null) instance = new CIMSystem();
	return instance;
      }

      private CIMSystem() 
      {
            ....
            cfg = new CIMConfiguration();
            ...
      }

      public void init() 
      {
            ...
            cfg.configure();
            ...
      }

      private boolean scheduleJob( String jobName, String jobGroup, Long interfaceDefId, InterfaceDef
intf,
                  User user, String runDescription, ProcessContext.Type processType, String
refProcessId,              
                  org.quartz.Trigger trigger) 
      {
	org.quartz.JobDetail jobDetail = new org.quartz.JobDetail(jobName, jobGroup, InterfaceJob.class);
	jobDetail.setDescription(runDescription);
	jobDetail.getJobDataMap().put(InterfaceJob.SYSTEM, this);
                      ....
	trigger.setName(jobName);
	trigger.setGroup(jobGroup);
	try {
                        	sched.scheduleJob(jobDetail, trigger);
		log.info("Interface ["+interfaceDefId+"] is added to scheduler. Next fire time      
                                                            ["+trigger.getNextFireTime()+"]");
	} catch (SchedulerException e) {
                        	e.printStackTrace();
		log.error("Exception when schedule job interface["+interfaceDefId+"]", e);
		return false;
	}
	return true;
      }
}



public class InterfaceJob implements org.quartz.Job 
{
     private CIMSystem system;

     public void execute(JobExecutionContext context) throws JobExecutionException 
     {
          try 
          {
               system = (CIMSystem) context.getJobDetail().getJobDataMap().get(SYSTEM);
               system.getConfiguration().configure();
               ....do the rest of processing....
          } 
          catch (Exception ex) 
          {
	log.error("Job ["+context.getJobDetail().getName()+"] completed with Exception.", ex);
          } 
     }
}




> org.apache.commons.configuration.ConfigurationException: Cannot locate configuration
source null
> ------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-379
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-379
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: Windows XP, Tomcat 5.5 server, Quarts 1.6.0
>            Reporter: ranbir singh
>            Priority: Critical
>
> In one of my projects, we are using commons-configuration to read properties file.  There
are multiple threads that are trying to read property in this property file and many times
fails giving following exception:
> org.apache.commons.configuration.ConfigurationException: Cannot locate configuration
source null
> 	at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:213)
> 	at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:193)
> 	at com.mycomp.myapp.CIMConfiguration.configure(CIMConfiguration.java:104)
> 	at com.mycomp.myapp.CIMConfiguration.configure(CIMConfiguration.java:89)
> 	at com.mycomp.myapp.InterfaceJob.execute(InterfaceJob.java:64)
> 	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
> 	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
> To my understanding, this error is reported from
> Class: AbstractFileConfiguration.java
> Method: load(String fileName) throws ConfigurationException
> {
>       URL url = ConfigurationUtils.locate(basePath, fileName);
>       if (url == null)
>       {
>              throw new ConfigurationException("Cannot locate configuration source " +
fileName); } 
>             load(url);
>       }
> I have checked& printed that the filename passed to this method is correct.
> Please advice

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message