Figured it out! The problem is in my /private/etc/hosts file. For whatever reason, certain processes were not respecting this file - specifically maven and other build tools such as Angular CLI (trying Angular is how I ultimately picked up on what was happening). In short, "localhost" was not resolving to 127.0.0.1 when running maven install. It was instead resolving to nonsense IP's (a few different ones actually). The tricky part was that "localhost" did correctly resolve in the browser or when running terminal commands such as telnet/curl manually. If this hadn't been the case the problem would have been super obvious.
But in any case my hosts file had the "127.0.0.1 localhost" entry like you'd expect so something else was up. I added a new line like "127.0.0.1 localhost2" to see if this resolved correctly, and it did not. Not in maven, angular, the browser, or telnet/curl. So obviously the hosts file was not being read correctly by the system.
The solution was to:
Not sure if it was the removing/replacing of the hosts file that caused system to correct, or perhaps it was actually the tab characters in the file that were the problem. Worth doing both I guess. I still don't understand why the problem sort of came about gradually like it did, or why localhost resolved correctly in some places but not others. Maybe I'll never know. Oh well.
Hi, I'm very new to AEM and have run into a problem that I have been trying to solve for a week. It is absolutely befuddling. I have no ideas as to what the solution might be, other than to completely reinstall MacOSX (running AEM 6.5 author instance from a quickstart jar that was provided from me on a Macbook pro).
Like I said I'm new so maybe this is all pretty standard, but the way our codebase works is there are a number of different projects that maven builds and installs onto your local AEM instance as content-packages. It was all working fine since I started a few weeks ago, until last week when out of the blue I ran the normal "mvn clean install" with the standard profile argument for our project, and got an error like "The host did not accept the connection within the timeout period" or something like that. Then every subsequent retry the error reads:
Failed to execute goal com.day.jcr.vault:content-package-maven-plugin:0.0.24:install (install-content-package-author) on project myproject-package: connection refused (connection refused) -> [Help 1]
(my-project-package is called something else in reality)
So immediately I thought "I must have forgotten to start AEM", because I'd seen that error before and that was the cause. But no, AEM was running on the normal port as always. Completely accessible from the browser: the sites, the crx/de, the package manager, everything.
I try again and again and nothing works. Restart AEM, restart machine, etc. Connection refused. I try other projects (we have multiple projects that build into separate content). Connection refused.
Rather than troubleshoot further I just delete my AEM instance entirely and reinstall. Problem solved, all projects install normally... for about two days. Then randomly, when building my changes to local instance: "The host did not accept the connection within...". I can't think of anything I might have done to prompt it but the same error reappeared.
I reinstalled, started installing packages. A few installed correctly, but I didn't even get through all of them before I ran into the familiar "host did not accept the connection".
Every subsequent try resulted in "Connection refused" as before. But this time, reinstalling aem DID NOT HELP. I have done it 4 times now, completely deleting the crx-quickstart folder and the jar file, everything I know to do. I also reinstalled maven, deleted my .m2 folder, probably several other things I'm forgetting. "Connection refused".
When I ran the mvn command with all the debug logs I eventually found that it was trying to connect to "localhost:4502/crx/packmgr/service.jsp". I try this url in the browser. Works fine as far as I can tell, returns this xml snippet with the possible arguments for that jsp.
I look at the pom, credentials and url seem fine, and besides, I haven't made any changes to configuration.
I attempt to reach it with curl. This is not my area of expertise but trying to guess at what the underlying call maven is doing is, I ran a command like
curl -v -X POST -u admin:admin http://localhost:4502/crx/packmgr/service.jsp&file=my-content/target/my-content-package.zip
It returns a 200OK and the same xml snippet that the base address returned in the browser. Which is not quite what I expected, like maybe it means the call is not quite formed right, but still there's no problem reaching the resource.
If you offered me a million dollars to solve this without help and without reinstalling the OS. I'm completely out of ideas, like literally there's nothing else I know to do other than the same stuff I've already done. And the senior dev I talked to on friday had no idea what to make of it either. In fact he didn't even believe me and insisted my AEM instance was not running until I hopped onto a zoom call and showed him.
Connection Refused error pops up only then the instance is not running with the configured host:port that is mentioned in pom.xml i.e., let's say if you have defined the host and port in pom.xml as localhost:4504 and your AEM instance is running on localhost:4502, then you will get this error.
Anaother use case can be if the instance is running on a different machine and you are trying to deploy from your machine using IP address and the connection between 2 machine cannot be established using IP due to any restrictions, you will get this error.
So debug this issue please follow the below steps:
Now run the below command and it should deploy the code:
mvn clean install -PautoInstallPackage
Hi asutosh_jena. As I noted in my post, I looked for both these problems and have all but ruled them out. I was hoping someone knew of some cached file outside of the crx-quickstart location that might be carrying over bad state of some kind between reinstalls. Or something like that. Like I said I'm out of ideas other than wiping my machine