[JAVA-2158] Java+Spark+Mongodb+web app+heroku Created: 25/Mar/16 Updated: 11/Sep/19 Resolved: 29/Mar/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Build, Connection Management |
| Affects Version/s: | 2.11.3 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Junwei Zhuge | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | connection, crash | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Mac Pro, heroku |
||
| Attachments: |
|
| Description |
|
I am making a web application with java and mongodb on Heroku. But I keep getting error like this: |
| Comments |
| Comment by Ross Lawley [ 29/Mar/16 ] |
|
Closing as this is a question better suited to the wider MongoDB Java community. |
| Comment by Ross Lawley [ 29/Mar/16 ] |
|
Just to let you know the JAVA project is specifically for driver based bugs or issues. For questions please use the mailing list or stackoverflow as you will reach the broader community. As stated in a previous comment there is a bug here: System.getenv("mongodb://heroku:111:10385/app45876994") is the cause of the NPE - there is no environment variable called mongodb://heroku:111:10385/app45876994. If you have a MONGOHQ_URL environment variable then update the code to use it eg: System.getenv("MONGOHQ_URL") or just pass the string URI to MongoClientURI. |
| Comment by mahdi mallaki [ 26/Mar/16 ] |
|
Hi Junwei, that wasn't correct. change line 28 to this: |
| Comment by Junwei Zhuge [ 25/Mar/16 ] |
|
Hi Mahdi, Thank you very much for your time. I changed it to mongodb://user:passwd@host1:port1,host2:port2/dbname as I mentioned before this comment. Is that not correct? I changed the Main.java in the attachments. Please let me know if you have any suggestions, I will be very appreciated. |
| Comment by mahdi mallaki [ 25/Mar/16 ] |
|
java can't access the MONGOHQ_URL variable that you used in line 32 of your code. maybe this is an alternative solution: new MongoClientURI("mongodb://heroku:111111@111:1111:11111/app45876994") |
| Comment by Junwei Zhuge [ 25/Mar/16 ] |
|
Hi mahdi, I changed this MONGOHQ_URL to mongodb://user:passwd@host1:port1,host2:port2/dbname, because I use MONGOHQ on Heroku, so I didn't use localhost. But I still get this error, almost the same error: 11:17:05 AM web.1 | SLF4J: Class path contains multiple SLF4J bindings. |
| Comment by mahdi mallaki [ 25/Mar/16 ] |
|
in line 32 you used a system variable: I suggest you to use change above code to this: (27017 is mongodb default port ) |
| Comment by Junwei Zhuge [ 25/Mar/16 ] |
|
It seems this log has never stopped. It just keep logging the same issue. I don't know what that mean. Whatever I have changed in my project, it seems log the same issue, so annoying. Any help would be appreciated. |
| Comment by Junwei Zhuge [ 25/Mar/16 ] |
|
@mahdimallaki this is the result of my `cat .env`: I am new to mongodb and heroku, can you explain more clearly what 'MONGOHQ_URL' variable mean? There is *MONGOHQ_URL* in the .env |
| Comment by mahdi mallaki [ 25/Mar/16 ] |
|
you didn't set 'MONGOHQ_URL' variable in your system. |