[JBoss Seam] - Re: SeamTest and expectedExceptions
by matt.drees
Ok, I felt like implementing this. It works well enough for me, anyway. Maybe you can do something similar:
| import static org.jboss.seam.annotations.Install.MOCK;
|
| import java.io.IOException;
|
| import javax.servlet.FilterChain;
| import javax.servlet.ServletException;
| import javax.servlet.ServletRequest;
| import javax.servlet.ServletResponse;
|
| import org.jboss.seam.annotations.Install;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.intercept.BypassInterceptors;
| import org.jboss.seam.annotations.web.Filter;
|
| /**
| * By default, Seam's exception filter is installed in integration tests. Unfortunately,
| * if an exception occurs during Request.run(), the exception filter logs it and redirects,
| * but the exception is not thrown (which is correct for a prod environment, but not what
| * we want for tests). This filter overrides the default exception filter, and throws
| * any encountered exceptions. ServletExceptions are unwrapped if the root exception
| * is a runtime exception.
| * @author Matthew.Drees
| *
| */
| @Name("org.jboss.seam.web.exceptionFilter")
| @Install(precedence = MOCK, classDependencies="javax.faces.context.FacesContext")
| @BypassInterceptors
| @Filter(within="org.jboss.seam.web.ajax4jsfFilter")
| public class ExceptionFilter extends org.jboss.seam.web.ExceptionFilter {
|
| @Override
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
| try {
| chain.doFilter(request, response);
| } catch (ServletException se) {
| //unwrap servletException if we can (we can't rethrow a checked non-servlet exception)
| Throwable throwable = se.getRootCause();
| if (throwable instanceof RuntimeException) {
| RuntimeException runtimeException = (RuntimeException) throwable;
| throw runtimeException;
| }
| throw se;
| }
| }
| }
|
It works well if you don't care what kind of exception is thrown, or if you're looking for a runtime exception. If you're looking for a checked exception, your testcase is somewhat verbose:
|
| import javax.servlet.ServletException;
|
| import org.testng.annotations.Test;
|
| public class ExceptionFilterOverrideTest extends BaseIntegrationTest {
|
| @Test(expectedExceptions = IllegalStateException.class)
| public void testRuntimeException() throws Exception {
| new NonFacesRequest() {
| @Override
| protected void renderResponse() throws Exception {
| throw new IllegalStateException();
| }
| }.run();
| }
|
| @Test(expectedExceptions = Exception.class)
| public void testGeneralException() throws Exception {
| new NonFacesRequest() {
| @Override
| protected void renderResponse() throws Exception {
| throw new IllegalStateException();
| }
| }.run();
| }
|
| @Test(expectedExceptions = IllegalAccessException.class)
| public void testCheckedException() throws Exception {
| new NonFacesRequest() {
| @Override
| protected void renderResponse() throws Exception {
| throw new IllegalAccessException();
| }
|
| //this could be pulled into a superclass, if used frequently
| @Override
| public String run() throws Exception {
| try {
| return super.run();
| } catch (ServletException se) {
| handleServletException(se);
| return null; //nonreachable
| }
| }
|
| }.run();
| }
|
|
| private void handleServletException(ServletException se) throws Exception, ServletException {
| Throwable throwable = se.getRootCause();
| if (throwable instanceof Exception) {
| Exception exception = (Exception) throwable;
| throw exception;
| }
| throw se;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089038#4089038
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089038
18 years, 6 months
[Installation, Configuration & DEPLOYMENT] - deployment problems
by mrsmall
quick question have any of you used JBoss in the past - how do you deploy a enterprise application to Jboss.
I know of the /server/all/deploy.
but do I stick the .war archive file , and the .jar files (common etc..) and EJB 3 module with entity enterprise beans (xxx.ejb3 extension which is a little confusing as its the EJB3 version of archive i think! - not used it before but I'm just treating it as a java archive file i.e. .jar -not sure if this is correct!) and a .sar archive with message driven beans
now I'm sticking all these in the deploy directory as above and starting the server hoping some kind of auto deploy will kick in is this correct - or is there a console admin manger needed to deploy the .sar files etc... and does the .war file need to be placed elsewhere ?
i get following errors - although it starts the server:
i have 3 problems:
1) i dont understand the below message and what i need to do with it.
--- MBeans waiting for other MBeans ---
ObjectName: bt-global:service=RBGANRadiusService
State: CONFIGURED
I Depend On:
jboss.j2ee:module=rbgan.ejb3,service=EJB3
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:module=rbgan.ejb3,service=EJB3
State: NOTYETINSTALLED
Depends On Me:
bt-global:service=RBGANRadiusService
2) also when i go to the http://localhost:8080/rbgan
ie. the context url i dont get the following error in the webbrowser:
javax.servlet.ServletException: Could not load class com.bt.rbgan.web.DefaultSiteBody from WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@138d2fc
: com/bt/rbgan/exceptions/RbganException
org.apache.tapestry.engine.AbstractEngine.activateExceptionPage(AbstractEngine.java:497)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:931)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:198)
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:159)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
root cause
org.apache.tapestry.ApplicationRuntimeException: Could not load class com.bt.rbgan.web.DefaultSiteBody from WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@138d2fc
: com/bt/rbgan/exceptions/RbganException
org.apache.tapestry.enhance.DefaultComponentClassEnhancer.constructComponentClass(DefaultComponentClassEnhancer.java:134)
org.apache.tapestry.enhance.DefaultComponentClassEnhancer.getEnhancedClass(DefaultComponentClassEnhancer.java:97)
org.apache.tapestry.pageload.PageLoader.instantiateComponent(PageLoader.java:603)
org.apache.tapestry.pageload.PageLoader.createImplicitComponent(PageLoader.java:569)
org.apache.tapestry.BaseComponentTemplateLoader.createImplicitComponent(BaseComponentTemplateLoader.java:295)
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:237)
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:172)
org.apache.tapestry.BaseComponent.readTemplate(BaseComponent.java:100)
org.apache.tapestry.BaseComponent.finishLoad(BaseComponent.java:135)
org.apache.tapestry.pageload.PageLoader.constructComponent(PageLoader.java:519)
org.apache.tapestry.pageload.PageLoader.loadPage(PageLoader.java:764)
org.apache.tapestry.pageload.PageSource.getPage(PageSource.java:152)
org.apache.tapestry.engine.RequestCycle.getPage(RequestCycle.java:195)
org.apache.tapestry.engine.AbstractEngine.activateExceptionPage(AbstractEngine.java:470)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:931)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:198)
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:159)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
3) if i start the server with none of the application components then i get following errors - what do these mean:
07:16:09,597 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.jmx:name=SnmpAgent,service=trapd,type=logger
State: FAILED
Reason: java.net.BindException: Address already in use: Cannot bind
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jmx:name=SnmpAgent,service=trapd,type=logger
State: FAILED
Reason: java.net.BindException: Address already in use: Cannot bind
07:16:09,738 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-
8080
07:16:09,858 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
07:16:09,868 INFO [JkMain] Jk running ID=0 time=0/20 config=null
07:16:09,878 INFO [Server] JBoss (MX MicroKernel) [4.0.3SP1 (build: CVSTag=J
also i get the following error message - not sure how to resolve this also
status: Deployment FAILED reason: No ClassLoaders found for: org.jboss.ha.s
ingleton.HASingletonController; - nested throwable: (java.lang.ClassNotFoundE
xception: No ClassLoaders found for: org.jboss.ha.singleton.HASingletonContro
ller)
state: FAILED
watch: file:/D:/bgan-workspace/RBGAN-Firewall/RBGANFirewallManager.sar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089036#4089036
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089036
18 years, 6 months