At the beginning I had an error java.lang.ClassNotFoundException. I solved this problem by adding jars to \war\WEB-INF\lib folder. But then I got java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.Orient error while applying to database. This is the server code:
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String greetServer(String input) throws IllegalArgumentException {
RegBugs rb = new RegBugs();
String a = rb.getDbAdres();
try {
//The error is here
ArrayList<String> table = rb.getAllGitRecords();
} catch (ParseException e) {
e.printStackTrace();
}
return a;
}
Compilation is finished successfully. And when I start to call to server I get An error occurred while attempting to contact the server. Please check your network connection and try again. from gwt. How could I solve this problem?
P.S. I use eclipse and gwt-plugin for it
The error occurs when I try to interrupt with orient database.
Trace:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.Orient
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.open(ODatabaseRaw.java:108)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:53)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:127)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:53)
at ru.sersem.testgwt.server.RegBugs.getBugRecordsCount(RegBugs.java:192)
at ru.sersem.testgwt.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more
Related
I have created a maven project and writing tests in it using testng. I have also created an executable jar using maven but getting error when executing the jar in command prompt with the arguments that are used in project. I could not actually figure out the error. Please help me with this.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/testng/TestNG
at mypackage.App.main(App.java:40)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
command prompt error image in this link
My project Main class codes(App.java)
public class App {
public static String testdataExcel;
public static Properties props = null;
public static Properties loadPropertyFile(String filepath) throws IOException {
FileInputStream stream = new FileInputStream(filepath);
props = new Properties();
props.load(stream);
return props;
}
public static void main(String[] args) throws IOException, InterruptedException {
//Receiving arguments from command prompt
String Filename = args[0];
testdataExcel = args[1];
loadPropertyFile(Filename);
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { LoginPage.class, testclass2.class,
testclass3.class, testclass4.class,
testclass5.class, testclass6.class });
testng.run();
}
}
I have tried to reinstall java, testng as well and then i ran the project but i am getting same error. i could not figure out actual error so far. so kindly help me to find the error and complete this task.
Thanks in advance :)
I'm using a Spring Boot APP and I'm trying to set a System property programatically. I don't want to set the URL hardcoded, it must be loaded from the classpath
The problem is that my code runs well on IDE but when I try to execute the jar file I get:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Unknown Source)
My Code:
public static void main(String[] args) {
try {
setSystemProperties();
} catch (IOException e) {
log.error("ERROR: Could not find my.properties file in classpath", e);
}
}
private static void setSystemProperties() throws IOException {
ClassPathResource resource = new ClassPathResource("my.properties");
System.setProperty("my.file", Paths.get(resource.getURI()).toString());
}
InvocationTargetException occurs when there's some underlying exception while calling method. Add the below catch block in your code to see the actual cause.
catch (InvocationTargetException e) {
// the real cause
e.getCause().printStackTrace();
}
I'm trying to connect to an external database and no matter what I do I keep getting the following error:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
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 java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DbCon.main(DbCon.java:10)
My code to set up the driver:
import java.sql.*;
public class DbCon {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
}
}
I've tried omitting the driver entirely, and just trying to connect with:
String connectionUrl = "jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=xxxx;user=xxxx;password=xxxx;";
try {
Connection con = DriverManager.getConnection(connectionUrl);
} catch (SQLException e) {
e.printStackTrace();
}
This only gets me the following error:
java.sql.SQLException: No suitable driver found for xxxx
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DbCon.main(DbCon.java:15)
I've tried adding the jar to Eclipse's classpath, I've added the folder to the project's build path as an external class folder.
Is there something I'm missing?
I'm wanting to read an iCalendar (ics file) for a project and thinking it might be easier to just use an API. After much research I found iCal4j.
I'm new to ical4j, and have been searching for an answer, and trying to do research and found that the creator of it allows any form of logging they want, so I'm really baffled. I'm trying to get just a simple example I found working. I'm horrible with different APIs, and it kills me. I just have the iCal4j-2.0-beta1.jar in my classpath, and I have the following code:
import java.io.*;
import net.fortuna.ical4j.data.*;
import net.fortuna.ical4j.model.*;
public class iCalendarSupport
{
public static void main(String[] args)
{
try
{
FileInputStream fin = new FileInputStream("C:\\Users\\Mike\\Downloads\\basic (1).ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(fin);
System.out.println(calendar.getComponent("Event").toString());
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Here's the output I have in the console in eclipse.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at net.fortuna.ical4j.util.Configurator.<clinit>(Configurator.java:51)
at net.fortuna.ical4j.data.CalendarParserFactory.<clinit>(CalendarParserFactory.java:63)
at net.fortuna.ical4j.data.CalendarBuilder.<init>(CalendarBuilder.java:104)
at iCalendarSupport.main(iCalendarSupport.java:12)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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
Any help would be much appreciated.
Classpath is missing the SLF4J (Simple Logging Facade) library. You can find it here:
http://www.slf4j.org/download.html
I'm new to GWT. I'm trying to connect my Oracle10g database to GWT server program,
I'm using this code:
public class Database_connect
{
public static void connect()
{
System.out.println("This is a test project");
Connection con=null;
try
{
Class.forName("oracle.jdbc.OracleDriver");
System.out.println("Oracle JDBC driver loaded ok.");
con=DriverManager.getConnection("jdbc:oracle:thin:#127.0.0.1:1521:XE","naren", "naren");
System.out.println("Connected with #localhost:1521:XE.");
System.out.println("We have done it successfully");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
in server file i'm calling the connect() function
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService
{
public String greetServer(String input) throws IllegalArgumentException
{
Database_connect.connect();
}
}
but it's showing error.
I don't know what to do now. Anyone help me. Thanks for advance.
the error is
[WARN] failed Server#6e058516
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:205)
at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:304)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.Server.doStart(Server.java:233)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:836)
at com.google.gwt.dev.DevMode.main(DevMode.java:311)
[ERROR] shell failed in doStartupServer method
You are running the project 2 times i think ..please kill all the java processes in task manager and run the project only once ..