Reputation: 381
I am getting the below error when I tried to use HTTPS in spring native application.
java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol HTTPS is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.
HTTPS URL protocol was not enabled. Please help me to enable during the build.
Update
Found the solution, looking on spring native documentation. https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#native-image-options
Add the below code to pom.xml under the plugin section
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-https</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
Updated pom.xml looks like this.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-https</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
</env>
</image>
</configuration>
</plugin>
Upvotes: 4
Views: 1708
Reputation: 162
or if you using graalvm native image plugin:
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<version>21.0.0</version>
<configuration>
<!-- The native image build needs to know the entry point to your application -->
<mainClass>com.dccorp.nativeapps.NativeCloudStreamsApplication</mainClass>
<buildArgs>
<!-- uncomment to generate dump file for graalvm dashboard analysis.-->
<!-- -H:DashboardDump=dumpfileoversizedbuildArgs-->
<!-- -H:+DashboardAll-->
<!-- you can provide additional params. -->
<!-- -H:DynamicProxyConfigurationFiles=classes/proxy-config.json-->
<!-- -H:ReflectionConfigurationFiles=classes/reflect-config.json-->
--enable-url-protocols=http
</buildArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
Upvotes: 3
Reputation: 33
Open up your configurations file and add the following line to that file and I hope it will work, as it has been mentioned in the error as well.
--enable-url-protocols=https
Upvotes: -1