#Maven Project

36 messages · Page 1 of 1 (latest)

unborn sonnet
#

java.lang.NullPointerException

rare lightBOT
#

This post has been reserved for your question.

Hey @unborn sonnet! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

unborn sonnet
#

Can anyone help me through this error

rare lightBOT
jolly trellis
unborn sonnet
jolly trellis
#

don't do that but just explain more on where the nullpointer is, what you're doing etc

unborn sonnet
#

ok wait I don't know about this rule

#

can you atleast look up to a git repo

jolly trellis
#

fine but you'll still need to explain what the issue is

unborn sonnet
#

Yea sure

jolly trellis
unborn sonnet
#

So the context is to make a School management system using maven hibernate mysql

unborn sonnet
#

So I totally made the methods, classes organized the directory structure with the help of GPT -4 But I am stuck somewhere and I am helpless

#

This is my directory structure

#

Hello sir are you there @jolly trellis

jolly trellis
#

studentservice is empty?

unborn sonnet
#

no its not

#
package com.myschool.management.sms.services;


import java.util.List;

import com.myschool.management.sms.dao.StudentI;
import com.myschool.management.sms.models.Course;
import com.myschool.management.sms.models.Student;

public class StudentService implements StudentI {

    private final StudentI studentDAO; // Inject Student DAO

    public StudentService(StudentI studentDAO) {
        this.studentDAO = studentDAO;
    }

    @Override
    public void createStudent(Student student) {
        studentDAO.createStudent(student);
    }

    @Override
    public List<Student> getAllStudents() {
        return studentDAO.getAllStudents();
    }

    @Override
    public Student getStudentByEmail(String email) {
        return studentDAO.getStudentByEmail(email);
    }

    @Override
    public boolean validateStudent(String email, String password) {
        return studentDAO.validateStudent(email, password);
    }

    @Override
    public void registerStudentToCourse(String email, int courseId) {
        studentDAO.registerStudentToCourse(email, courseId);
    }

    @Override
    public List<Course> getStudentCourses(String email) {
        return studentDAO.getStudentCourses(email);
    }
}
#

this is my StudentService.java

jolly trellis
#

that's not what's in the repo

unborn sonnet
#

well I didn't start from the repo

#

I have made my own directory and started it from scratch

jolly trellis
#

so why did you link me to the repo if it's not your code lol

unborn sonnet
#

It is not my code but my assignment

#

I didn't upload mine in the github yet that was the reason I though of sending via zip file

jolly trellis
#

upload to github so we can see what your specific issue is

#

but anyway i suspect you are not creatingthe dao correctly and so studentdao is null

#

make sure studentdao isn't null by passing it in correctly as a constructor argument

unborn sonnet
#

Ok Let me try and come up to you thank you

rare lightBOT