Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext when building a function which calls Spring's Application Context #90

Closed
damadei opened this issue Feb 22, 2018 · 16 comments

Comments

@damadei
Copy link

damadei commented Feb 22, 2018

Plugin name and version

com.microsoft.azure.azure-functions-maven-plugin:0.1.10

Plugin configuration in your pom.xml

		<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>beta</value>
					</property>
				</appSettings>
			</configuration>
			<executions>
				<execution>
					<id>package-functions</id>
					<goals>
						<goal>package</goal>
					</goals>
				</execution>
			</executions>
		</plugin>

Expected behavior

Generate my maven package

Actual behavior

I'm getting the error bellow only when my code is using applicationContext.getBean() method. If I use ApplicationContext class, it works.

So it works with this:

ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath*:/application-context.xml");

If I add the following line, it stops working:

appContext.getBean("jdbcTemplate");

And the mvn clean package throws the following error:
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]


    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:166)
    ... 21 more

Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethod(Class.java:2128)
at org.reflections.util.Utils.getMemberFromDescriptor(Utils.java:88)
at org.reflections.util.Utils.getMethodsFromDescriptors(Utils.java:101)
at org.reflections.Reflections.getMethodsAnnotatedWith(Reflections.java:482)
at com.microsoft.azure.maven.function.handlers.AnnotationHandlerImpl.findFunctions(AnnotationHandlerImpl.java:43)
at com.microsoft.azure.maven.function.PackageMojo.findAnnotatedMethods(PackageMojo.java:97)
at com.microsoft.azure.maven.function.PackageMojo.doExecute(PackageMojo.java:62)
at com.microsoft.azure.maven.AbstractAzureMojo.execute(AbstractAzureMojo.java:288)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 32 more

Steps to reproduce the problem

@damadei
Copy link
Author

damadei commented Feb 22, 2018

Reproducer.zip
I'm attaching a reproducer, just run mvn clean package and the issue is show. Then comment the line 23 on Function.java and run again and the issue is gone.

@damadei
Copy link
Author

damadei commented Mar 1, 2018

I was able to get around this by declaring all my dependencies in the tag. However seems a bit awkward having to declare the dependencies twice:

com.microsoft.azure azure-functions-maven-plugin java-functions-group ${functionAppName} ${functionAppRegion} FUNCTIONS_EXTENSION_VERSION beta package-functions package
			<dependencies>
				<dependency>
					<groupId>org.apache.poi</groupId>
					<artifactId>poi</artifactId>
					<version>${apache.poi.version}</version>
				</dependency>

				<dependency>
					<groupId>org.apache.poi</groupId>
					<artifactId>poi-ooxml</artifactId>
					<version>${apache.poi.version}</version>
				</dependency>

				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-jdbc</artifactId>
					<version>${spring.components.version}</version>
				</dependency>

				<dependency>
					<groupId>com.microsoft.sqlserver</groupId>
					<artifactId>mssql-jdbc</artifactId>
					<version>${mssql-jdbc.version}</version>
				</dependency>

				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-beans</artifactId>
					<version>${spring.components.version}</version>
				</dependency>

				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-context</artifactId>
					<version>${spring.components.version}</version>
				</dependency>

				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-web</artifactId>
					<version>${spring.components.version}</version>
				</dependency>

				<dependency>
					<groupId>commons-dbcp</groupId>
					<artifactId>commons-dbcp</artifactId>
					<version>${commons.dbcp.version}</version>
				</dependency>
			</dependencies>
		</plugin>

@jdneo
Copy link
Member

jdneo commented Mar 16, 2018

Hi @damadei , sorry for the late reply.

Could you please explain more about declare the dependencies twice? Cause it looks like there is no duplicated denpendencies in your attached pom.xml?

@damadei
Copy link
Author

damadei commented Mar 16, 2018

Hi,

The maven Pom attached is the one that presents the error so it does not declared the dependencies twice. What I said is that to get rid of the issue I redeclared all dependencies again inside the plugin section for the azure functions plugin, this way it worked fine.

@jdneo
Copy link
Member

jdneo commented Mar 16, 2018

Yes I can reproduce the bug. It looks like something wrong with the classpath happened when we use the reflection to find the method with @FunctionName annotation.

Except duplicate the dependencies, another work around could be adding the maven shaded plugin into the pom file:

<build>
    ...
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
        </plugin>
        ...
    </plugins>
</build>

And please put the shaded plugin in the first place of the field to make sure the shaded jar will be packaged at the first time.

