How to run the rmiregistry and rmi server with the right parameters? - java

How to run the rmiregistry and RMI server with the right parameters on the remote host?
Got this problem when running the RMI client:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.net.MalformedURLException: unknown protocol: c
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.labros.client.TestClient.main(TestClient.java:33)
Caused by: java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
I started the rmiregistry on the remote host with the following:
rmiregistry -J-Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/cla‌​sses -J-Djava.security.policy=/export/home/timsadm/Projects/rmi-server/classes/java.p‌​olicy &
and the server with
java -Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/class‌​es -Djava.security.policy=/export/home/timsadm/Projects/rmi-server/classes/java.pol‌​icy com.labros.server.Server
Server started

java -Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/class‌​es
and
java.net.MalformedURLException: unknown protocol: c
These are mutually contradictory. I suspect your codebase parameter really looks like this:
-Djava.rmi.server.codebase=c:/export/home/timsadm/Projects/rmi-server/class‌​es
which isn't a valid URL.
But why are you using the codebase feature at all? A file: codebase URL only works within a single host, in which case you don't need the codebase feature at all, or if it specifies a shared filesystem from the point of view of the Registry and the client, which this one doesn't appear to do. Normally codebase URLs are http: or ftp:, and they refer to a JAR file.

Related

java rmi call failure across different jvm versions

I have existing rmi server running with jvm 1.5 and client running in jvm 1.6 communicating with no issues.
However, when i run (server under JVM 1.7/ client jvm1.7) OR (server under JVM 1.7/ client jvm 1.6)getting following error -
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.tmobile.kiosk.simulator.Kiosk.<init>(Unknown Source)
at com.tmobile.kiosk.simulator.Kiosk.main(Unknown Source)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(Unknown Source)
With (Server jvm 1.5/ client jvm 1.7) getting following error -
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: com.xxx.yyy.zzzserver.ZZZServerFactoryImpl_Stub (no security manager: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
Is this happening due to RMI changes across Java versions?
Can i run rmi Server in JVM 1.7 without any code changes so that existing clients (jvm 1.5 etc) can connect to it.
We are not rebuilding the jar file which was built probably using java 1.4 or 1.5.
Thanks in Advance
Problem was some old jar versions being part of classpath.

gradle build fails for unknown host exception

I just installed a new version of Android Studio and am trying to create a project using the built in templates.
My environment is:
Windows 7, SP1, 64 bit
In a secure domain environment and I am a domain administrator on my machine.
Here is what I am seeing:
C:\Users\stuz\AndroidStudioProjects\test>gradlew compileDebug --stacktrace
Downloading file://C:/Users/stuz/.gradle/wrapper/dists/gradle-1.10-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.UnknownHostExcep
tion: C
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.UnknownHostException: C
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.ftp.impl.FtpClient.doConnect(Unknown Source)
at sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source)
at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Sour
ce)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
The problem is in your gradle/wrapper/gradle_wrapper.properties file. I'm not sure how it happened, but you have an improper URL in there for the downloadable distribution of Gradle. Change that line from this:
distributionUrl=file://C:/Users/stuz/.gradle/wrapper/dists/gradle-1.10-all.zip
to this:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
This solution worked for me...
Find the file gradlew.bat on your project directory, in that file change DEFAULT_JVM_OPTS variable as below:
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=YOUR_HOST -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USERNAME -Dhttp.proxyPassword=PASSWORD -Dhttps.proxyHost=YOUR_HOST -Dhttps.proxyPort=PORT -Dhttps.proxyUser=USERNAME -Dhttps.proxyPassword=PASSWORD
then run gradlew clean build.
Check if you are on secure network - if that is the case than in your gradle/wrapper/gradle_wrapper.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
this line have https in it which is refused by secure network.
I changed to unsecure network and it started working for me.
under you project folder go to : platforms/android/cordova/lib/builders/GradleBuilder.js
find distributionUrl and Remove https with http and replace "services" with "downloads".
distributionUrl=http\://downloads.gradle.org/distributions/gradle-2.4-all.zip
you need to use the windows style file URI to make it valid
Windows Reference for File URI
distributionUrl=file\:///C\:/Users/<your_path_separated_by_/_chars>/gradle-2.4-all.zip
After changing the distribution url to http://services.gradle.org/distributions/gradle-1.10-all.zip .
If you still get unknown host exception for services.gradle.org, try setting the HTTP / HTTPS proxy to your environmental variables . See the below post
https://stackoverflow.com/a/59045565/4468693

