$cast failed when casting sequence item

casting failed in the below code. It was working and then started failing the casting(no change in this sequence) . what could be the issue to make the casting failed in this code?

sequencer also having same transaction type.

import xyz:: *; 

class simple_seq extends simple_base_seq;  

 `uvm_object_utils(simple_seq) 
 `uvm_declare_p_sequencer(seqr1); 

 xyz::simple_txn txn1; 

 function new(string name = "simple_seq"); 
  super.new(name); 
endfunction : new 

 virtual task body(); 

If(!$cast (txn1, uvm_factory::get().create_object_by_name(xyz::simple_txn, simple_txn_inst1))) begin 
 `uvm_fatal(get_full_name(), unable to cast ") 
end 

//assigning values to transaction item in txn1
 .... 
 … 

endtask  
endclass

The function create_object_by_name() has the following definition:

function uvm_object create_object_by_name (
  string requested_type_name, 	   	
  string parent_inst_path = "",
  string name = "");

The first argument ‘requested_type_name’ should be a string. In your code, it appears that you are passing a data type (‘xyz::simple_txn’). Is the code you posted correct? Or is there a typo? Also, the second argument is also a string, and the argument you pass also seems incorrect, although I don’t see ‘simple_txn_inst1’ defined anywhere.