I am creating a modular Maven project. The project is deployed on Glassfish 3.1. The project (webapp) consists of three modules:
- "General", consisting of the basic functionality (persistence, authentication logic, etc.) built into the JAR
- "User", depending on the Common built-in WAR
- "Admin", also depending on Common and WARCR
Both WARs use heavy annotated classes (@Entity, @Inject, @EJB, ...) from Common. Common is currently a JAR, but this is not a requirement. The question arises: how to properly deploy such a project?
According to my current ones (google and stackoverflow influence):
Common cannot be a JAR because the .jar file is placed in the WEB-INF \ lib directory inside the JAR. This does initialization of the deployment time because Glassfish expects .classes and generates an Unsatisfied Dependencies error, which results in a failed deployment.
Normal cannot be WAR, because with WAR-overlay copying ocurrs after assembly - the result is assembly depending on yourself ...
EDIT
As Mike Pak notes, the installation works fine, I assume providing a full error message would be helpful:
Deployment Error for module: User: Error occurred during deployment:
Exception while loading the app : WELD-001408 Unsatisfied dependencies
for type [Authentication] with qualifiers [@Default] at injection point
[[field] @Inject xxx.xxx.servlets.LoginFilter.authentication].
What does it mean? What could be the reason?
EDIT2
I include the corresponding classes (a bit cropped, i.e. does not receive / sets methods, imports, etc.)
public class LoginFilter implements Filter {
@Inject
Authentication authentication;
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
LoginBean login = (LoginBean) httpRequest.getSession().getAttribute("loginBean");
if((login == null || !login.isAuthenticated())) {
HttpServletResponse httpResponse = (HttpServletResponse) response;
String requestUrl = httpRequest.getRequestURI().toString();
authentication.setNavigateAfterLogin(requestUrl);
httpResponse.sendRedirect("./../login.html");
}
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig fConfig) throws ServletException {}
@Override
public void destroy() {}
}
and
@SessionScoped
public class Authentication implements Serializable {
@Inject
private UserDatabaseController userDb;
private ShopUser user;
private String navigateAfterLogin;
private String login;
private String password;
public boolean doLogin(String username, String password) {
List<ShopUser> users = userDb.getUsers();
for(ShopUser shopUser : users) {
if(shopUser.getLogin().equals(username) && shopUser.getPassword().equals(password)) {
setUser(shopUser);
return true;
}
}
return false;
}
public void doLogout() {
setUser(null);
}
public boolean isAuthenticated() {
return getUser() != null;
}
}
source
share