0

I have a java azure function that was running package azure-functions-maven-plugin version 1.3, trying to upgrade the package to anything 1.4 or greater when I try to package the function I get the following error:

Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.12.0:package (package-functions) on project azure-functions-archetype: com.google.gson.stream.MalformedJsonException: Expected name at line 9 column 4 path $.extensions.http

My Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-functions-archetype</artifactId>
    <version>1.38</version>
    <packaging>jar</packaging>
<dependency>
       <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-documentdb</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-storage</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>adal4j</artifactId>
            <version>1.1.2</version>
        </dependency>
    
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.0.0.jre8</version>
    </dependency>
</dependency>
 <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <groupId>com.microsoft.azure</groupId>
                    <artifactId>azure-functions-maven-plugin</artifactId>
                    <version>1.12.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <configuration>
                    <resourceGroup>java-functions-group</resourceGroup>
                    <appName>${functionAppName}</appName>
                    <region>${functionAppRegion}</region>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~3</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
```



I m unable to find a solution online on what is causing this error, hoping someone out there has an idea  
user1953901
  • 21
  • 1
  • 5

1 Answers1

0

Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.12.0:package (package-functions) on project azure-functions-archetype: com.google.gson.stream.MalformedJsonException:

It seems to be the issue in pom.xml code like either the tags are misspelled or the azure functions maven plugin code is missing or written wrong.

There is a similar issue here resolved by specifying the runtime and correcting the misspelt tags/code.

Also, Please make changes in your pom.xml file by comparing with my pom.xml as I see in the given pom.xml is missing the azure.functions.maven.plugin.version, runtime OS property etc. (https://i.stack.imgur.com/DrobX.png, https://i.stack.imgur.com/aRanA.png).

Reference: pom.xml code

I tried to run the Azure Functions Project (Java Stack) in VS Code and it come up with many issues regarding to loading the dependencies, Java Compiler Packages etc. and finally running the function successfully by following the below steps:

  1. Maven version 3.8.4
  2. Azure Functions Maven Plugin 1.15

Process 1: Created the Azure Java Functions Project through VS Code and run the function successfully:

enter image description here

Process 2: Created azure functions project using maven-archetype-quickstart template and is working good.

Run this command in your VS Code terminal:

mvn archetype:generate -DgroupId=com.microsoft.azure -DartifactId=azure-functions-archetype -DinteractiveMode=false

enter image description here

  • Since archetypes are templates and they intend to reflect current best practices, they can evolve in time, thus they have their own versions. Maven will ask you which version of the archetype you want to use. By default, maven chooses latest version for you. so if you agree to use the latest version of an archetype, just press Enter at this step;

  • Every maven project (and module) has its groupId, artifactId and version. Maven will then ask these to you in three steps. groupId: This is generally unique amongst an organization or a project. artifactId: The artifactId is generally the name that the project is known by. version: This is the last piece of the naming puzzle.(read more)

  • Finally, maven will ask you the package structure for your code. A best practice is to create your folder structure that reflects the groupId, thus Maven sets this as default but you are free to change this.

After entering these information, Maven will show you all the information you entered and ask you to verify project creation. If you press Y and then enter, voila your project is created with the artifact and settings you chose.

You can also read maven-archetype-plugin's usage site.

To Update the pom.xml versions, please run the commands (in your VS Code Project terminal) available in this Maven official site.