Q: WebDriver cannot be initialized I got NullPointerException when I run the @testCase
1. In FrameworkTestCases.class -> @BeforeClass I initialize the instance of the selected webdriver. The browser is running when I start the  FrameworkTestCases.class as jUnit test, but when I reach the testCase it says NullPointerException. What is the reason? I also used a constructor with 2 arguments to inherit the driver from the Generic.class to LoginPageFactory.class, but nothing happened.  
Here is my FrameworkTestCases class:
public class FrameworkTestCases {

static WebDriver driver;
private static String baseURl = "https://management.tacticlicks.com/";
static LoginPageFactory loginPage;
static Generic generic;
//WebDriver driver;
//static LoginPageFactory lpFactory;


@BeforeClass
public static void setUp() {        
    generic = new Generic(driver);
    generic.getDriver(baseURl, "chrome");
}

@Test
public void test() {
    System.out.println("Executing test");

    loginPage
    .fillUsernameField("ivailostefanov1989@gmail.com")
    .fillPasswordField("astral8909")
    .clickSubmit(); 
}


@AfterClass
public static void tearDown() {
    driver.quit();
}
}

public class LoginPageFactory extends Generic {

public LoginPageFactory(WebDriver driver2, Class<LoginPageFactory> class1) {
    super(driver2, class1);
    // TODO Auto-generated constructor stub
}

WebDriver driver;

@FindBy(name="email") //.//*[@id='login']/div[1]/div/div/table/tbody/tr/td[2]/div[1]/form/div[1]/input
WebElement loginUsernameField;

@FindBy(name="password")
WebElement loginPasswordField;

@FindBy(tagName="button")
WebElement loginSubmitButton;

public LoginPageFactory(WebDriver driver) {
    System.out.println("LoginPageFactory");
    this.driver = driver;
    PageFactory.initElements(driver, this);
}

public LoginPageFactory fillUsernameField(String username) {
    System.out.println("Before field initializing");
    WebElement emailField = driver.findElement(By.name("email"));
    emailField.click();
    emailField.sendKeys(username);
    return this;
}

public LoginPageFactory fillPasswordField(String password) {
    loginPasswordField.click();
    loginPasswordField.clear();
    loginPasswordField.sendKeys(password);
    return this;
}

public LoginPageFactory clickSubmit() {
    loginSubmitButton.click();
    return this;
}   
}

public class Generic {

WebDriver driver;

public Generic(WebDriver driver) {
    this.driver = driver;
}

public Generic(WebDriver driver2, Class<LoginPageFactory> class1) {
    // TODO Auto-generated constructor stub
}

private void getBrowser(String browser) {

    if (browser.equalsIgnoreCase("Firefox")) {
        File chromeDriver = new File("C:\\Users\\Ivo\\Desktop\\geckodriver.exe");
        System.setProperty("webdriver.gecko.driver", chromeDriver.getAbsolutePath());
        driver = new FirefoxDriver();
    } else if (browser.equalsIgnoreCase("Chrome")) {

        //set chromedriver property
        File chromeDriver = new File("C:\\Users\\Ivo\\Desktop\\chromedriver.exe");
        System.setProperty("webdriver.chrome.driver", chromeDriver.getAbsolutePath());
        driver = new ChromeDriver();


    } else {
        System.out.println("Browser cannot be launched");
    }

}

public WebDriver getDriver(String appUrl, String browser) {
    getBrowser(browser);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.get(appUrl);
    return driver;
}
}


A: You are missing a variable assignment in @BeforeClass method.
Change
@BeforeClass
public static void setUp() {        
    generic = new Generic(driver);
    generic.getDriver(baseURl, "chrome");
}

to 
@BeforeClass
public static void setUp() {        
    generic = new Generic(driver);
    driver = generic.getDriver(baseURl, "chrome");
}

And also you did not create any instance of LoginPageFactory class. You have created a variable static LoginPageFactory loginPage; but didn't initialize it (at least nowhere in provided code).
In method
@Test
public void test() {
    System.out.println("Executing test");

    //add this line of code to initialize elements via Page Factory
    loginPage = new LoginPageFactory(driver);

    loginPage
    .fillUsernameField("ivailostefanov1989@gmail.com")
    .fillPasswordField("astral8909")
    .clickSubmit(); 
}

