I'm getting the following error on server.start() call:
ClassNotFoundException: org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContainer
I also could not found a maven dependency for GrizzlyServerContainer.
Any ideas? Here is my code:
private WebSocketModulManager() {
server = new Server("127.0.0.1", 30000, "/lightconsole", null, LightconsoleEndpoint.class);
try {
server.start();
} catch (DeploymentException e) {
e.printStackTrace();
} finally {
server.stop();
}
}
Maven Dependecies
Try this dependency:
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-server</artifactId>
<version>1.13</version>
</dependency>
Related
The bounty expires in 6 days. Answers to this question are eligible for a +100 reputation bounty.
Ihsan Haikal is looking for an answer from a reputable source.
I am trying to list JIRA projects with the Java SDK following https://www.baeldung.com/jira-rest-api (I could not find another example in Google for this) with the following code:
public static void main(String[] args) {
JiraRestClient jiraRestClient = getJiraRestClient(URI.create("uri"),"username","token");
try {
Iterable<BasicProject> projects = jiraRestClient.getProjectClient().getAllProjects().get();
projects.forEach(basicProject -> System.out.println(basicProject.getName()));
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
private static JiraRestClient getJiraRestClient(URI uri, String username, String password) {
return new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(uri, username, password);
}
However, it returns this error:
Exception in thread "main" java.lang.NoClassDefFoundError: io/atlassian/fugue/Suppliers
at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<clinit>(ApacheAsyncHttpClient.java:80)
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.doCreate(DefaultHttpClientFactory.java:61)
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.create(DefaultHttpClientFactory.java:36)
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:68)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:36)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
at JiraPlayground.getJiraRestClient(JiraPlayground.java:30)
at JiraPlayground.main(JiraPlayground.java:13)
Caused by: java.lang.ClassNotFoundException: io.atlassian.fugue.Suppliers
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 8 more
Here are my dependencies:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.atlassian.fugue/fugue -->
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
Any idea how to run the code correctly?
i'm trying run code
public static Connection getConnection() throws SQLException{
try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=convertToNull [root on Default schema]");
} catch (ClassNotFoundException | SQLException e) {
JOptionPane.showMessageDialog(null,e.toString());
}
return cn;
}
but i get the exception:
with the dialog:
I have added the divier :mysql-connector-java-5.1.36-bin.jar in this project.
What am I doing wrong?
Add mysql connector jar to your project classpath.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
I am trying to send GET request from the postman chrome plugin and I am getting this error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver I have already included the mysql-connector-java-5.1.35-bin in my project
jersey endpoint:
#Path("/test")
public class Driver{
#GET
#Produces(MediaType.TEXT_PLAIN)
public void mysqltest(){
Database db = new Database();
db.connection();
}
}
Database class:
public class Database {
public void connection() {
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("jar works :) ");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I have already tested it with this class in the same project and I am getting the output driver works
Driver class:
public class Driver {
public static void main(String[] args){
connection();
}
public static void connection() {
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("driver works :) ");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Why when am I calling it from the jersey method I am getting the error in the title?
You need to add the following dependency in your pom.xml file. (I assume you are working with Maven project)
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
P.S. I was getting the same exception. This worked for me.
Adding to what #LuiggiMendoza wrote, you need to understand the packaging of your artifacts and trace the classloader delegation to understand if the classloader that invokes your Driver class also has access to the MySQL driver JAR. For instance, adding the MySQL JAR to WEB-INF/lib may not help if Jersey is a dependency of an EJB JAR that itself is in the WEB-INF/lib of the webapp.
I want to use the latest release of smack 4.0.0 in my project for xmpp with android studio 0.6.0,the code as below:
try{
ConnectionConfiguration config = new ConnectionConfiguration("wooxonline.com",4000);
XMPPConnection connection = new XMPPTCPConnection(config);
connection.connect();
connection.login("cliff","cliff123");
}
catch (SmackException e) {
e.printStackTrace();
}
catch (java.io.IOException e)
{
e.printStackTrace();
}
catch (XMPPException e) {
e.printStackTrace();
Log.i(TAG, "login failed!");
}
this almost like sample with the smack sample code,but I have a compile issue that can't be solved as below trace info:
Error:(58, 29) error: cannot access SaslException
class file for javax.security.sasl.SaslException not found
I'm stuck here and anyone can help to have a look?
I ran into the same problem. This is the appropriate import sentence:
import org.apache.harmony.javax.security.sasl.SaslException;
According to the official forum "Smack does not work on Android. You need aSmack." So you should try to change the library to ASmack.
You can use maven to get the jar or download it from here
Reference:https://community.igniterealtime.org/thread/52833
when i am retrieving data from column family using Cssandra-JDBC driver. i got error
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Ljava/nio/ByteBuffer;Lorg/apache/cassandra/thrift/Compression;Lorg/apache/cassandra/thrift/ConsistencyLevel;)Lorg/apache/cassandra/thrift/CqlResult;
at org.apache.cassandra.cql.jdbc.CassandraConnection.execute(CassandraConnection.java:447)
at org.apache.cassandra.cql.jdbc.CassandraConnection.execute(CassandraConnection.java:472)
at org.apache.cassandra.cql.jdbc.CassandraStatement.doExecute(CassandraStatement.java:161)
at org.apache.cassandra.cql.jdbc.CassandraStatement.executeQuery(CassandraStatement.java:226)
at CassandraJDBCTest.main(CassandraJDBCTest.java:19)
Code is
public static void main (String args[]) throws SQLException{
try {
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
Connection con = DriverManager.getConnection("jdbc:cassandra://localhost:9160/TestExample");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT Name,Age FROM Users WHERE keyname='001';");
rs.next();
System.out.println(rs.getString("Name"));
System.out.println(rs.getInt(2));
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
You have missing dependencies:
Exception in thread "main" java.lang.NoSuchMethodError
I have a feeling that the classpath is just not configured correctly (why the L's?):
Ljava/nio/ByteBuffer;
Lorg/apache/cassandra/thrift/Compression;
Lorg/apache/cassandra/thrift/ConsistencyLevel;
...
If you want to save yourself of dependency hell try using maven, the Datastax java driver has a maven central repo and you just need to include the dependency:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.2</version>
</dependency>
EDIT
Sorry, didnt realise you are using JDBC. The cassandra jdbc driver has also got a maven repository:
<dependency>
<groupId>org.apache-extras.cassandra-jdbc</groupId>
<artifactId>cassandra-jdbc</artifactId>
<version>1.2.5</version>
</dependency>