Unable to create Appuim driver session despite having latest chrome driver and slf4j dependencies - maven

I have the latest chrome driver installed, which fixed the issue for others that have encountered the same error. I am new to using Appium.
here is the error:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Host info: host: 'MallSoft.local', ip: '2601:1c2:0:3680:0:0:0:8406%en0'
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_301'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[{appium:app=/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk, appium:automationName=uiAutomator2, appium:deviceName=nexus_5, platformName=ANDROID, appium:udid=emulator-5554}], desiredCapabilities=Capabilities {app: /Users/fieldemployee/IdeaPr..., automationName: uiAutomator2, deviceName: nexus_5, platformName: ANDROID, udid: emulator-5554}}]
Capabilities {app: /Users/fieldemployee/IdeaPr..., automationName: uiAutomator2, deviceName: nexus_5, platformName: ANDROID, udid: emulator-5554}
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:194)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:117)
at CreateDriverSession.main(CreateDriverSession.java:25)
Process finished with exit code 1
here is my code in IntelliJ:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class CreateDriverSession {
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "nexus_5");
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiAutomator2");
caps.setCapability(MobileCapabilityType.UDID, "emulator-5554");
//for windows users
String appUrl = "/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk";
//System.getProperty("user.dir") + File.separator + "src" + File.separator + "main"
//+ File.separator + "resources" + File.separator + "ApiDemos-debug.apk";
caps.setCapability(MobileCapabilityType.APP, appUrl);
URL url = new URL("http://0.0.0.0:4723/");
AppiumDriver driver = new AndroidDriver(url, caps);
}
}
here is the result in the Appium GUI:
[HTTP] No route found for /wd/hud/session
[HTTP] <-- POST /wd/hud/session 404 8 ms - 211
[HTTP]
[HTTP] Request idempotency key: e718b60f-1d53-4e4b-8ebb-ddaf41d23b43
[HTTP] --> POST /session
[HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:app":"/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk","appium:automationName":"uiAutomator2","appium:deviceName":"nexus_5","appium:udid":"emulator-5554","platformName":"android"}}}
As stated, I have the latest chrome driver and browser installed (latest as of the date on this post). My initial error was related to slf4j but adding the dependencies to pom resolved it. I have tried changing the url and removing the "/wd/hud/" as well.

Possibly you need to add /wd/hub at the end.
Solution
Instead of:
URL url = new URL("http://0.0.0.0:4723/");
you need to use:
URL url = new URL("http://localhost:4723/");
or
URL url = new URL("http:///127.0.0.1:4723/");
References
You can find a relevant detailed discussion in:
SessionNotCreatedException: Could not start a new session. Unable to parse remote response error using SeleniumGrid

Related

Appium 2 version is no invoking via appium automation but old version is invoking

I have installed appium 2 version. If i start appium server via CLI command , i can see latest appium version . But when i start via APPIum+gradle+Selenium automation code, I'm getting wrong old version.
[Appium] Welcome to Appium v2.0.0-beta.53 [Appium] Non-default server
args: [Appium] { [Appium] address: '127.0.0.1' [Appium] } [Appium]
Appium REST http interface listener started on 127.0.0.1:4723
I'm using appium automation and code is like below
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
public final class AppiumServerController {
private static final Logger LOG =
LoggerFactory.getLogger(AppiumServerController.class); private
static final AppiumDriverLocalService service =
buildService(
new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingAnyFreePort()
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "debug"));
static {
LOG.info("Print Default Data" + DataHelper.getEnvironment());
LOG.info(
"Print Default Data"
+ APPIUM_HOST
+ " "
+ APPIUM_LOG_LEVEL
+ " "
+ GeneralServerFlag.LOG_LEVEL
+ " "
+ IMPLICIT_WAIT_TIME); }
public static void startAppiumServer() {
// To start appium server
try {
service.start();
LOG.info("Appium server started successfully");
} catch (Exception e) {
e.printStackTrace();
} }
Sometime it's generating correct version but sometimes it's giving wrong version. Is there any way to specify the version in app in automation in Java?
[Appium] Welcome to Appium v1.22.3
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] port: 29548
[Appium] sessionOverride: true
[Appium] Appium REST http interface listener started on 127.0.0.1:29548

How can i make local http request in flutter?