Runtime error on the exact same code on a different computer

I am working with a relativly unknown API. (ScrumWorks Pro) I am using it to export data into a SQL database. My issue is that I have moved my eclipse project from one computer to another and it stopped working. It continues to run fine on the old computer but I am getting the following error
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://XXXXXXX:8080/scrumworks-api/api2/scrumworks?wsdl. It failed with:
Got Server returned HTTP response code: 503 for URL: http://XXXXXXXXXX:8080/scrumworks-api/api2/scrumworks?wsdl while opening stream from http://dxzbid01.zhi.com:8080/scrumworks-api/api2/scrumworks?wsdl.
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
at javax.xml.ws.Service.create(Unknown Source)
at com.danube.scrumworks.api2.ScrumWorksService.getConnection(ScrumWorksService.java:53)
at main.connectAPI(main.java:69)
at main.main(main.java:12)
Caused by: java.io.IOException: Got Server returned HTTP response code: 503 for URL: http://XXXXXXXXX:8080/scrumworks-api/api2/scrumworks?wsdl while opening stream from http://XXXXXXXXXXXXX.com:8080/scrumworks-api/api2/scrumworks?wsdl
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(Unknown Source)
... 11 more
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://XXXXXXXXXXX:8080/scrumworks-api/api2/scrumworks?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
... 13 more
It looks like while it's running its failing to connect to the host. But it works completely fine with the exact same credentials on the other computer.
The magic words: Server returned HTTP response code: 503. The answer will be in your server logs.
From https://www.rfc-editor.org/rfc/rfc2616#section-10.5.4:
The server is currently unable to handle the request due to a
temporary overloading or maintenance of the server.
make sure that url
http://XXXXXXXXXX:8080/scrumworks-api/api2/scrumworks?wsdl
is accessible, if not able to access the 8080 port, check your firewall settings in that machine (allow that 8080 port to accessible)
The problem was that the newer computer had a newer version of Java installed which broke parts of the API.

JAVA RMI Client

I have the problem that my RMI Application Client isn't working when i hit the "run" Button in Eclipse. It throws the following exception:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.net.MalformedURLException: unknown protocol: rsrc
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
...
I looked on the internet and people seem to have that problem when generating JARs from eclipse. But my (ant-built) jars work fine, just inside Eclipse it's not doing as it should!
InterfaceRemota objetoRemoto = (InterfaceRemota)Naming.lookup("//localhost:1097/ObjetoRemoto");
I found a solution, before starting the rmiregistry server I have to clean the java classpath using "set CLASSPATH="
c: > set CLASSPATH=
c: > rmiregistry

Getting javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException. Not able to connect to application on HTTPS?

hi i am using tomcat 6 as webserver. i have two webbapplication installed on tomcat on same port. Say App1 and App2. App1 connects to
App2 . Then App2 again connects to App1 using jessionid(so url which app2 is sending is http://localhost/App1;jessionid=sessionidOfAp11)
It works perfectly fine as long as i am on http. But as soon as i move to https App2 is not able to connects to App1 with same url.
Another interesting fact is if i type same url on Brower , it connects to App1. I am not getting what is the mystery going here?
Edit :- here is the exact error i get
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
... 53 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
Answer
Guys thanks for answer. Alon with ramesh answer i also had to do the stuff suggested at http://www.coderanch.com/t/134384/Security/Getting-error-No-subject-alternative.
Because App1 is connecting to App2 using https. The certificate of App2 should be there in the trust store of VM where the App1 runs.
Refer here to see how to add certificate to the keystore.
You can set the truststore using these system properties
-Djavax.net.ssl.trustStore="C:/test/truststore"
-Djavax.net.ssl.trustStorePassword="test".
Moreover you dont have to communicate over https when client and server are there on
Same VM
Same Machine
Private Network
Seems like you need to remove native tomcat library from {tomcat_home}/bin folder (tcnative-1.dll under windows, maybe tcnative-1.so under *nix). Tomcat uses APR if native library is in classpath. Read more about configuring SSL here

Categories