A U.S. Navy sailor who shot three people, killing two and himself with his service weapons at the Pearl Harbor Naval Shipyard on Wednesday was undergoing nonjudicial punishment for minor misconduct and had been in counseling, a military official said Friday on condition of anonymity.

The shooter was also unhappy with his commanders, the official added.

Navy officials Friday said they are still investigating the gunman’s motive for the attack, which unfolded in 23 seconds, but said it was isolated and there was no evidence of domestic terrorism.

PEARL HARBOR NAVAL SHIPYARD SHOOTER IDENTIFIED, SURVIVING VICTIM IN CRITICAL CONDITION

The victims were identified as Roldan Agustin, 49, and Vincent Kapoi Jr., 30. A third victim was in a hospital in critical condition.

“We will forever remember Roldan to be humble and honest, and a generous and patient man,” Agustin's family said in a statement.

Kapoi's family described him as an “easy-going, fun-loving, ‘let’s do this’ man.”

The shooting has prompted some to question the access to mental health care in the Navy, Hawaii News Now reported.

The shooter was on watch at the shipyard for the submarine USS Columbia when he opened fire. It's not clear if his victims were targeted or random.

Retired Army Col. Gregory Gross, who was a former Navy judge, said the nonjudicial punishment could have been for something as small as being late for work.

He said if the misconduct was serious, officials could have easily taken away his service weapons and removed him from watch duty.

“All it takes is for the commander to say, ‘You’re not getting a weapon,’ and he would be taken off that watch,” he said.

The Wednesday morning shooting came just days before the 78th anniversary of the Japanese bombing of Pearl Harbor on Dec. 7, 1941.

CLICK HERE TO GET THE FOX NEWS APP

On Friday, a Saudi gunman training at Naval Air Station Pensacola in Florida fatally shot three people on the base before he was killed by officers.

The Associated Press contributed to this report.