connection refused exception when trying to run a jar via web start - java

I am getting the following exception when trying to run my jar through java web start:
com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost /ValidatorWEB/validator.jnlp
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
This is the wrapped exception:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
Here is my .jnlp file:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost/ValidatorWEB/"
href="validator.jnlp">
<information>
<title>Validator</title>
<vendor>My Company</vendor>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.6+"
href="http://java.sun.com/products/autodl/j2se"/>
<jar href="WEB-INF/lib/validator.jar" main="true" />
</resources>
<application-desc
name="Validator"
main-class="webstartComponentArch.DynamicTreeApplication"
width="300"
height="300">
</application-desc>
<update check="background"/>
I am deploying the whole thing as a simple WAR to glassfish v2.1 on my local machine. The validator.jar is located in WEB-INF/lib and the jnlp and jsp page I am accessing the jnlp from is at the root of the ValidatorWEB folder.
Googling hasn't helped. I have tried turning my firewall off and it still does the same thing. I have the appropriate Mime-type set in Glassfish. Is there something else I'm forgetting to do?

You do know what http://localhost actually points to? It points to the web server which is running at localhost at port 80. Localhost == 127.0.0.1 == local machine.
As Webstart aka JNLP apps runs at the client machine, it will try to connect the web server at the same (local) machine. You don't want to do that. Change the URL to point to the actual web server at the server machine where your webapp runs and where JNLP is to be downloaded from.

So I figured it out. The problem was where I am specifying the base url:
<jnlp spec="1.0+" codebase="http://localhost/ValidatorWEB/" href="validator.jnlp">
When I deployed to Glassfish, the url that I would access the web application through is actually:
http://localhost:8080/ValidatorWEB/
I had to change my codebase to read:
<jnlp spec="1.0+" codebase="http://localhost:8080/ValidatorWEB/" href="validator.jnlp">
This is something I will definitely have to keep in mind when deploying to a remote server.
Thanks for all of the input!

The spaces after localhost make me suspicious - is there a chance you've defined the hostname with trailing spaces somewhere and web start isn't having any of it?
Also, have you tried simply wgetting (or similar) the listed jnlp URL? The response from the request will let you see what's happening when Java makes the same request.

I dont know if its related but while giving address of resource jar, i would not use "WEB-ıNF/lib", client machine cannot see inside web-inf, you should put that jar inside web application not inside web-inf.

How about the policy file? See here: http://blogs.oracle.com/monzillo/entry/policy_files_the_securitymanager_and

Related

How to troubleshoot Microsoft Azure WebApp on java? How to access logs?