After we find out a way to fix the classpath issue, we will inform you in this issue thread. 😄

@roastario
Copy link

roastario commented Mar 20, 2018

+1 also encounter this issue, and the shade workaround does not work 👎

@jdneo
Copy link
Member

jdneo commented Mar 21, 2018

@damadei @roastario

Updated the code and I think the problem should be resolved.

The change has not been released, but you can install the code into your local machine to check if the problem is resolved. Really appreciated if you can help to verify.

Steps:

Install plugin

Update the pom.xml

@damadei take your pom file as an example:

    <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>0.1.10-SNAPSHOT</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>beta</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${project.build.directory}/azure-functions/${functionAppName}
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>host.json</include>
                                        <include>local.settings.json</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/azure-functions/${functionAppName}/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <includeScope>runtime</includeScope>
                    </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

In short, what we changed in the pom file:

  • change the plugin version to 0.1.10-SNAPSHOT (the version we local installed)
  • remove the section for maven-assembly-plugin
  • add the section for maven-dependency-plugin

More explanation

Recently, the Azure Java Function support to upload a lib folder to the cloud, and the cloud function host will add the files in the lib folder into the class path. This means we no need to use the fat jar any more.

In the plugin side, we add the maven-dependency-plugin to copy the runtime dependency into the lib folder, and we will add the jars in that folder into the class path when we treat the annotation through reflection. Meanwhile, the maven-assembly-plugin can also be removed.

@roastario
Copy link

roastario commented Mar 21, 2018

Hi, thanks for getting back so fast!

I've tried to follow the above instructions and encountered some issues

  1. Someone's been naughty, and there is a checkstyle error
  2. There is also a test compilation error

so the maven command line needed is:

mvn clean install -DskipTests -Dcheckstyle.skip=true  -Dmaven.test.skip

Once this was completed, I did as described above and set the version of the plugin to 0.1.10-SNAPSHOT, removed the maven-assembly plugin and removed the dependencies from the azure-functions-plugin configuration, but I still encounter:

