Skip navigation
2012

Ondrej Zizka's Blog

September 2012 Previous month Next month

It's ok to change standalone.xml in OpenShift, if you take care not to remove things like MysqlDS provided by OpenShift's infrastructure.

 

After checkout, the file is located in /.openshift/config/standalone.xml .

It's hidden both on Windows and Linux.

It's also ignored, so changes to it can't be added to git's stage.

To unignore this and only this file, change the relevant part in /.gitignore from

/.openshift/

to

/.openshift/*
!/.openshift/config/

/.openshift/config/*
!/.openshift/config/standalone.xml

After that, you can `git add`.

 

Upon pushing, the AS is restarted with the new file. Check if your app responds.

 

If you see HTTP 503 - Temporarily unavailable, SSH your app's shell (see the "NEED TO LOGIN TO YOUR APP?" at app's OpenShift page) and check:

tail -200f /jbossas-7/logs/boot.log

 

If you see HTTP 500, then something's wrong in your app;

If you see a blank page, something went south during the deployment phase.

In both cases, see

tail -200f /jbossas-7/logs/server.log

Those who tried to run Wicket on JBoss AS 7 hit this:

 

java.lang.ClassNotFoundException: org.jboss.msc.service.ServiceName from [Module "deployment.ROOT.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
...
at org.apache.wicket.application.AbstractClassResolver.resolveClass(AbstractClassResolver.java:108)
at org.apache.wicket.serialize.java.JavaSerializer$ClassResolverObjectInputStream.resolveClass(JavaSerializer.java:216)

 

Well, the proper solution would be a special serializer, but who has time to do it.

 

So the quick workaround for that is to add org.jboss.msc to app's dependencies.

 

Add the org.jboss.msc module to dependencies. E.g. put this to META-INF/MANIFEST.MF :

Dependencies: org.jboss.msc

 

 

E.g. using this in pom.xml: 

 

    <build>
       ...
       <plugins>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-war-plugin</artifactId>
           <configuration>
              <archive>
                 <manifestEntries>
                    <Dependencies>org.jboss.msc</Dependencies>
                 </manifestEntries>  
              </archive>
           </configuration>
         </plugin>   
       </plugins>
    </build>
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.IExceptionMapper;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.handler.PageProvider;
import org.apache.wicket.request.handler.RenderPageRequestHandler;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.IProvider;

public class MyApplication extends WebApplication {

    /**
     *  Maps exceptions to pages.
     */
    @Override public IProvider<IExceptionMapper> getExceptionMapperProvider() {
        return new IProvider<IExceptionMapper>() {
            @Override public IExceptionMapper get() {
                return new IExceptionMapper() {
                    final DefaultExceptionMapper def = new DefaultExceptionMapper();

                    @Override public IRequestHandler map( Exception ex ) {
                        PageParameters par = new PageParameters().add("ex", ex);

                        // Possible workaround for AS7-4554, WICKET-4785 - only for stateful pages.
                        // java.lang.ClassNotFoundException: org.jboss.msc.service.ServiceName
                        // at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                        if( ClassNotFoundException.class.isInstance(ex) ){
                            if("org.jboss.msc.service.ServiceName".equals( ((ClassNotFoundException)ex).getMessage() ) )
                                 return new RenderPageRequestHandler(new PageProvider(HomePage.class, par) );
                        }
                        return def.map( ex );                    }
                };
            }
        };
    }

}

 

I plan to create some convenience MapExceptionMapper which would work like

 

new MapExceptionMapper()
   //                     Type, Destination
   .add( Exception.class, ExceptionPage.class )
   .add( ... )

 

Sources:

https://cwiki.apache.org/WICKET/migration-to-wicket-15.html#MigrationtoWicket1.5-Exceptionhandling

 

Exception handling

In Wicket 1.4 it was needed to extend org.apache.wicket.RequestCycle.onRuntimeException(Page, RuntimeException).
Wicket 1.5 gives even better control:

  • add your own org.apache.wicket.request.cycle.IRequestCycleListener (AbstractRequestCycleListener) with org.apache.wicket.Application.getRequestCycleListeners().add() and implement its #onException(RequestCycle, Exception)
  • or override org.apache.wicket.Application.getExceptionMapperProvider() - the IExceptionMapper is used if none of the configured IRequestCycleListeners doesn't know how to handle the exception.
    For information on how the request cycle handles exceptions see RequestCycle in Wicket 1.5 for more information

Filter Blog

By date:
By tag: