I'm trying to create an administrative client program for websphere,
but when I'm trying to connect I get the following message.
Maybe I lack some libs (I create my app in notepad).
at TryConnection1.main(TryConnection1.java:37) Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.security.auth.WSL oginFailedException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
My code:
import java.util.Properties;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.*;
import com.ibm.websphere.management.*;
import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.exception.*;
import com.ibm.websphere.management.exception.ConnectorException;
public class TryConnection1 {
/** * #param args */
public static void main(String[] args) {
Properties connectProps = new Properties();
connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_HOST, "hostgoeshere");
connectProps.setProperty(AdminClient.CONNECTOR_PORT, "portgoeshere");
connectProps.setProperty(AdminClient.USERNAME, "usernamegoeshere");
connectProps.setProperty(AdminClient.PASSWORD, "passgoeshere");
AdminClient adminClient = null;
try {
adminClient = AdminClientFactory.createAdminClient(connectProps);
} catch(ConnectorException e) {
System.out.println("Exception creating admin client: " + e); }
}
}
try to add $WEBSPHERE_HOME/AppServer/runtimes/com.ibm.ws.admin.client_8.5.0.jar, or similar if you're using a different WebSphere version, to your classpath. This is the required jar for WebSphere Admin Client.
You should try to add:
import com.ibm.websphere.security.auth.*;
Related
My friends and I have minecraft server and we want to add JavaMail plugin with Maven , We added 2 jar files:
Mail.jar
Activation.jar
With this code:
package com.parlagames;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class App {
public void AppVoid(String host, String port,final String userName,final String password, String[] toAddress, String subject, String message) {
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port",port);
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
});
try {
Message SendMessage = new MimeMessage(session);
SendMessage.setFrom(new InternetAddress(userName));
for(int i=0;i<toAddress.length;i++) {
SendMessage.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(toAddress[i]));
SendMessage.setSubject(subject);
SendMessage.setContent(message, "text/html; charset=utf-8");
Transport.send(SendMessage);
}
System.out.println("Sent");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
When we start the plugin in his server it shows an error that it doesn't identify the class
java.lang.NoClassDefFoundError: com/parlagames/App
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_161]
at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_161]
at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_161]
at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_161]
at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.8.0_161]
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_161]
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_161]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_161]
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_161]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.11.2.jar:git-Spigot-3fb9445-6e3cec8]
Why does it happend? we need to have the maven by the way
It seems that you need to add this line of code to the plugin:
public void onEnable()
and this code
public void onDisable()
It also seems that you don't have a main class. A main class is declared at plugin.yml. Try finding the part that says "main:" and change it to the class that has the "onEnable()" and "onDisable()". Also add extends JavaPlugin as someone said before
Is App the main class of your plugin ? If so, it you need to make it extend the JavaPlugin class like this :
public class MyPlugin extends JavaPlugin {
public void onEnable() {
}
public void onDisable() {
}
}
If you have trouble understanding of the bukkit/spigot API, I would suggest to start learning from the docs (here is a reference guide for the basics).
trying to run simple test selenium Web Driver program which is mentioned below:
package com.abc;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Mock_Exam {
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/");
}
}
after running as java application getting the below error :
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonSyntaxException
at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:95)
at org.openqa.selenium.firefox.Preferences.<init>(Preferences.java:65)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:87)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:77)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:66)
at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:262)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at com.kesdee.ia.Mock_Exam.main(Mock_Exam.java:14)
Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonSyntaxException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
FireFox version: 36.0.1
Selenium: selenium-java-2.45.0
You miss the gson-<version>.jar: in your classpath. Download add add it.
Let me tell you, I'm completely new by using GhostDriver
I successfully download PhantomJSand i've set my path into environment variable, now i'm trying to run this simple program:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class PhantomJSTest {
private WebDriver driver;
private static final By ABOUT_TAB = By.linkText("About");
private static final By ROADMAP_LINK = By.xpath("//a[text() = 'Roadmap']");
private static final By HELP_LINK = By.xpath("//a[text() = 'Help']");
#BeforeClass
private void initialize() {
driver = new PhantomJSDriver();
driver.navigate().to("http://www.seleniumhq.org/");
}
#Test
public void verifySomething() {
driver.findElement(ABOUT_TAB).click();
assertThat(driver.findElement(ROADMAP_LINK).isDisplayed(), is(true));
assertThat(driver.findElements(HELP_LINK).isEmpty(), is(true));
}
#AfterClass
private void quit() {
driver.quit();
}
}
I tried to run it, But it's saying:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:178)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
at smsRobot.MyProgram.main(MyProgram.java:24)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.browserlaunchers.Proxies
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
Please help :(
HELP WOULD BE APPRECIATED!!
UPDATED
After downloading selenium-common.jar, I'm getting this error:
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http://phantomjs.org/download.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:237)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:182)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
at smsRobot.MyProgram.main(MyProgram.java:24)
You need to set the path to your phantomDriver executable like so:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // enabled by default
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"path/to/your/phantomjs.exe"
);
driver = new PhantomJSDriver(caps);
driver.navigate().to("http://www.seleniumhq.org/");
I'm creating a Java RMI program, but I'm getting a ClassNotFoundException.
Could you guys help me figure it out? I'm using Eclipse.
Somebody suggested me it was a codebase problem, but how does this relate?
Here are the codes for my Server and Client:
Server:
package server;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import base.Server;
import base.RmiStarter;
public class ServerImplStarter extends RmiStarter{
public ServerImplStarter() {
super(Server.class);
}
#Override
public void doCustomRmiHandling() {
try{
Server engine = new ServerImpl();
Server engineStub = (Server)UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.createRegistry( 1099 );
registry = LocateRegistry.getRegistry();
registry.rebind("Server", engineStub);
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args){
new ServerImplStarter();
}
}
Client:
package client;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import base.RmiStarter;
import base.Server;
import base.Cell;
public class CellClient extends RmiStarter {
public CellClient() {
super(Server.class);
}
#Override
public void doCustomRmiHandling() {
try{
Registry registry = LocateRegistry.getRegistry();
Server server = (Server)registry.lookup("Server");
Cell c = null;
c = server.getcell();
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new CellClient();
}
}
and the error is this:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: server.CellImpl
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getcell(Unknown Source)
at client.CellClient.doCustomRmiHandling(CellClient.java:23)
at base.RmiStarter.<init>(RmiStarter.java:19)
at client.CellClient.<init>(CellClient.java:13)
at client.CellClient.main(CellClient.java:31)
Caused by: java.lang.ClassNotFoundException: server.CellImpl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
... 8 more
Both client and server should have same package name. I had the same error yesterday, i corrected it after lots of searching. Try it and tell me if any other error comes.
Mark this as answer, if you find so.Thank You !!
CellImpl has not been exported or made available via the client's CLASSPATH. It needs to either (a) extend UnicastRemoteObject or be exported via UnicastRemoteObject.exportObject(); or (b) be Serializable and available on the client's CLASSPATH.
Solution for NoClassFound Exception when running RMI Client.
Case:
The server and client files are in different folders.
Example:
Server side: The server interface and server implementation are inside
Project Folder: C:\RMIServer
Package: rmiserver
Client side: The server interface and the client are inside
Project Folder: C:\RMIClient
Package: rmiClient
Problem: Could not find the location of the server interface.
Solution: In the client side,
1. Create a package name rmiServer (the package name should be the same as the server side package).
2. Place the server stub inside this package.
3. The client.java is inside the rmiClient package. Now import the rmiServer package in the client.java file.
import rmiServer.*;
This will solve the classNotFound Exception that happens when we execute the client side RMI.
Today I started coding a project that uses sqlite and when I tried to test it I received the java.lang.ClassFormatError: Invalid pc in LineNumberTable. Hope you can help me with it, because I'm just lost. I'v searched about this error, and came across some weird solutions to some weird causes. As I understand, none of them was causing my problem.
I'm using "sqlitejdbc-v056" wich is inserted in my classpath.
Edit: My JDK version is 1.7.0_03-b05
StackTrace:
Exception in thread "main" java.lang.ClassFormatError: Invalid pc in LineNumberTable in class file Controllers/FuncionariosController
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at Main.main(Main.java:13)
Code giving the error:
public class Main {
public static void main(String[] args) {
DatabaseController db=new DatabaseController();
FuncionariosController f=new FuncionariosController(db);
...
}
}
Class FuncionarioController:
package Controllers;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import Models.Funcionario;
public class FuncionariosController {
private DatabaseController db;
public FuncionariosController(DatabaseController db){
this.db=db;
}
public void render(String cargo){
...
}
public List<Funcionario> selectAll(){
...
}
public Funcionario select(String login){
...
}
}
Thanks in advance,
I had a simmilar problem.
It occured that it was caused by switch that haven't got cases code.
While the error occured it looked somtheing like this:
switch(e.getActionCommand()) {
case ACTION_OPEN_PID:
break;
case ACTION_OPEN_PPID:
break;
default:
}
After adding simple console output to the cases the error was gone.
switch(e.getActionCommand()) {
case ACTION_OPEN_PID:
System.out.println(ACTION_OPEN_PID);
break;
case ACTION_OPEN_PPID:
System.out.println(ACTION_OPEN_PPID);
break;
default:
}
Thanks to Luiggi Mendoza I solved it by using JDK 1.6 instead of 1.7. That did the trick, but I had to comment out a lot of code to compile it. Not that good a solution....