package-functions of goal com.microsoft.azure:azure-functions-maven-plugin:0.1.10-SNAPSHOT:package failed: A required class was missing while executing com.microsoft.azure:azure-functions-maven-plugin:0.1.10-SNAPSHOT:package: net/corda/core/node/NetworkParameters
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>com.microsoft.azure:azure-functions-maven-plugin:0.1.10-SNAPSHOT
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-functions-maven-plugin/0.1.10-SNAPSHOT/azure-functions-maven-plugin-0.1.10-SNAPSHOT.jar
[ERROR] urls[1] = file:/home/stefano/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[2] = file:/home/stefano/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
[ERROR] urls[3] = file:/home/stefano/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.0/org.eclipse.sisu.inject-0.3.0.jar
[ERROR] urls[4] = file:/home/stefano/.m2/repository/org/apache/maven/maven-builder-support/3.3.3/maven-builder-support-3.3.3.jar
[ERROR] urls[5] = file:/home/stefano/.m2/repository/org/eclipse/aether/aether-util/1.0.2.v20150114/aether-util-1.0.2.v20150114.jar
[ERROR] urls[6] = file:/home/stefano/.m2/repository/org/sonatype/sisu/sisu-guice/3.2.5/sisu-guice-3.2.5-no_aop.jar
[ERROR] urls[7] = file:/home/stefano/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[8] = file:/home/stefano/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar
[ERROR] urls[9] = file:/home/stefano/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[10] = file:/home/stefano/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[11] = file:/home/stefano/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[12] = file:/home/stefano/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
[ERROR] urls[13] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-maven-plugin-lib/0.1.7/azure-maven-plugin-lib-0.1.7.jar
[ERROR] urls[14] = file:/home/stefano/.m2/repository/org/apache/maven/shared/maven-filtering/3.0.0/maven-filtering-3.0.0.jar
[ERROR] urls[15] = file:/home/stefano/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[16] = file:/home/stefano/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[17] = file:/home/stefano/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[18] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure/1.2.1/azure-1.2.1.jar
[ERROR] urls[19] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-resources/1.2.1/azure-mgmt-resources-1.2.1.jar
[ERROR] urls[20] = file:/home/stefano/.m2/repository/org/slf4j/slf4j-simple/1.7.5/slf4j-simple-1.7.5.jar
[ERROR] urls[21] = file:/home/stefano/.m2/repository/io/reactivex/rxjava/1.2.4/rxjava-1.2.4.jar
[ERROR] urls[22] = file:/home/stefano/.m2/repository/org/apache/httpcomponents/httpcore/4.4.5/httpcore-4.4.5.jar
[ERROR] urls[23] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-storage/1.2.1/azure-mgmt-storage-1.2.1.jar
[ERROR] urls[24] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-network/1.2.1/azure-mgmt-network-1.2.1.jar
[ERROR] urls[25] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-compute/1.2.1/azure-mgmt-compute-1.2.1.jar
[ERROR] urls[26] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-graph-rbac/1.2.1/azure-mgmt-graph-rbac-1.2.1.jar
[ERROR] urls[27] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-keyvault/1.2.1/azure-mgmt-keyvault-1.2.1.jar
[ERROR] urls[28] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-batch/1.2.1/azure-mgmt-batch-1.2.1.jar
[ERROR] urls[29] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-trafficmanager/1.2.1/azure-mgmt-trafficmanager-1.2.1.jar
[ERROR] urls[30] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-dns/1.2.1/azure-mgmt-dns-1.2.1.jar
[ERROR] urls[31] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-redis/1.2.1/azure-mgmt-redis-1.2.1.jar
[ERROR] urls[32] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-appservice/1.2.1/azure-mgmt-appservice-1.2.1.jar
[ERROR] urls[33] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-cdn/1.2.1/azure-mgmt-cdn-1.2.1.jar
[ERROR] urls[34] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-sql/1.2.1/azure-mgmt-sql-1.2.1.jar
[ERROR] urls[35] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-containerregistry/1.2.1/azure-mgmt-containerregistry-1.2.1.jar
[ERROR] urls[36] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-cosmosdb/1.2.1/azure-mgmt-cosmosdb-1.2.1.jar
[ERROR] urls[37] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-search/1.2.1/azure-mgmt-search-1.2.1.jar
[ERROR] urls[38] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-mgmt-servicebus/1.2.1/azure-mgmt-servicebus-1.2.1.jar
[ERROR] urls[39] = file:/home/stefano/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
[ERROR] urls[40] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-client-runtime/1.1.0/azure-client-runtime-1.1.0.jar
[ERROR] urls[41] = file:/home/stefano/.m2/repository/com/microsoft/rest/client-runtime/1.1.0/client-runtime-1.1.0.jar
[ERROR] urls[42] = file:/home/stefano/.m2/repository/com/squareup/retrofit2/retrofit/2.1.0/retrofit-2.1.0.jar
[ERROR] urls[43] = file:/home/stefano/.m2/repository/com/squareup/okhttp3/okhttp/3.3.1/okhttp-3.3.1.jar
[ERROR] urls[44] = file:/home/stefano/.m2/repository/com/squareup/okio/okio/1.8.0/okio-1.8.0.jar
[ERROR] urls[45] = file:/home/stefano/.m2/repository/com/squareup/okhttp3/logging-interceptor/3.3.1/logging-interceptor-3.3.1.jar
[ERROR] urls[46] = file:/home/stefano/.m2/repository/com/squareup/okhttp3/okhttp-urlconnection/3.3.1/okhttp-urlconnection-3.3.1.jar
[ERROR] urls[47] = file:/home/stefano/.m2/repository/com/squareup/retrofit2/converter-jackson/2.1.0/converter-jackson-2.1.0.jar
[ERROR] urls[48] = file:/home/stefano/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.7.2/jackson-databind-2.7.2.jar
[ERROR] urls[49] = file:/home/stefano/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-joda/2.7.2/jackson-datatype-joda-2.7.2.jar
[ERROR] urls[50] = file:/home/stefano/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar
[ERROR] urls[51] = file:/home/stefano/.m2/repository/com/squareup/retrofit2/adapter-rxjava/2.1.0/adapter-rxjava-2.1.0.jar
[ERROR] urls[52] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-client-authentication/1.1.0/azure-client-authentication-1.1.0.jar
[ERROR] urls[53] = file:/home/stefano/.m2/repository/com/microsoft/azure/adal4j/1.1.2/adal4j-1.1.2.jar
[ERROR] urls[54] = file:/home/stefano/.m2/repository/com/nimbusds/oauth2-oidc-sdk/4.5/oauth2-oidc-sdk-4.5.jar
[ERROR] urls[55] = file:/home/stefano/.m2/repository/javax/mail/mail/1.4.7/mail-1.4.7.jar
[ERROR] urls[56] = file:/home/stefano/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
[ERROR] urls[57] = file:/home/stefano/.m2/repository/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar
[ERROR] urls[58] = file:/home/stefano/.m2/repository/net/minidev/json-smart/1.1.1/json-smart-1.1.1.jar
[ERROR] urls[59] = file:/home/stefano/.m2/repository/com/nimbusds/lang-tag/1.4/lang-tag-1.4.jar
[ERROR] urls[60] = file:/home/stefano/.m2/repository/com/nimbusds/nimbus-jose-jwt/3.1.2/nimbus-jose-jwt-3.1.2.jar
[ERROR] urls[61] = file:/home/stefano/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.51/bcprov-jdk15on-1.51.jar
[ERROR] urls[62] = file:/home/stefano/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
[ERROR] urls[63] = file:/home/stefano/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar
[ERROR] urls[64] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-annotations/1.2.0/azure-annotations-1.2.0.jar
[ERROR] urls[65] = file:/home/stefano/.m2/repository/com/microsoft/azure/applicationinsights-core/1.0.9/applicationinsights-core-1.0.9.jar
[ERROR] urls[66] = file:/home/stefano/.m2/repository/eu/infomas/annotation-detector/3.0.4/annotation-detector-3.0.4.jar
[ERROR] urls[67] = file:/home/stefano/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[68] = file:/home/stefano/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar
[ERROR] urls[69] = file:/home/stefano/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
[ERROR] urls[70] = file:/home/stefano/.m2/repository/commons-net/commons-net/3.6/commons-net-3.6.jar
[ERROR] urls[71] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-functions-java-core/1.0.0-beta-2/azure-functions-java-core-1.0.0-beta-2.jar
[ERROR] urls[72] = file:/home/stefano/.m2/repository/org/reflections/reflections/0.9.11/reflections-0.9.11.jar
[ERROR] urls[73] = file:/home/stefano/.m2/repository/com/google/guava/guava/20.0/guava-20.0.jar
[ERROR] urls[74] = file:/home/stefano/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar
[ERROR] urls[75] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-storage/5.4.0/azure-storage-5.4.0.jar
[ERROR] urls[76] = file:/home/stefano/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.0/jackson-core-2.6.0.jar
[ERROR] urls[77] = file:/home/stefano/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar
[ERROR] urls[78] = file:/home/stefano/.m2/repository/com/microsoft/azure/azure-keyvault-core/0.8.0/azure-keyvault-core-0.8.0.jar
[ERROR] urls[79] = file:/home/stefano/.m2/repository/org/zeroturnaround/zt-zip/1.12/zt-zip-1.12.jar
[ERROR] urls[80] = file:/home/stefano/.m2/repository/junit/junit/4.12/junit-4.12.jar
[ERROR] urls[81] = file:/home/stefano/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: net.corda.core.node.NetworkParameters

