Cause for Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: error Currently trying to port over a Contrib module and learn the new Drupal 8 architecture.

A google search revealed a possible issue related to this. 

The cause could be that there's an underscore in the file name which violates psr-0 naming standards. Looks like i had that before and have renamed it just now and still have that issue after clearing the cache.

What would likely be the cause of the following error?


  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
  You have requested a non-existent service
  "\drupal\form_example\forms\formexampleformone". in
  Symfony\Component\DependencyInjection\Container->get() (line 304 of
  /home/chris/workspace/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php).


The error occurs when i visit /examples/form_example/tutorial/1

form_example.routing.yml

form_example:
  path: 'examples/form_example'
  defaults:
    # _form: '\Drupal\form_example\Forms\FormExampleForm'
    _content: '\Drupal\form_example\Controller\FormExampleController::description'
  requirements:
    _access: 'TRUE'
form_example_tutorial_1:
  path: 'examples/form_example/tutorial/1'
  defaults:
    _form: '\Drupal\form_example\Forms\FormExampleForm'
  requirements:
    _access: 'TRUE'


form_example.module

&lt;?php
function form_example_menu() {
//   $items = array();
//   $items['examples/form_example'] = array(
//     'title' =&gt; 'Form Example',
//     'route_name' =&gt; 'form_example',
//     'access callback' =&gt; TRUE,
//     'expanded' =&gt; TRUE,
//   );
  $items['examples/form_example/tutorial'] = array(
    'title' =&gt; 'Form Tutorial',
    // 'page callback' =&gt; 'drupal_get_form',
    'route_name' =&gt; array('form_example_tutorial'),
    'access callback' =&gt; TRUE,
    'description' =&gt; 'A set of ten tutorials',
    // 'file' =&gt; 'form_example_tutorial.inc',
    // 'type' =&gt; MENU_NORMAL_ITEM,
  );
  $items['examples/form_example/tutorial/1'] = array(
    'title' =&gt; '#1',
    // 'page callback' =&gt; 'drupal_get_form',
    'route_name' =&gt; array('form_example_tutorial_1'),
    'access callback' =&gt; TRUE,
    'description' =&gt; 'Tutorial 1: Simplest form',
    // 'type' =&gt; MENU_DEFAULT_LOCAL_TASK,
    // 'file' =&gt; 'form_example_tutorial.inc',
  );
  return $items;
}


/lib/Drupal/form_example/Forms/FormExampleForm.php

&lt;?php
/**
 * @file
 * Contains \Drupal\form_example\Form\FormExampleForm
 */
namespace Drupal\form_example;

use Drupal\Core\Form\FormInterface;

class FormExampleForm extends FormBase {
// form...
}
Looks like the namespace defined in your class file does not match the one you put into the resource, there's a "Form" sub-namespace missing.

Also make sure that the class is placed in the right folder.

The reason for that error is apparently that for some reason, the specified class can't be found, so apparently the router then falls back to the service. So the _ thing is just one possible reason.

Also, there are some errors in your hook_menu(), route_name is a string, access callback can be removed and you still need the first entry for now so that you have a menu link to it.