code: @Override
      protected void writeObjectOverride(final Object object) throws IOException {
          try {
              outputStream.writeObject(object);
          } catch (NotSerializableException e) {
              if (CheckingObjectOutputStream.isAvailable()) {
                  // trigger serialization again, but this time gather some more info
                  new PaxWicketSerializableChecker(e) {
                      @Override
                      protected boolean validateAdditionalSerializableConditions(Object obj) {
                          return !(obj instanceof BundleContext) && !(obj instanceof Bundle);
                      }
  
                      @Override
                      protected Object additionalObjectReplacements(Object streamObj) {
                          if (streamObj instanceof BundleContext) {
                              BundleContext context = (BundleContext) streamObj;
                              streamObj = new ReplaceBundleContext(context);
                          } else if (streamObj instanceof Bundle) {
                              Bundle bundle = (Bundle) streamObj;
                              streamObj = new ReplaceBundle(bundle);
                          }
                          return streamObj;
                      }
                  }.writeObject(object);
                  // if we get here, we didn't fail, while we should;
                  throw e;
              }
              throw e;
          } catch (RuntimeException e) {
              LOGGER.error("error writing object " + object + ": " + e.getMessage(), e);
              throw e;
          }
      }
docs: {@inheritDoc}