when i make access on website on endpoint "http://localhost/newsapp_api/public/api/authors"it's work without any problem,but when i try this in flutter it shows me a problem.
message error:E/flutter (24506): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 46873
codes:
authors_api.dart
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:news_app/utilities/api_utilities.dart';
import 'package:news_app/models/author.dart';
class AuthorsAPI {
Future<List<Author>> fetchAllAuthors() async {
// ignore: deprecated_member_use
List<Author> authors = List<Author>();
String allAuthorsApi = base_api + all_authors_api;
var url = Uri.parse(allAuthorsApi);
var response = await http.get(url);
print(response.statusCode);
print("*****************");
print(response.body);
}
}
api_utilities.dart
String base_api = "http://localhost/newsapp_api/public/api/authors";
String all_authors_api = "/api/authors";
make sure that you are not using any VPN or proxy server
try to use http://127.0.0.1 instead of http://localhost
hope this solve your problem
Note that localhost does not work with the Android emulator which uses 10.0.0.2
To support both Web and Android emulator use the (local) IP address of the server
You can make the server running on localhost avalible on your device like this:
adb reverse tcp:3000 tcp:3000
Please note that you should replace 3000 with the port that you srever is running on.
And that's it! Now you can access localhost from your device.

WebDriver wait command is failing for Safari on Mac OS

