List of usage examples for java.io NotSerializableException NotSerializableException
public NotSerializableException(String classname)
From source file:org.mule.keygenerator.ExpressionMuleEventKeyGenerator.java
public Serializable generateKey(MuleEvent event) throws NotSerializableException { Object key = event.getMuleContext().getExpressionManager().evaluate(expression, event); if (logger.isDebugEnabled()) { logger.debug("Generated key for event: " + event + " key: " + key); }//w ww. j a v a 2s. c om if (key instanceof Serializable) { return (Serializable) key; } else { throw new NotSerializableException("Generated key must a serializable object but was " + (key != null ? key.getClass().getName() : "null")); } }
From source file:org.mule.keygenerator.MD5MuleEventKeyGenerator.java
public Serializable generateKey(MuleEvent event) throws NotSerializableException { try {/*from www . ja va 2 s. co m*/ byte[] bytesOfMessage = event.getMessageAsBytes(); MessageDigest md = MessageDigest.getInstance("MD5"); String key = new String(md.digest(bytesOfMessage)); if (logger.isDebugEnabled()) { logger.debug("Generated key for event: " + event + " key: " + key); } return key; } catch (Exception e) { NotSerializableException notSerializableException = new NotSerializableException(e.getMessage()); notSerializableException.initCause(e); throw notSerializableException; } }
From source file:org.apache.tajo.webapp.QueryExecutorServlet.java
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException { throw new NotSerializableException(getClass().getName()); }
From source file:io.smartspaces.scheduling.quartz.orientdb.internal.util.SerialUtils.java
private static String rethrowEnhanced(JobDataMap jobDataMap, NotSerializableException e) throws NotSerializableException { final String key = getKeyOfNonSerializableStringMapEntry(jobDataMap.getWrappedMap()); throw new NotSerializableException(String.format(SERIALIZE_MESSAGE_FORMAT, key, e.getMessage())); }
From source file:org.apache.tajo.webapp.QueryExecutorServlet.java
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, ClassNotFoundException { throw new NotSerializableException(getClass().getName()); }
From source file:org.eclipse.ecf.provider.internal.org.change.ChangeClientContainer.java
public void connect(ID targetID, IConnectContext connectContext1) throws ContainerConnectException { // Set the connectTargetID in the AbstractClientContainer super class super.connect(targetID, connectContext1); // Create callables prior to registering them via registerCallables // below/*from www. j ava 2 s . c o m*/ List<IRemoteCallable> petitionCallables = new ArrayList<IRemoteCallable>(); // add callable for getPetitionId petitionCallables.add(new RemoteCallable.Builder("getPetitionId", "/v1/petitions/get_id") .setRequestType(new HttpGetRequestType()).build()); // add callables for other IPetitionService methods // Register callables registration = registerCallables(IPetitionService.class, petitionCallables.toArray(new IRemoteCallable[petitionCallables.size()]), null); setResponseDeserializer(new IRemoteResponseDeserializer() { @Override public Object deserializeResponse(String endpoint, IRemoteCall call, IRemoteCallable callable, @SuppressWarnings("rawtypes") Map responseHeaders, byte[] responseBody) throws NotSerializableException { try { return new JSONObject(new String(responseBody)).getInt("petition_id"); } catch (JSONException e) { NotSerializableException t = new NotSerializableException( "response from endpoint=" + endpoint + " could not be parsed"); t.setStackTrace(e.getStackTrace()); throw t; } } }); }
From source file:org.eclipse.ecf.remoteservice.rest.client.AbstractEntityRequestType.java
public RequestEntity generateRequestEntity(String uri, IRemoteCall call, IRemoteCallable callable, IRemoteCallParameter paramDefault, Object paramToSerialize) throws NotSerializableException { if (paramToSerialize instanceof RequestEntity) return (RequestEntity) paramToSerialize; switch (requestEntityType) { case INPUT_STREAM_REQUEST_ENTITY: if (paramToSerialize instanceof InputStream) { return new InputStreamRequestEntity((InputStream) paramToSerialize, getContentLength(call, callable, paramDefault), getContentType(call, callable, paramDefault)); }//from w w w .j av a 2s. c o m throw new NotSerializableException( "Cannot generate request entity. Expecting InputStream and got class=" //$NON-NLS-1$ + paramToSerialize.getClass().getName()); case STRING_REQUEST_ENTITY: if (paramToSerialize instanceof String) { try { return new StringRequestEntity((String) paramToSerialize, getContentType(call, callable, paramDefault), getCharset(call, callable, paramDefault)); } catch (UnsupportedEncodingException e) { throw new NotSerializableException( "Could not create request entity from call parameters: " + e.getMessage()); //$NON-NLS-1$ } } throw new NotSerializableException("Cannot generate request entity. Expecting String and got class=" //$NON-NLS-1$ + paramToSerialize.getClass().getName()); case BYTEARRAY_REQUEST_ENTITY: if (paramToSerialize instanceof byte[]) { return new ByteArrayRequestEntity((byte[]) paramToSerialize, getContentType(call, callable, paramDefault)); } throw new NotSerializableException("Cannot generate request entity. Expecting byte[] and got class=" //$NON-NLS-1$ + paramToSerialize.getClass().getName()); case FILE_REQUEST_ENTITY: if (paramToSerialize instanceof File) { return new FileRequestEntity((File) paramToSerialize, getContentType(call, callable, paramDefault)); } throw new NotSerializableException("Remote call parameter with name=" + paramDefault.getName() //$NON-NLS-1$ + " is incorrect type for creating request entity."); //$NON-NLS-1$ default: throw new NotSerializableException("Request entity generation not supported for this request type"); //$NON-NLS-1$ } }
From source file:org.castor.persist.proxy.SingleProxy.java
/** * {@inheritDoc}// w w w .j av a2s . c o m * @see net.sf.cglib.proxy.MethodInterceptor #intercept(java.lang.Object, * java.lang.reflect.Method, java.lang.Object[], * net.sf.cglib.proxy.MethodProxy) */ public Object intercept(final Object obj, final Method method, final Object[] args, final MethodProxy proxy) throws Throwable { String methodName = method.getName(); // to not load if method geClass() or finalize() if ("writeReplace".equals(methodName)) { if (LOG.isDebugEnabled()) { LOG.debug("writeReplacing " + _classMolder.getName() + " with identity " + _identity); } if (!_hasMaterialized) { try { _object = loadOnly(); } catch (ObjectNotFoundException e) { String msg = "Object with identity " + _identity + " does not exist"; LOG.error(msg, e); throw new NotSerializableException(msg); } catch (PersistenceException e) { String msg = "Problem serializing object with identity " + _identity; LOG.error(msg, e); throw new NotSerializableException(msg); } } if (LOG.isDebugEnabled()) { LOG.debug("Serializing instance of " + _object.getClass().getName()); LOG.debug("_object = " + _object); } return _object; } else if ("interceptedClass".equals(methodName)) { return _clazz; } else if ("interceptedHasMaterialized".equals(methodName)) { return new Boolean(_hasMaterialized); } else if ("interceptedIdentity".equals(methodName)) { return _identity; } else if ("interceptedClassMolder".equals(methodName)) { return _classMolder; } else if ("getClass".equals(methodName)) { return method.invoke(obj, args); } else if ("finalize".equals(methodName)) { return method.invoke(obj, args); } // load object, if not previous loaded if (_object == null) { _object = load(obj); } // object found? if (_object == null) { return null; } // invoke original method in loaded object return method.invoke(_object, args); }
From source file:org.apache.tinkerpop.gremlin.hadoop.process.computer.giraph.GiraphGraphComputer.java
@Override public int run(final String[] args) { this.giraphConfiguration.setBoolean(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT_HAS_EDGES, this.persist.equals(Persist.EDGES)); try {/* www. j a v a2 s. c o m*/ // it is possible to run graph computer without a vertex program (and thus, only map reduce jobs if they exist) if (null != this.vertexProgram) { // a way to verify in Giraph whether the traversal will go over the wire or not try { VertexProgram.createVertexProgram(this.hadoopGraph, ConfUtil.makeApacheConfiguration(this.giraphConfiguration)); } catch (IllegalStateException e) { if (e.getCause() instanceof NumberFormatException) throw new NotSerializableException( "The provided traversal is not serializable and thus, can not be distributed across the cluster"); } // prepare the giraph vertex-centric computing job final GiraphJob job = new GiraphJob(this.giraphConfiguration, Constants.GREMLIN_HADOOP_GIRAPH_JOB_PREFIX + this.vertexProgram); // handle input paths (if any) if (FileInputFormat.class.isAssignableFrom(this.giraphConfiguration .getClass(Constants.GREMLIN_HADOOP_GRAPH_INPUT_FORMAT, InputFormat.class))) { final Path inputPath = new Path( this.giraphConfiguration.get(Constants.GREMLIN_HADOOP_INPUT_LOCATION)); if (!FileSystem.get(this.giraphConfiguration).exists(inputPath)) // TODO: what about when the input is not a file input? throw new IllegalArgumentException("The provided input path does not exist: " + inputPath); FileInputFormat.setInputPaths(job.getInternalJob(), inputPath); } // handle output paths final Path outputPath = new Path( this.giraphConfiguration.get(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION) + "/" + Constants.HIDDEN_G); FileOutputFormat.setOutputPath(job.getInternalJob(), outputPath); job.getInternalJob().setJarByClass(GiraphGraphComputer.class); this.logger.info(Constants.GREMLIN_HADOOP_GIRAPH_JOB_PREFIX + this.vertexProgram); // execute the job and wait until it completes (if it fails, throw an exception) if (!job.run(true)) throw new IllegalStateException( "The GiraphGraphComputer job failed -- aborting all subsequent MapReduce jobs"); // how do I get the exception that occured? // add vertex program memory values to the return memory for (final String key : this.vertexProgram.getMemoryComputeKeys()) { final Path path = new Path( this.giraphConfiguration.get(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION) + "/" + key); final ObjectWritableIterator iterator = new ObjectWritableIterator(this.giraphConfiguration, path); if (iterator.hasNext()) { this.memory.set(key, iterator.next().getValue()); } FileSystem.get(this.giraphConfiguration).delete(path, true); } final Path path = new Path(this.giraphConfiguration.get(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION) + "/" + Constants.HIDDEN_ITERATION); this.memory.setIteration( (Integer) new ObjectWritableIterator(this.giraphConfiguration, path).next().getValue()); FileSystem.get(this.giraphConfiguration).delete(path, true); } // do map reduce jobs this.giraphConfiguration.setBoolean(Constants.GREMLIN_HADOOP_GRAPH_INPUT_FORMAT_HAS_EDGES, this.giraphConfiguration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT_HAS_EDGES, true)); for (final MapReduce mapReduce : this.mapReducers) { this.memory.addMapReduceMemoryKey(mapReduce); MapReduceHelper.executeMapReduceJob(mapReduce, this.memory, this.giraphConfiguration); } // if no persistence, delete the map reduce output if (this.persist.equals(Persist.NOTHING)) { final Path outputPath = new Path( this.giraphConfiguration.get(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION) + "/" + Constants.HIDDEN_G); if (FileSystem.get(this.giraphConfiguration).exists(outputPath)) // TODO: what about when the output is not a file output? FileSystem.get(this.giraphConfiguration).delete(outputPath, true); } } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } return 0; }