Interestingly, the jar that contains that class (corda-api) is not on the list of scanned jars.

Adding the list of dependencies back to the plugin configuration does work.

@jdneo
Copy link
Member

jdneo commented Mar 22, 2018

@roastario Did you add the maven-dependency-plugin in your pom?

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/azure-functions/${functionAppName}/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <includeScope>runtime</includeScope>
                    </configuration>
                    </execution>
                </executions>
            </plugin>

@roastario
Copy link

roastario commented Mar 22, 2018 via email

@jdneo
Copy link
Member

jdneo commented Mar 22, 2018

@roastario Great! Thanks.

@roastario
Copy link

hokay @jdneo I've pushed it to: https://github.com/roastario/azure-functions-networkmap and it's on branch "new_plugins_investigation"

feel free to check it out and test it!

@jdneo
Copy link
Member

jdneo commented Mar 23, 2018

@roastario I tested your code, and no error occurred during the package lifecycle.

I also tested to package after removing all the dependencies definition in the azure-functions-maven-plugin configuration, also works well.

Does the problem still occur on your side?

@roastario
Copy link

@jdneo

Hi, I must apologize, I just tried it again with removing the second list of dependencies and it worked. I must have had something odd in my environment.

Looks like it's fixed, thanks 👍

@jdneo
Copy link
Member

jdneo commented Mar 23, 2018

@roastario Thank you too to share the project to me and help verify the issue. 😄

I'll inform you in this issue thread once we released this fix into the Maven Central.

@jdneo
Copy link
Member

jdneo commented Apr 2, 2018

@roastario @damadei

v0.2.0 released. Please have a try!

@jdneo jdneo reopened this Apr 2, 2018
@jdneo jdneo closed this as completed Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants