Home
Web CMS (TeamSite)
Inline Java code issue
nawalt
Hi,
i am using TS 7.3 and have an inline java code to populate a drop down box. The java code makes https get request to a URL (api call to a external url) which return the drop down values, which i populate as the substitution text and return back.
The issue is when i execute the java code on the command prompt (Windows 2008), The code executes , makes the api call to the exteranl url a response is returned and the substitution string is created. The same code when executes via the inline command fails as the java code throws unknowHostException for the api URL.
Is there any configuration which i need to do so that the java code succeeds when called via the inline in DCT ? Seems that that the same java code fails to query the api URL when called via inline.
Please help.
Find more posts tagged with
Comments
Adam Stoller
Besides possibly running into cross-domain or untrusted host issues - the most likely source of the problem is that inline scripts do NOT get passed the full environment data - so you need to explicitly set environment variables within your inline code in order to make sure that what you need is there.
E.g.: CLASSPATH, LD_LIBRARY_PATH, PATH, etc - you will need to make sure that these are explicitly configured within your Java code because they most likely will not exist at all when the code is run from an inline directive (but they do exist when you run the code from the command line)
Rick Poulin
Java natively understands how to do HTTP, assuming you're using the HttpUrlConnection class to do your fetch. If you're forking to some other process, then yes the env vars could very well be to blame. I'd sooner think that your URL to the external service is being constructed improperly, and your Java is missing some context to figure it out. Try logging the URL right before the call and compare between the one that works and the one that doesn't. If they're the same, then that means on the one side your Java can't connect to a DNS server (or isn't allowed to) when run by TeamSite -- check your windows firewall and all that fun stuff for restrictions.