- This topic has 7 replies, 3 voices, and was last updated 16 years, 5 months ago by
Riyad Kalla.
-
AuthorPosts
-
newpigMemberI’m trying to create a login filter and deploy it to a JBoss 4.2.3 server. Whenever I start the server in the IDE it crashes and wants to go into the debug perspective. Neither the console or the server log displays an error message. My filter class also doesn’t seem to load, I have some log messages in the init method of my filter that don’t display. However, if I start JBoss from the command line everything runs normally. Thanks.
Loyal WaterMemberCan you go to MyEclipse > Installation Summary > Installation Details and paste the information here for me.
newpigMemberHere’s the installation details :
*** Date:
Thursday, December 4, 2008 1:16:47 PM EST** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.6.0_07*** MyEclipse details:
MyEclipse Enterprise Workbench
Version: 6.6.0
Build id: 6.6.0-20081015*** Eclipse details:
MyEclipse Enterprise WorkbenchVersion: 6.6.0
Build id: 6.6.0-20081015Eclipse Platform
Version: 3.3.3.r33x_r20080129-_19UEl7Ezk_gXF1kouft
Build id: M20080221-1800Eclipse Project SDK
Version: 3.3.3.r33x_r20080129-7M7J7LB-u3aphGW6o3_VmiVfGXWO
Build id: M20080221-1800Eclipse Graphical Editing Framework
Version: 3.3.2.v20080129
Build id: 20080221-1602Eclipse RCP
Version: 3.3.3.r33x_r20080129-8y8eE9UEUWI6qujeED0xT7bc
Build id: M20080221-1800Eclipse Java Development Tools
Version: 3.3.2.r33x_r20080129-7o7jE7_EDhYDiyVEnjb1pFd7ZGD7
Build id: M20080221-1800Eclipse Plug-in Development Environment
Version: 3.3.3.r33x_r20080129-7N7M5DQVIA_6oJsEFkEL
Build id: M20080221-1800Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-showsplash
-launcher
C:\Program Files\Pulse\MyEclipse 6.5\eclipse.exe
-name
Eclipse
–launcher.library
C:\Program Files\Pulse\MyEclipse 6.5\../Common\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.3.R33x_v20080118\eclipse_1023.dll
-startup
C:\Program Files\Pulse\MyEclipse 6.5\../Common\plugins\org.eclipse.equinox.launcher_1.0.1.R33x_v20080118.jar
-clean
-configuration
C:\Program Files\Pulse\MyEclipse 6.5\configuration
-vm
C:\Program Files\Java\jre1.6.0_07\bin\client\jvm.dll
Loyal WaterMembernewpig,
Can you make sure your jboss connector is configured to look like this :-
https://www.genuitec.com/forums/topic/jboss-4-what-does-a-configured-connector-look-like/Also, can you switch to a new workspace, configure the JBoss connector again and check if you are able to start the server without issues.
newpigMemberNipun,
My connector is configured like that. I should have added, that if I remove my filter configuration from the web.xml of my application the server runs fine. But, as soon as I add my filter it crashes. Here’s the filter & it’s config entry :package com.newpig.security;
//Import Java classes
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import org.apache.log4j.Logger;
// Import New Pig classes
import com.newpig.handlers.NPApplicationHandler;/**
* Redirects the user to the login page if they are not logged in or their
* session has expired and they try to access a page that requires a
* valid user.
*
* Also catches FacesServlet errors and sends an email to report it.
*
* @author GregH
*/public class NPSecurityFilter implements Filter
{
private String[] protectedPaths = null;
private String loginPage = null;
private String errorPage = null;
private FilterConfig filterConfig = null;public void init(FilterConfig filterConfig) throws ServletException
{this.filterConfig = filterConfig;
Logger logger = Logger.getLogger(“com.newpig”);
logger.info(“Intializing NPSecurityFilter”);
loginPage = filterConfig.getInitParameter(“loginPage”);
String paths = filterConfig.getInitParameter(“protectedPaths”);
logger.info(“Protected paths: ” + paths);
if (paths != null)
{
protectedPaths = paths.split(“,”);
}
errorPage = filterConfig.getInitParameter(“errorPage”);
}public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
Logger logger = Logger.getLogger(“com.newpig”);
logger.info(“In NPSecurityFilter.doFilter”);
boolean redirectSent = false;
HttpServletRequest req = (HttpServletRequest)request;
String reqPath = req.getServletPath();
HttpSession session = req.getSession();
String originalPage = req.getRequestURI();
logger.info(“Original page: “+ originalPage);boolean allowed = true;
for (int i = 0; i < protectedPaths.length; i++)
{
if (reqPath.startsWith(protectedPaths[i].trim()))
{
allowed = false;
break;
}
}
if (!allowed)
{
Object appObj = session.getAttribute(“appHandler”);
if (appObj == null || ((NPApplicationHandler)appObj).getUser()== null ||
((NPApplicationHandler)appObj).getUser().getUsername() == null)
{
session.invalidate();
((HttpServletResponse)response).sendRedirect(loginPage + “?originalURL=” + originalPage);
redirectSent = true;
}
}
if (!redirectSent)
{
try
{
chain.doFilter(request, response);
}
catch(Exception e)
{
logger.error(“NPSecurityFilter caused exception: ” + e.getMessage());if (errorPage != null)
{
// Redirect to the error page
((HttpServletResponse)response).sendRedirect(errorPage);
}
else
{
throw new ServletException(“Error in Secuirty Filter”);
}
}
}}
public void destroy()
{
this.filterConfig = null;
}
}<filter>
<display-name>Security Filter</display-name>
<filter-name>loginFilter</filter-name>
<filter-class>com.newpig.security.NPSecurityFilter</filter-class>
<init-param>
<param-name>loginPage</param-name>
<param-value>/login.jsf</param-value>
</init-param>
<init-param>
<param-name>protectedPaths</param-name>
<param-value>/modules</param-value>
</init-param>
</filter><filter-mapping>
<filter-name>loginFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
Riyad KallaMembernewpig,
This looks like an old really-random bug we had where phantom breakpoints would cause execution to halt on srever startup. Try this:
1. Go to debug perspective
2. Right-click on the Breakpoint view and do a Remove All
3. Shut down MyEclipse, double-check your eclipse.ini file in the MyEclipse installation folder under the “eclipse” subfolder has “-clean” in it
4. Restart and fire the app server back up.That should fix it.
newpigMemberThat did it, Thanks!
Riyad KallaMemberGlad to hear it’s working now.
-
AuthorPosts