Package java.io

Examples of java.io.NotSerializableException


    private void writeObject(ObjectOutputStream oos) throws IOException
    {
      counter++;
      if (counter == 1)
      {
        throw new NotSerializableException();
      }
      throw new IllegalStateException("Cannot serialize me twice!");
    }
View Full Code Here


     * @since 1.1.0
     */
    void writePC(ObjectOutputStream oos, PersistenceCapable pc)
        throws IOException {
        if (!Serializable.class.isAssignableFrom(_meta.getDescribedType()))
            throw new NotSerializableException(_meta.getDescribedType().getName());

        oos.writeObject(pc);
    }
View Full Code Here

    private void writeObject(ObjectOutputStream out) throws IOException
    {
        if (!(bean instanceof PassivationCapable))
        {
            throw new NotSerializableException("Bean is not PassivationCapable: " + bean.toString());
        }
        String passivationId = ((PassivationCapable) bean).getId();
        if (passivationId == null)
        {
            throw new NotSerializableException(bean.toString());
        }

        out.writeLong(serialVersionUID);
        out.writeObject(passivationId);
        out.writeObject(instance);
View Full Code Here

    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
    {
        long oldSerialId = in.readLong();
        if (oldSerialId != serialVersionUID)
        {
            throw new NotSerializableException(getClass().getName() + " serialVersion does not match");
        }
        String passivationId = (String) in.readObject();
        bean = (Bean<T>) BeanManagerProvider.getInstance().getBeanManager().getPassivationCapableBean(passivationId);
        instance = (T) in.readObject();
        creationalContext = (CreationalContext<T>) in.readObject();
View Full Code Here

            return new JndiEncArtifact(this);
        } else if (IntraVmCopyMonitor.isCrossClassLoaderOperation()) {
            return new JndiEncArtifact(this);
        }

        throw new NotSerializableException("IntraVM java.naming.Context objects can not be passed as arguments");
    }
View Full Code Here

            baos = new ByteArrayOutputStream(128);
            ObjectOutputStream out = new ObjectOutputStream(baos);
            out.writeObject(object);
            out.close();
        } catch (NotSerializableException e) {
            throw (IOException) new NotSerializableException(e.getMessage()+" : The EJB specification restricts remote interfaces to only serializable data types.  This can be disabled for in-vm use with the "+OPENEJB_LOCALCOPY+"=false system property.").initCause(e);
        }

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ObjectInputStream in = new EjbObjectInputStream(bais);
        Object obj = in.readObject();
View Full Code Here

            baos = new ByteArrayOutputStream(128);
            ObjectOutputStream out = new ObjectOutputStream(baos);
            out.writeObject(object);
            out.close();
        } catch (NotSerializableException e) {
            throw (IOException) new NotSerializableException(e.getMessage()+" : The EJB specification restricts remote interfaces to only serializable data types.  This can be disabled for in-vm use with the "+OPENEJB_LOCALCOPY+"=false system property.").initCause(e);
        }

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ObjectInputStream in = new EjbObjectInputStream(bais);
        Object obj = in.readObject();
View Full Code Here

    Logger logger = LogManager.getLogger(SerializableChecker.class);
    logger.setLevel(Level.WARN);
    Log4jEventHistory logHistory = new Log4jEventHistory();
    logger.addAppender(logHistory);
    SerializableChecker serializableChecker = new SerializableChecker(
      new NotSerializableException());
    try
    {
      serializableChecker.writeObject(new TestType1());
      String expectedMessage = "Wasn't possible to check the object class org.apache.wicket.util.io.SerializableCheckerTest$ProblematicType possible due an problematic implementation of equals method";
      assertTrue(logHistory.contains(Level.WARN, expectedMessage));
View Full Code Here

   * @throws IOException
   */
  public void testNonSerializableTypeDetection() throws IOException
  {
    SerializableChecker serializableChecker = new SerializableChecker(
      new NotSerializableException());
    String exceptionMessage = null;
    try
    {
      serializableChecker.writeObject(new TestType2());
    }
View Full Code Here

    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception
    {
        if( !( message instanceof Serializable ) )
        {
            throw new NotSerializableException();
        }

        ByteBuffer buf = ByteBuffer.allocate( 64 );
        buf.setAutoExpand( true );
        buf.putObject( message );
View Full Code Here

TOP

Related Classes of java.io.NotSerializableException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.