Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Last active December 18, 2015 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkMenard/5710668 to your computer and use it in GitHub Desktop.
Save MarkMenard/5710668 to your computer and use it in GitHub Desktop.
This Servelet listener is to work around https://github.com/jruby/jruby/issues/788 Written by bbrowning.
// Add this as a listener in your web.xml file prior to loading jruby-rack.
//
//
// <listener>
// <listener-class>lib.JnrConstantHackListener</listener-class>
// </listener>
// <listener>
// <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
// </listener>
package lib;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import jnr.constants.ConstantSet;
public class JnrConstantHackListener implements ServletContextListener {
public void contextInitialized(final ServletContextEvent event) {
ConstantSet.getConstantSet( "AddressFamily" );
ConstantSet.getConstantSet( "Errno" );
ConstantSet.getConstantSet( "Fcntl" );
ConstantSet.getConstantSet( "INAddr" );
ConstantSet.getConstantSet( "IPProto" );
ConstantSet.getConstantSet( "NameInfo" );
ConstantSet.getConstantSet( "OpenFlags" );
ConstantSet.getConstantSet( "PRIO" );
ConstantSet.getConstantSet( "ProtocolFamily" );
ConstantSet.getConstantSet( "RLIM" );
ConstantSet.getConstantSet( "RLIMIT" );
ConstantSet.getConstantSet( "Shutdown" );
ConstantSet.getConstantSet( "Signal" );
ConstantSet.getConstantSet( "Sock" );
ConstantSet.getConstantSet( "SocketLevel" );
ConstantSet.getConstantSet( "SocketOption" );
ConstantSet.getConstantSet( "Sysconf" );
ConstantSet.getConstantSet( "TCP" );
ConstantSet.getConstantSet( "WaitFlags" );
}
public void contextDestroyed(final ServletContextEvent event) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment