The eldest of six children, James Hartley was born in Davenport, Iowa, to Irish immigrants Edward Hartley and Catherine McManus Hartley. Shortly after his birth, Hartley and his family moved to Columbus, Ohio, where his parents had been married at St. Patrick Parish. His father kept a saloon on West Maple Street, and the family lived upstairs. His father also worked as a Columbus police officer for many years.
Hartley attended the parish school at St. Patrick, then entered St. Aloysius Seminary in Columbus. When that seminary closed, he attended Mount St. Mary's Seminary of the West in Norwood, Ohio, then Our Lady of Angels Seminary in Niagara, New York.
Hartley was ordained to the priesthood by Bishop John A. Watterson on July 10, 1882, in St. Joseph Cathedral. His first assignment was assistant pastor at St. Peter's Church in Steubenville, Ohio. In 1885, he was named pastor of Holy Name Parish in Steubenville. While pastor of Holy Name, Hartley organized a school, a high school, and had a new church built which later became the cathedral of the Diocese of Steubenville when the diocese was erected by Pope Pius XII on October 21, 1944 out of territory from the Diocese of Columbus.
On December 10, 1903, at the age of 45, Hartley was chosen as the fourth Bishop of Columbus by Pope Pius X. He was consecrated by his predecessor Bishop Henry K. Moeller on February 25, 1904, in Holy Name Parish in Steubenville. Bishops Denis O'Donaghue and Herman J. Alerding served as co-consecrators. He was formally installed as bishop in St. Joseph Cathedral on March 1, 1904.
During his tenure, Hartley oversaw a significant growth of the Diocese of Columbus. In 1905, he erected his first parishes, Holy Rosary and St. Aloysius. In 1906, he retired the debt on St. Joseph Cathedral. Within the first five years of his episcopate, Hartley had begun or dedicated more than 25 churches, schools, and chapels.
Hartley also established St. Charles Seminary, St. Joseph Cemetery, St. Ann Hospital, Mercy Hospital in Portsmouth, Good Samaritan Hospital in Zanesville, Mercy Hospital in Mount Vernon, and St. Therese Shrine, and renovated St. Joseph Cathedral. Toward the end of his term as bishop he consecrated Edward Gerard Hettinger as the first auxiliary bishop of the Columbus diocese.
Hartley died at age 85, and was buried at St. Joseph Cemetery in Lockbourne, just outside Columbus. Bishop Hartley High School, established on the east side of Columbus in 1957, is named in his honor.