Получение исключения нулевого указателя, потому что невозможно создать компонентJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Получение исключения нулевого указателя, потому что невозможно создать компонент

Сообщение Anonymous »

Код: Выделить всё





























com.revguru.crs.security.dao.UserRoleDAO




hibernateInterceptor
userRoleDAOTarget






com.revguru.crs.security.dao.AuthenticationDAO




hibernateInterceptor
userAuthDAOTarget






com.revguru.crs.security.dao.HotelUserDAO




hibernateInterceptor
hotelUserDAOTarget







userauthResources/hsd_user_msg




Это мой bean-файл, и он получает ссылку на hsdsessionFsctory, который определен, как показано ниже: и когда я запускаю свой проект, я получаю исключение нулевого указателя

Код: Выделить всё

    public class UserLoginController {

private FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
private SecurityService securityService;

public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}

public SecurityService getSecurityService() {
return this.securityService;
}

/**
* Authenticate the User
* @return
*/
public String authenticate() {
if(session.getAttribute("menus") != null) {
session.removeAttribute("menus");
}

if (session.getAttribute("CommonGlobalBean") != null) {
session.removeAttribute("CommonGlobalBean");
}

CommonGlobalBean commonGlobalBean = new CommonGlobalBean();
commonGlobalBean.setTimeZone(TimeZone.getDefault().getID());

UserLogin userLogin =(UserLogin)session.getAttribute("UserLogin");

String username = userLogin.getUserName();
String password = userLogin.getPassword();

UserInformation userInformation = null;
System.out.println("security serv ice  is ");
if(securityService==null){
System.out.println("security serv ice  is null:");
securityService= new SecurityService();
}
if (userLogin != null) {
System.out.println("username is:"+username);
System.out.println("password is:"+password);

if (securityService.authenticate(username,password)) {
Util.log("Get User Object by Email");
UserDataObject userDataObject = securityService.getUserObjectByEmail(userLogin.getUserName());
Util.log("User name : "+userDataObject.getUserFirstName());
userInformation = (UserInformation)session.getAttribute("UserObject");
if (userInformation != null) {
session.removeAttribute("UserObject");
}
userInformation = getUserInformation(userDataObject);
session.setAttribute("UserObject", userInformation);

if(!checkUserAsHotelRole(userInformation)) {
Util.log("User does not have hotel role.");
Util.reportError(facesContext, "login_user_not_valid_password", null);
}

HotelDataObject hotelDataObject = getAssignedHotel(userInformation);
session.setAttribute("hotelDataObjectInSession", hotelDataObject);

List menus = new ArrayList();
for (FeatureDataObject feature : userInformation.getFeatureDataObjects()) {
if (feature.getParentFeatureId() == null && feature.getFeatureTypeId().getId().intValue() == HSDServiceConstants.MENU && feature.getShowFeature() == 1) {
List menuItems = getMenuItems(feature.getId(), userInformation.getFeatureDataObjects());
menus.add(new Menu(feature.getId(), feature.getFeatureName(), "", menuItems));
}
}

String languageCode = userLogin.getLanguageCode();

if (languageCode == null) {
userLogin.setLanguageCode("en");
facesContext.getViewRoot().setLocale(Locale.ENGLISH);
} else {
if(languageCode.equals("fr")) {
facesContext.getViewRoot().setLocale(Locale.FRENCH);
} else {
facesContext.getViewRoot().setLocale(Locale.ENGLISH);
}
}

Util.log(":: languageCode :: " + userLogin.getLanguageCode());

session.setAttribute("menus", menus);
session.setAttribute("CommonGlobalBean", commonGlobalBean);
/**
* get hotel general info details
*/
GeneralHotelController generalHotelController = new GeneralHotelController();
generalHotelController.loadGeneralInformation();
/**
* return to hotel general info page
*/
return "generalInfo";
} else {
Util.log("Invalid User.");
Util.reportError(facesContext, "login_user_not_valid_password", null);
}
}
return "";
}
которые вызывают другой метод класса, как показано ниже.

Код: Выделить всё

    public boolean authenticate(String email, String password) {
log.info("Authenticating : " + email);
UserDataObject user = getUserObjectByEmail(email);
if (user == null) {
log.info("User does not exist for email id :"  + email);
return false;
}
return checkPassword(password, user.getPassword());
}
когда я вижу это в своем Spring Explorer, он показывает, что ссылка на компонент неизвестна
это моя трассировка стека

Код: Выделить всё

    javax.servlet.ServletException:  java.lang.NullPointerException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
Что такое красная отметка в моем Spring Explorer?
[img]https://i .sstatic.net/Rez0O.jpg[/img]

а у других его нет

Подробнее здесь: https://stackoverflow.com/questions/425 ... reate-bean
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»