I have script to login to a site and then waiting for home button to get loaded. I have put fluentwait to wait for element to be visible. But WebDriver is not waiting and failing immediately as the home button is not loaded.
I have tried with fluentwait and webdriverwait but none of them are working.
Here is code I am trying.
By usernameInput = By.name("User”);
By passwordInput = By.name("Password”);
By loginButton = By.xpath("//input[#value='Sign In']”);
String URL = “https://demotest.mytest.com/"
WebDriver driver = new SafariDriver();
driver.get(URL);
driver.manage().window().maximize();
setText(usernameInput,”User1");
setText(passwordInput,”User1");
clickOnElement(loginButton);
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#title='Home']")));
Throws below error -
org.openqa.selenium.WebDriverException:
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'cnparmar-mac', ip: '10.168.104.60', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_211'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 12.1.1, javascriptEnabled: true, platform: MAC, platformName: MAC, safari:automaticInspection: false, safari:automaticProfiling: false, safari:diagnose: false, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}}
Session ID: 1257BF8B-335E-4E80-8B08-CB15A77AD648
*** Element info: {Using=xpath, value=//div[#title='Home']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo rAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo nstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException( W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExec utor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(Drive rCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.jav a:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWe bDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:315)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
at sample.Sample.loginAs(Sample.java:64)
at sample.Sample.test1(Sample.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j ava:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess orImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocati onHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorke r.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Ideally it should wait for Home button to get visible. but it is failing. This works on Chrome,Firefox, IE, Edge on Windows but only failing on Safari on MAC.
It looks like you are mixing up WebDriverWait and FluentWait classes.
Try using the following instead:
WebDriverWait wait = new WebDriverWait(driver, 15, 100);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#title='Home']")));

geb.Browser is trying to use FirefoxDriver instead of PhatomJSDriver

For some reason, my code tries to use the firefox browser when it should be using phantomjs.
My groovy code looks like this:
import geb.Browser
...
env = System.getenv()
def username = env.username
def password = env.password
def gateway = env.gateway
def matcher = gateway =~ /^(https?:\/\/)([^:^\/]*)(:\d*)?(.*)?.*$/
def host = matcher[0][2]
def port = matcher[0][3]
if (env.driver == 'firefox') {
driver = new FirefoxDriver()
} else {
println env.phantomjspath
def caps = DesiredCapabilities.phantomjs()
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, env.phantomjspath
)
driver = new PhantomJSDriver(caps)
driver.manage().window().setSize(new Dimension(1028, 768))
}
def browser = new Browser(driver: driver)
BiHome = "https://" + username + ":" + password + "#" + host + port + "/gateway/default/BigInsightsWeb/#/welcome"
browser.drive {
go BiHome
// code omitted for brevity
}
browser.close()
Unfortunately, for some reason geb.Browser is trying to use the FirefoxDriver:
:CheckHomePhantomJS
/Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: /Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 19084
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=19084, --webdriver-logfile=/Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/phantomjsdriver.log]
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2016-05-10T09:13:58.925Z] GhostDriver - Main - running on port 19084
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.customHeaders: - {}
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2016-05-10T09:13:59.117Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 8784a390-168f-11e6-bcd7-a7a5f8e205b1
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: MAC
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'xxxxxxx', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: 'xxxxx', java.version: '1.8.0_66'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
....
My build.gradle:
import org.apache.tools.ant.taskdefs.condition.Os
// set the dependencies for running the groovy script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.codehaus.groovy:groovy-all:latest.release'
}
}
plugins {
id 'groovy'
}
apply from: "osSpecificDownloads.gradle"
// set the dependencies for compiling the groovy script
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:latest.release'
compile 'org.codehaus.geb:geb-core:latest.release'
compile 'org.seleniumhq.selenium:selenium-firefox-driver:2.53.0'
compile('com.codeborne:phantomjsdriver:1.3.0') {
transitive = false
}
}
// tell gradle the groovy script is in the same folder as the build.gradle file
sourceSets {
main {
groovy {
srcDirs = ['.']
}
}
}
Properties props = new Properties()
props.load(new FileInputStream("$projectDir/../../connection.properties"))
task("CheckHomePhantomJS", type: JavaExec) {
dependsOn unzipPhantomJs
def phantomJsFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "phantomjs.exe" : "bin/phantomjs"
environment 'phantomjspath', new File(unzipPhantomJs.outputs.files.singleFile, phantomJsFilename).absolutePath
environment 'driver', 'phantomjs'
environment 'gateway', props.gateway
environment 'username', props.username
environment 'password', props.password
main = 'CheckHome'
classpath = sourceSets.main.runtimeClasspath
}
Any idea what is going wrong here?
Geb creates a new Browser instance when you call.
Browser drive(Closure script)
Instead try with
Browser drive(Browser browser, Closure script)
So change your code to
Browser.drive(browser) {
go BiHome
// code omitted for brevity
}

Building a JMX client in a servlet installed on the Deployment Manager

I'm building a monitoring application as a servlet running on my websphere 7 ND deployment manager. The tool uses JMX to query the deployment manager for various data. Global Security is enabled on the dmgr.
I'm having problems getting this to work however. My first attempt was to use the websphere client code:
String sslProps = "file:" + base +"/properties/ssl.client.props";
System.setProperty("com.ibm.SSL.ConfigURL", sslProps);
String soapProps = "file:" + base +"/properties/soap.client.props";
System.setProperty("com.ibm.SOAP.ConfigURL", pp);
Properties connectProps = new Properties();
connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_HOST, dmgrHost);
connectProps.setProperty(AdminClient.CONNECTOR_PORT, soapPort);
connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
AdminClient adminClient = AdminClientFactory.createAdminClient(connectProps) ;
This results in the following exception:
Caused by: com.ibm.websphere.management.exception.ConnectorNotAvailableException: ADMC0016E: The system cannot create a SOAP connector to connect to host ssunlab10.apaceng.net at port 13903.
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.getUrl(SOAPConnectorClient.java:1306)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.access$300(SOAPConnectorClient.java:128)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPConnectorClient.java:370)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SOAPConnectorClient.java:363)
... 22 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:209)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.getUrl(SOAPConnectorClient.java:1286)
... 26 more
So, I then tried to do it via RMI, but adding in the sas.client.properties to the environment, and setting the connectort type in the code to CONNECTOR_TYPE_RMI. Now though I got a NameNotFoundException out of CORBA:
Caused by: javax.naming.NameNotFoundException: Context: , name: JMXConnector: First component in name JMXConnector not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
To see if it was an IBM issue, I tried using the standard JMX connector as well with the same result (substitute AdminClient for JMXConnector in the above error)
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/JMXConnector");
Hashtable h = new Hashtable();
String providerUrl = "corbaloc:iiop:" + dmgrHost + ":" + rmiPort + "/WsnAdminNameService";
h.put(Context.PROVIDER_URL, providerUrl);
// Specify the user ID and password for the server if security is enabled on server.
String[] credentials = new String[] { "***", "***" };
h.put("jmx.remote.credentials", credentials);
// Establish the JMX connection.
JMXConnector jmxc = JMXConnectorFactory.connect(url, h);
// Get the MBean server connection instance.
mbsc = jmxc.getMBeanServerConnection();
At this point, in desperation I wrote a wsadmin sccript to run both the RMI and SOAP methods. To my amazement, this works fine. So my question is, why does the code not work in a servlet installed on the dmgr ?
regards,
Trevor
For the SOAP error, the ConnectException looks like the wrong SOAP host/port was used for the dmgr. I would double-check the server logs for the SOAP port. For the RMI error (NameNotFoundException), it looks like you're trying to use JMXConnectorFactory, which isn't supported by WAS.
If your application is installed on the dmgr, it's probably easiest to just use AdminServiceFactory.getAdminService to get an in-process reference to the AdminService rather than trying to open a new connection to the same process:
http://publib.boulder.ibm.com/infocenter/wasinfo/fep/topic/com.ibm.websphere.javadoc.doc/web/apidocs/com/ibm/websphere/management/AdminServiceFactory.html

Resources