I have a java-application (standard springboot from default tutorial: https://spring.io/guides/gs/spring-boot-for-azure/ ) that I "successfuly" deploy to my WebApp (created during deployment) via Eclipse/maven plugin azure-webapp:deploy
Once deployed, files are inside the WebApp, I can see them. If start-up is successful I do get running application, but if it is not - I do not know how to troubleshoot. I don't know where to find error logs, what caused the problem and as consequence, how to solve it.
as an example of how to make it fail, add this line:
throw new RuntimeException("Doomed to fail");
I tried enabling logs from "diagnostic logs tab" and expected to see them under LogFiles/Applications but that folder remains empty.
How do I troubleshoot java-application that fails to start in WebApps of Azure?
edit: additional example of Exception to troubleshoot:
public static void main(String[] args) {
throw new RuntimeException("start failure #21");
//SpringApplication.run(Application.class, args);
}
It sounds like you followed the springboot tutorial Deploying a Spring Boot app to Azure to build the GitHub project microsoft/gs-spring-boot and deploy to Azure, but not works.
Here is my steps which I also followed the tutorial, but deployed via my own way.
I created a directory SpringBoot on my local machine, and to do the commands cd SpringBoot and git clone https://github.com/microsoft/gs-spring-boot.
Then, to build it via commands cd gs-spring-boot/complete and mvnw clean package
Note: I reviewed the sections of the tutorial under Create a sample Spring Boot web app which seems to do on Linux, but the web.config file in microsoft/gs-spring-boot/complete is ready to Azure WebApp for Windows. However, there is not any comments to describe the deployment target that be Azure WebApp for Windows or Linux.
So I used my existing WebApp for Windows to test my deployment. I open my Kudu console in browser via the url https://<webapp name>.scm.azurewebsites.net/DebugConsole and drag the files complete/web.config and complete/target/gs-spring-boot-0.1.0.jar to site/wwwroot as the figure below. Then, I started my webapp, and it works fine.
Note: Please check the JAVA_HOME environment variable which has been configured on Azure via command echo %JAVA_HOME% as the figure below.
If not, you need to set Java runtime in the Application settings tab of Azure portal.
Or you can also configure the web.config file to replace the reference %JAVA_HOME% with an existing Java runtime installed in the path D:\Program Files\Java of Azure WebApp, as below.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<!-- <httpPlatform processPath="%JAVA_HOME%\bin\java.exe" -->
<httpPlatform processPath="D:\Program Files\Java\jre1.8.0_181\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.0.jar"">
</httpPlatform>
</system.webServer>
</configuration>
I didn't manage to find logs in windows based machine, but If you enable logs on linux-based-machine you will see them in the "Diagnostic logs" output. There is a catch though.
There is 230 timeout. It will wait full "timeout" time, until producing logs in the log file, after which you can access them via log file or through "Diagnostic logs". Make sure to enable logging before you start application. This applies to linux based machine, I don't know if it can apply to windows based machine.
Then it waits for an answer trigger. Answer trigger, as it turns out, is a phrase in console output "Application is started in X seconds". I increased the timeout to 500 seconds, because although it starts in 60 seconds on my local machine, it takes 430 seconds on remote-linux-based machine of Microsoft Azure*
Second, I changed the name of my main class from "GameStart" to "Application" and after that it actually caught the trigger. After that the application started. Nowhere in manuals did I find the "until timeout - no logs" and "trigger phrase" clauses mentioned.
ps: For reference, it took me 20 to upload application, 5 minutes to start it. I was using centralUS server, cuz centralEU did not work out for me, as it was even longer, although I'm in central EU myself
-
*using test account. It might happen that on payed account number are either different or similar.

Running Solr on Azure Web Apps

I have tried to run it in azure web app, but it doesn't work.
Here is my configuration. Maybe someone know how achieve this.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%HOME%\site\wwwroot\webapps\solr-6.0.0\bin\solr.cmd"
arguments="start -p %HTTP_PLATFORM_PORT%"
startupTimeLimit="20"
startupRetryCount="2"
stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="JAVA_HOME" value="D:\Program Files\Java\jdk1.8.0_73" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Here is the Error Message:
The handle could not be opened
during redirection of handle 0.
The handle could not be opened
during redirection of handle 0.
ERROR: Java 1.8 or later is required to run Solr. Current Java version is:
There are two ways for setting up the Java version on Azure WebApp.
Configuring the web.config file in the Kudu Console via the url https://<your-webapp-name>.scm.azurewebsites.net/DebugConsole as your said. However, please set the JAVA_HOME environment variable with the value D:\Program Files (x86)\Java\jdk1.8.0_73 if your webapp not enable 64-bit for the option PLATFORM of Azure portal, see the figures below.
Fig 1. The Platform option of the tab CONFIGURE on Azure old portal
Fig 2. The PLATFORM option of the Appication settings on Azure new portal
Directly setting up in the Application settings on Azure new portal, please see the figure below and refer to the blog.
Fig 3. The Java version option of the Application settings on Azure new portal
Update
You can try to add the line below at the line 65.
set "JAVA_HOME=D:\Program Files\Java\jdk1.8.0_73"

IllegalArgumentException: Document base \.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps does not exist or is not a readable directory

When I try to run my project on my local Tomcat server, I get the error:
Server Tomcat v7.0 Server at localhost failed to start.
I followed the advice in this Stackoverflow answer and deleted the folder tmp0. but I still get the same error.
I've copied the stack trace below.
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Users\Imray\Projects\InstrurentalApp\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\instrurentalapp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:136)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5089)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Did you notice this line:
java.lang.IllegalArgumentException: Document base C:\Users\Imray\Projects\
InstrurentalApp\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\
wtpwebapps\instrurentalapp does not exist or is not a readable directory
The message is clearly saying that either that directory does not exist, or that the Tomcat server does not have read access to it. And if you deleted it ... that might explain why it doesn't exist!
Actually, the pathname is very suspicious to me. It looks like a path to something in your development sandbox, and a deployed webapp (running in Tomcat) should not depend on such things. (You shouldn't have that kind of stuff on your production server!) That may be the root cause of your problems; i.e. you have neglected to put your resources into your WAR file and update your configuration files accordingly.
Try these 3 methods
1) try deleting the .snap file found in
yourprojectworkspace.metadata.plugins\org.eclipse.core.resources
2) The most common hiccup is when another web server (or any process for that matter) has laid claim to port 8080. This is the default HTTP port that Tomcat attempts to bind to at startup. To change this, open the file:
$CATALINA_HOME/conf/server.xml
and search for '8080'. Change it to a port that isn't in use, and is greater than 1024, as ports less than or equal to 1024 require superuser access to bind under UNIX. (Example 8181)
Restart Tomcat and you're in business. Be sure that you replace the "8080" in the URL you're using to access Tomcat. For example, if you change the port to 8181, you would request the URL http://localhost:8181/ in your browser.
3) Open the bin folder which contains the shutdown.bat file residing inside the tomcat directory. Run it, that should solve the port problem.
Just Change the port no, So you can solve this problem..
Take different port for
1. Tomcat Admin port: 8079
2. Http Port : 99
3. Ajp port : 8078
Check your web.xml file
and make correction in url-pattern and servlet-class or any syntax error, and run project.
Go on the server link (which is synchronized with the servlets) shown into the server console.
Expand the the link.
unsynchronize the synchronized servlets.
Right click on the server link.
Click on publish.
Then start the server again.
Hope it will work. :D
Go to Server tab in Eclipse where you configured Server and right click on server and select clean. after that restart server. It Works

