Maven annoyances: “Web.Xml Is Missing And Is Set To True”

So you are getting this error in your Eclipse IDE

web.xml is missing and <failOnMissingWebXml&gt> is set to true

Here how you fix this silly error

Right click the project->Java EE Tools->Generate Deployment Descriptor Stub

Voila. Problem fixed.

Advertisements

Java and Cassandra setup on an AWS Linux server

Java 7 Setup

# First verify the version of Java being used is not Oracle JDK.
java -version

# Get the latest JDK 7 from Oracle http://www.oracle.com/technetwork/java/javase/downloads/
wget http://download.oracle.com/otn-pub/java/jdk/XXXXXX/jdk-7u71-linux-x64.rpm
# Install Java
sudo rpm -i jdk-7u71-linux-x64.rpm
# Check if the default java version is set to Oracle jdk
java -version

# If not then lets create one more alternative for Java for Oracle JDK
sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 20000
# Set the Oracle JDK as the default java
sudo /usr/sbin/alternatives --config java

# Verify if change in SDK was done.
java -version

Cassandra Setup

Download Cassandra from http://cassandra.apache.org/download/

  • Unzip/Untar the file apache-cassandra-2.1.0-bin.tar.gz
    • Copy the Cassandra folder apache-cassandra-2.1.0 to /usr/share
  • Edit the file /usr/share/apache-cassandra-2.1.0/conf/cassandra.yaml if necessary
  • Make sure /var/lib/cassandra has sufficient space

Start cassandra using the command:

/usr/share/apache-cassandra-2.1.o/bin/cassandra

Collections.sublist() not serializable

Ran into a strange serialization issue when trying to add a Java class to memcached…

Caused by:

java.io.NotSerializableException: java.util.RandomAccessSubList
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(
BaseSerializingTranscoder.java:105)

The problem was with a class member that was initialized with Collections.sublist() method. This method returns an instance of java.util.RandomAccessSubList which is not serializable.

The solution was to wrap initialize the list as an ArrayList.

new ArrayList<String>(biglist.subList(2, 4))