I am trying to get the archived messages using below code as described in this document
try {
MamManager mamManager = MamManager.getInstanceFor(connection);
boolean isSupported = mamManager.isSupportedByServer();
if (isSupported) {
MamManager.MamQueryResult mamQueryResult = mamManager.queryArchive(500);
List<Forwarded> forwardedMessages = mamQueryResult.forwardedMessages;
Forwarded d = forwardedMessages.get(0);
}
} catch (Exception e) {
e.printStackTrace();
}
But it's throwing org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: feature-not-implemented - cancel exception on executing queryArchive() function. Does anyone have any idea how to resolve this issue? Any help would be appreciated.
This issue is resolved now after updating openfire server to latest version (4.1.5)
Related
I want to implement config cat in my java 8 project.
The way I am creating a config cat client is this:
import com.configcat.ConfigCatClient;
public class ConfigCatClientUtil {
public ConfigCatClientUtil() {
}
public ConfigCatClient createClient(String configCatKey) {
ConfigCatClient configCatClient = null;
try {
configCatClient = new ConfigCatClient(configCatKey);
} catch (Exception e) {
}
return configCatClient;
}
}
The problem is that when try to execute this new ConfigCatClient(configCatKey) throws an error:
messages Feb 11 13:11:38 server: Caused by: java.lang.NoClassDefFoundError: okhttp3/Callback
I am using configcat-java-client-6.0.1.jar.
Does anyone know why I am getting this error?
This library has a direct dependency on OkHttp
https://mvnrepository.com/artifact/com.configcat/configcat-java-client/6.0.1
If you are following their documentation you wouldn't see this, so I suggest starting with their instructions for setting up your maven or Gradle build.
https://configcat.com/docs/sdk-reference/java/
I'm trying to use UART serial communication with MicroEj in STM32F7 using java, and I've got exception throw opening the Com Port. Here is the simple code to open a connection:
private static final String CONNECTION_STRING = "comm:com42;baudrate=9600;bitsperchar=8;stopbits=1;parity=none";
try {
CommConnection comm = (CommConnection) Connector.open(CONNECTION_STRING);
} catch (IOException e1) {
e1.printStackTrace();
}
And here is the exception:
java.io.IOException: ECOM-COMM: Invalid connection descriptor.
I think there might be some problems with the CONNECTION_STRING but I couldn't find any examples. anyone can help me?
Try with com51.
You can find the correct value in launch parameters/Configuration tab/Libraries/ECOM/Comm Connection
java with Amazon AWS NoSuchFieldError
Here is the console log:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:246)
at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:225)
at org.apache.http.client.utils.URIBuilder.parseQuery(URIBuilder.java:95)
at org.apache.http.client.utils.URIBuilder.digestURI(URIBuilder.java:165)
at org.apache.http.client.utils.URIBuilder.<init>(URIBuilder.java:90)
at org.apache.http.client.utils.URIUtils.rewriteURI(URIUtils.java:138)
at org.apache.http.impl.client.DefaultRequestDirector.rewriteRequestURI(DefaultRequestDirector.java:353)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:476)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:837)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3826)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3778)
at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:610)
at net.pocketsurvey.cloud.Amazon.listObjectsInBucket(Amazon.java:93)
The bottom line is where my code hands over to Amazon's S3. The code is as follows:
public static ObjectListing listObjectsInBucket(String bucketName,
String key) throws Exception {
ObjectListing list = null;
AmazonS3Client client = Client.s3(Client.DESKTOP);
try {
boolean b_exists = client.doesBucketExist(bucketName);
boolean o_exists = client.doesObjectExist(bucketName, key);
if(b_exists) {
list = client.listObjects(bucketName, key);
}
} catch ( AmazonServiceException e){
String err = e.getErrorMessage();
e.printStackTrace();
} catch ( AmazonClientException e){
e.printStackTrace();
} catch ( Exception e){
e.printStackTrace();
}
return list;
}
'client.listObjects' is where it bombs out.
libraries used include:
aws-java-sdk-1.10.77.jar
httpclient-osgi-4.3.jar
org.apache.httpcomponents.httpcore_4.2.1.jar
'b_exists' is true but 'o_exists' returns as false even tho the key most definitely exists.
I am using credentials that work for other things such as email, and downloading a known object, i.e. a complete key string. But trying to get a listing using a partial key string (such as "hhs/") I get the above eror.
Also the 'catches' don't catch it.
The code currently runs on the UI thread but I have tried it on its own thread with similar results.
The platform is Windows 7.
Any help would be greatly appreciated.
Problem sorted - library mismatch.
'aws-java-sdk-1.10.77.jar' needs 'org.apache.httpcomponents.httpcore_4.4.4.jar' to bein the build path.
I have a cron-job running at a Linux machine running after every 5 minutes. The job executes a Java class.
private MongoClient createConnection(int retry,List<ServerAddress> host){
try {
System.out.println("Retrying----------"+retry);
MongoClient client = new MongoClient(host, MongoClientOptions.builder()
.connectionsPerHost(10)
.threadsAllowedToBlockForConnectionMultiplier(5)
.connectTimeout(5000).writeConcern(WriteConcern.NORMAL).build());
client.getDB("admin").command("ping").throwOnError();
retry = 0;
return client;
} catch (Exception e) {
retry++;
if (retry < retryLimit) {
createConnection(retry,host);
} else {
System.out.println("Connection could not be established to host-"+host);
}
return null;
}
}
retry is the integer value denoting how many times client creation can be tried in case host is unreachable.
The host list that i am passing is -
public static List<ServerAddress> HOST_SCRIPT = new ArrayList<ServerAddress>() {
private static final long serialVersionUID = 1L;
{
try {
add(new ServerAddress("PrimaryHost23", 27017));
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
};
Code is Stuck when i MongoClient is being created. It does not happen always. Code works fine and NEVER hangs when i run on my local machine. There is no exception thrown.
I recently upgraded Linux machine OS (from CentOS 5 to CentOS 6). Can this be responsible for this because this script was working fine earlier.
Please help.
Regards,
Vibhav
The thing what you can do is you can throw mongo exception try out that of mongo client is stuck you will get to know try out this https://api.mongodb.org/java/2.6/com/mongodb/MongoException.html
Yes of course, actually i was creating crawler in java which fetch all the links of any particular website and validate the css and html structure Using the Jsoup and jcabi api but when i used to store links to the database it was not throwing any exception and even not storing the data also. so i did this
catch (MongoException e){
System.err.print(e.getClass().getName()+": "+e.getMessage());
}
Have you checked the compatibility like of jar that you have uploaded for your project like before it was like Mongo mongo = new Mongo(host,port); but That is deprecated. Try to check that and even your MongoDb jar.
I've recently made the switch from elasticsearch 1.7 to 2.0 and I noticed the way you setup the client has changed. I went through the documentation and for some reason the client is always null. I was wondering if I have set it up correctly.
Here is my code:
Client client = null;
try {
client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
} catch (Exception e) {
Logger.log(e);
} finally {
client.close();
try {
conn.close();
} catch (SQLException e) {
Logger.log(e);
}
}
As noted in the comments, but a little bit more in detail: Elasticsearch 2.0 uses Guava 18.0 (see https://github.com/elastic/elasticsearch/pull/7593). So to fix errors like java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concu‌rrent/Executor;, make sure to use Guava 18.0 as dependency and not other versions.