java.net.ConnectException: after adding weblogic-application.xml

I have recently added weblogic-application.xml to my ear to resolve antlr jar file conflict in weblogic 10.x
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<prefer-application-packages>
<package-name>antlr.*</package-name>
</prefer-application-packages>
</weblogic-application>
now when deploying the application I m getting the following exception:
Error while parsing the Tag Library Descriptor at
com.ctc.wstx.exc.WstxIOException: Tried all: '1' addresses, but could not connect over HTTP to server: 'java.sun.com', port: '80'
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:683)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
at weblogic.servlet.internal.TldCacheHelper$TldIOHelper.parseXML(TldCacheHelper.java:134)
at weblogic.descriptor.DescriptorCache.parseXML(DescriptorCache.java:380)
at weblogic.servlet.internal.TldCacheHelper.parseTagLibraries(TldCacheHelper.java:65)
Truncated. see log file for complete stacktrace
java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to server: 'java.sun.com', port: '80'
at weblogic.net.http.HttpClient.openServer(HttpClient.java:312)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:388)
at weblogic.net.http.HttpClient.New(HttpClient.java:238)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:172)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:356)
Truncated. see log file for complete stacktrace
This seems to be a proxy issue. Why this is happening only after adding the weblogic-application.xml?
Any solution that may not require changing the weblogic server config?
Thanks in advance.
It seems if your .xml file has any taglib is failing to download the DTD definition from Internet because of private network. This is thread has discussion on possible work around. Work around link

JNLP java.security.AccessControlException with TargetDataLine.open()?

I have the following line which caused this error message run under JNLP :
java.security.AccessControlException: access denied (javax.sound.sampled.AudioPermission record)
at java.security.AccessControlContext.checkPermission(Unknown Source)
TargetDataLine targetDataLine.open(audioFormat);
How to fix it ? Or does that mean in JNLP, we can't record sound ?
PS : I'm not running it in all-permissions mode, because it requires a 3rd party paid cert. to sign the jar before I can submit my app to Sun's Java Store. I wonder if there's any other way, like using JNLP's FileSaveService / FileOpenService ?
Frank
If you add the following to your JNLP (sibling to </infomration>, does it work?
<security>
<all-permissions/>
</security>
By default, you do not have access outside the applet sandbox, including audio.

Categories

Resources