The error may occur because Maven is attempting to use system or IDE proxy settings when connecting to http://localhost:4502/crx/packmgr/service.jsp, which causes the request to be redirected (HTTP 301) instead of being processed directly by your local AEM instance.
Try to disable proxy usage for the content package plugin in your POM file. Add the following configuration to your content-package-maven-plugin or filevault-package-maven-plugin section: <useProxy>false</useProxy>
content-package-maven-plugin:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<configuration>
<targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL>
<username>${vault.user}</username>
<password>${vault.password}</password>
<useProxy>false</useProxy>
</configuration>
</plugin>
filevault-package-maven-plugin:
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<configuration>
<serviceURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</serviceURL>
<userId>${vault.user}</userId>
<password>${vault.password}</password>
<useProxy>false</useProxy>
</configuration>
</plugin>
If you require proxy configuration for external repositories but not for localhost, update your Maven settings.xml to exclude localhost from proxy routing:
<proxies>
<proxy>
<id>corporate-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.company.com</host>
<port>8080</port>
<nonProxyHosts>localhost|127.0.0.1|*.local</nonProxyHosts>
</proxy>
</proxies>
The nonProxyHosts element ensures local connections bypass the proxy.