Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 462117

Summary: [bower] JsonSyntaxException exception occurs in Bower IDE while installing angular dependency
Product: [WebTools] JSDT Reporter: Victor Rubezhny <vrubezhny>
Component: GeneralAssignee: Stephane Begaudeau <stephane.begaudeau>
Status: RESOLVED FIXED QA Contact: Victor Rubezhny <vrubezhny>
Severity: normal    
Priority: P3 CC: stephane.begaudeau, thatnitind
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/44364
Whiteboard:
Bug Depends on:    
Bug Blocks: 459732    
Attachments:
Description Flags
Patch to fix the issue in bower branch none

Description Victor Rubezhny CLA 2015-03-13 20:10:13 EDT
When InstallCommand finishes the operation it tries to load the dependency bower.json file (in my case it's angular's bower (stored in bower_dependencies/angular/bower.json). So, reading that file throws the following exception:

!ENTRY org.eclipse.wst.jsdt.bower.code 4 0 2015-03-04 22:04:53.027
!MESSAGE java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 77
!STACK 0
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 77
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
    at com.google.gson.Gson.fromJson(Gson.java:803)
    at com.google.gson.Gson.fromJson(Gson.java:768)
    at com.google.gson.Gson.fromJson(Gson.java:717)
    at com.google.gson.Gson.fromJson(Gson.java:689)
    at org.eclipse.wst.jsdt.bower.core.api.AbstractBowerCommand.getBowerJson(AbstractBowerCommand.java:308)
    at org.eclipse.wst.jsdt.bower.core.api.InstallCommand.download(InstallCommand.java:129)
    at org.eclipse.wst.jsdt.bower.core.api.InstallCommand.call(InstallCommand.java:59)
    at org.eclipse.wst.jsdt.bower.ide.ui.internal.handlers.BowerInstallHandler.doExecute(BowerInstallHandler.java:44)
    at org.eclipse.wst.jsdt.bower.ide.ui.internal.handlers.AbstractBowerHandler$1.execute(AbstractBowerHandler.java:141)
    at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:108)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
    at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:130)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 77
    at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:338)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:79)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
    ... 13 more

despite the fact that the file looks OK for me:

{
  "name": "angular",
  "version": "1.3.9-build.3768+sha.b5e00cf",
  "main": "./angular.js",
  "ignore": [],
  "dependencies": {
  }
}

The bower.json Schema says there should be a String or an Array of Strings:

main - Recommended - Type: String or Array of String

But it looks like the only Array of String is currently supported.
Comment 1 Victor Rubezhny CLA 2015-03-20 17:03:20 EDT
Created attachment 251799 [details]
Patch to fix the issue in bower branch
Comment 3 Victor Rubezhny CLA 2015-03-20 19:50:01 EDT
Fixed in bower branch
Comment 4 Eclipse Genie CLA 2015-03-23 07:26:28 EDT
New Gerrit change created: https://git.eclipse.org/r/44364