By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

how to make join between "JAR file and JSF"

P: 5
Dear All,

Hope every one is feeling good, and happy new year .

Can any one help me on this?
I built an Alfreasco code and it works on eclipse, now on eclipse I made in the "main class" username and password (desktop application) and when I send the username and password it returns true , but on web Application when I take tha Jar file and use JSF code on netbeans and then enter the username and password it gives me an error like this:

Null pointer exception :
on Get Authuntication error
and on Registry service

So How I mada a "login page on jsf and connect it to the jar file?
Dec 31 '08 #1
Share this Question
Share on Google+
1 Reply


P: 5
@isra123
ah by the way the error I got is:

og4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax). log4j:WARN Please initialize the log4j system properly. Dec 31, 2008 1:43:57 PM org.apache.catalina.core.StandardContext start INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Login] has already been started java.lang.NullPointerException at CRC.AlfrescoServices.getServiceRegistry(AlfrescoSe rvices.java:52) at CRC.AlfrescoServices.getAuthenticationService(Alfr escoServices.java:36) at CRC.AlfUserServices.login(AlfUserServices.java:28) at CRC.CrcLogin.Check_Valid


**************
This is the my code which has the problem :
package CRC;
import java.io.Serializable;
import java.beans.EventHandler;
import java.util.Date;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
/*
* CrcLogin.java
*
* Created on November 30, 2008, 12:30 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author SPAREWNMAN
*/
public class CrcLogin {

/** Creates a new instance of CrcLogin */
public CrcLogin() {
}

private String UserName;
private String PassWord;

public String Check_Validate()
{

AlfUserServices alfUserServices=new AlfUserServices();

System.out.println(alfUserServices.login(getUserNa me(),getPassWord()));

System.out.println(getUserName()+" : "+getPassWord());
FacesContext context =FacesContext.getCurrentInstance();
HttpSession session=(HttpSession) context.getExternalContext().getSession(true);
System.out.println(session);

System.out.println(UserName + " has logged in at " + new Date());

System.out.println(alfUserServices.login(getUserNa me(),getPassWord()));
return"success";
}







/*else
System.out.println(getUserName()+" : "+getPassWord());
System.out.println("Invalide User");

return"failed";*/



public String getUserName() {
return UserName;
}

public void setUserName(String UserName) {
this.UserName = UserName;
}

public void setPassWord(String PassWord) {
this.PassWord = PassWord;
}

public String getPassWord() {
return PassWord;
}
}
================================================== ===========================================
================================================== ===========================================


package CRC;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAwar e;

/**
*
* @author SPAREWNMAN
*/


public class ContextAwareClass implements ApplicationContextAware {

private static ApplicationContext ctx;

public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
ctx = applicationContext;
}

public static void displayAppContext() {
System.out.println(ctx);
}

public static ApplicationContext getAppContext() {
return ctx;

}




/** Creates a new instance of ContextAwareClass */
public ContextAwareClass() {
}

}

================================================== ===========================================
================================================== ===========================================



package CRC;

import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthenticationSe rvice;
import org.springframework.context.ApplicationContext;


/**
*
* @author SPAREWNMAN
*/
public class AlfrescoServices {

private ServiceRegistry serviceRegistry;
private AuthenticationService authenticationService;
/** Creates a new instance of AlfrescoServices */
public AlfrescoServices() {
}

protected void setAuthenticationService(
AuthenticationService authenticationService) {
this.authenticationService = authenticationService;
}

protected AuthenticationService getAuthenticationService() {
if (authenticationService == null)
authenticationService = getServiceRegistry()
.getAuthenticationService();
return authenticationService;
}

protected void setServiceRegstry(ServiceRegistry serviceRegstry) {
this.serviceRegistry = serviceRegstry;
}

protected ServiceRegistry getServiceRegistry() {
if (serviceRegistry == null) {
ApplicationContext ctx = ContextAwareClass.getAppContext();

//ApplicationContext ctx = ApplicationContextHelper
//.getApplicationContext();

serviceRegistry = (ServiceRegistry) ctx
.getBean(ServiceRegistry.SERVICE_REGISTRY);
}

return serviceRegistry;


}
}

================================================== ===========================================
================================================== ===========================================


package CRC;

import org.alfresco.service.cmr.security.AuthenticationSe rvice;
import java.util.Hashtable;
import java.util.Map;
import org.alfresco.model.ContentModel;
/**
*
* @author SPAREWNMAN
*/
public class AlfUserServices extends AlfrescoServices {

/** Creates a new instance of AlfUserServices */
public AlfUserServices() {
}

public boolean login(String username,String password){
try{
AuthenticationService authenticationService = getAuthenticationService();
authenticationService.authenticate(username, password.toCharArray());
}
catch(Exception e){e.printStackTrace();

return false;}
return true;
}

}
================================================== ===========================================
================================================== ===========================================
Dec 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.