title: Unable to overcome the "invalid wire type" when using protocol buffers with GTFS data
body: <p>I'm trying to consume Google's GTFS Data, but get this error when trying to parse the downloaded stream from the GTFS api</p>
  
  <p>This is the setup: </p>
  
  <ul>
  <li>I downloaded 'gtfs.proto' file which should define the message classes of realtime transit feed data from here <a href="https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto" rel="nofollow noreferrer">https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto</a> </li>
  </ul>
  
  <p>you can open this file with notepad, it says it is version 2.0</p>
  
  <ul>
  <li>I downloaded a windows 64 bit pre-compiled version of protoc, from here: 
  <a href="https://repo1.maven.org/maven2/com/google/protobuf/protoc/2.5.0/" rel="nofollow noreferrer">https://repo1.maven.org/maven2/com/google/protobuf/protoc/2.5.0/</a></li>
  </ul>
  
  <p>I run the executable downloaded which generates a java package that should be useable later, by suppying my downloaded proto file as follows:</p>
  
  <pre><code>protoc-2.5.0-windows-x86_64.exe --proto_path=. --java_out=. gtfs.proto
  </code></pre>
  
  <ul>
  <li><p>I started a Java project, and included the package which the previous step generated, and..</p></li>
  <li><p>I downloaded the protobuf version 2.5 runtime java library from the Maven repository - here: <a href="https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/2.5.0" rel="nofollow noreferrer">https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/2.5.0</a></p></li>
  <li><p>I included this run time library into my project</p></li>
  <li><p>I made a REST call (using different technology) to get a stream of data from the transit provider I am wanting to interface to. I placed this stream in c:\temp\GTFSR.data, it is what I will use as source data.</p></li>
  </ul>
  
  <p>I build a main() method designed to open the data, and pull out transit update records as follows:</p>
  
  <pre><code>import com.google.transit.realtime.GtfsRealtime.FeedEntity;
  import com.google.transit.realtime.GtfsRealtime.FeedMessage;
  import java.io.File;
  import java.io.FileInputStream;
  
  public class GtfsRealtimeExample {
  
  public static void main(String[] args) throws Exception {
  
    File file = new File("c:/temp/GTFSR.data"); 
    FeedMessage feed = FeedMessage.parseFrom(new FileInputStream(file));
  
    for (FeedEntity entity : feed.getEntityList()) {
         if (entity.hasTripUpdate()) {
            System.out.println(entity.getTripUpdate());
         }
     }
    }
  }
  </code></pre>
  
  <p>When I run this, however, I get the error: </p>
  
  <pre><code>Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
      at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:99)
      at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:498)
      at com.google.protobuf.AbstractMessage$Builder.mergeFieldFrom(AbstractMessage.java:508)
      at com.google.protobuf.GeneratedMessage$ExtendableMessage.parseUnknownField(GeneratedMessage.java:661)
      at com.google.transit.realtime.GtfsRealtime$FeedHeader.&lt;init&gt;(GtfsRealtime.java:1234)
      at com.google.transit.realtime.GtfsRealtime$FeedHeader.&lt;init&gt;(GtfsRealtime.java:1217)
      at com.google.transit.realtime.GtfsRealtime$FeedHeader$1.parsePartialFrom(GtfsRealtime.java:1291)
      at com.google.transit.realtime.GtfsRealtime$FeedHeader$1.parsePartialFrom(GtfsRealtime.java:1)
      at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:309)
      at com.google.transit.realtime.GtfsRealtime$FeedMessage.&lt;init&gt;(GtfsRealtime.java:154)
      at com.google.transit.realtime.GtfsRealtime$FeedMessage.&lt;init&gt;(GtfsRealtime.java:126)
      at com.google.transit.realtime.GtfsRealtime$FeedMessage$1.parsePartialFrom(GtfsRealtime.java:203)
      at com.google.transit.realtime.GtfsRealtime$FeedMessage$1.parsePartialFrom(GtfsRealtime.java:1)
      at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:200)
      at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:217)
      at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:223)
      at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
      at com.google.transit.realtime.GtfsRealtime$FeedMessage.parseFrom(GtfsRealtime.java:400)
      at GtfsRealtimeExample.main(GtfsRealtimeExample.java:20)
  </code></pre>
  
  <p>I've tried this with the most recent releases of protoc (version 3), and the corresponding v3 of the runtime library, but get the same result.</p>
  
  <p>What am I doing wrong ?!!</p>