I am getting the below error while my code is trying to access a 3rd party endpoint
This request is sent via Service Stub generated code
We are using Axis2 version 1.7.7
Caused by: java.lang.IllegalStateException: Connection is not open
at org.apache.commons.httpclient.HttpConnection.assertOpen(HttpConnection.java:1277)
at org.apache.commons.httpclient.HttpConnection.getResponseInputStream(HttpConnection.java:858)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.getResponseInputStream(MultiThreadedHttpConnectionManager.java:1297)
What could be the reason for this and how can we solve this.
Below is the code for reference
public com.test.Token validateToken(com.test.Token actionToken)throws java.rmi.RemoteException
{
org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
try{
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName());
_operationClient.getOptions().setAction("http://serviceURL/action");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&");
org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
actionToken,
optimizeContent(new javax.xml.namespace.QName("http://serviceURL", "action")),
new javax.xml.namespace.QName("http://serviceURL", "action"));
_serviceClient.addHeadersToEnvelope(env);
_messageContext.setEnvelope(env);
_operationClient.addMessageContext(_messageContext);
_operationClient.execute(true);
org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
java.lang.Object object = fromOM(
_returnEnv.getBody().getFirstElement() ,
com.test.Token.class);
return (com.test.Token)object;
}
Related
I wrote a robot under the server
And I want to run with a proxy
But I miss the following error
mybot is:
public class StoreBot extends TelegramLongPollingBot {
public StoreBot( DefaultBotOptions botOptions) {
super(botOptions);
}
public int creatorId() {
return 0;
}
public StoreBot() {
}
....
}
mycode for run bot is:
ApiContextInitializer.init();
// Create the TelegramBotsApi object to register your bots
TelegramBotsApi botsApi = new TelegramBotsApi();
// Set up Http proxy
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);
botOptions.setProxyHost("2.181.254.198");
botOptions.setProxyPort(8580);
// Select proxy type: [HTTP|SOCKS4|SOCKS5] (default: NO_PROXY)
botOptions.setProxyType(DefaultBotOptions.ProxyType.SOCKS5);
// Register your newly created AbilityBot
StoreBot bot = new StoreBot(botOptions);
botsApi.registerBot(bot);
when run get this error:
org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Error removing old webhook
...
Caused by: org.telegram.telegrambots.meta.exceptions.TelegramApiException: Unable to execute deleteWebhook method
...
Caused by: java.net.SocketException: Connection timed out: connect
RequestConfig requestConfig = RequestConfig.custom()
.setProxy(new HttpHost(host, port))
.build();
DefaultBotOptions botOptions = new DefaultBotOptions();
botOptions.setRequestConfig(requestConfig);
StoreBot bot = new StoreBot(botOptions);
I am trying to configure and read data from existing Oracle tables
However, I get error message while calling cache.loadCache(); this line.
It shows error message as
Message as
session:javax.cache.integration.CacheWriterException: Failed to start store
session [tx=null]Caused by: java.sql.SQLException: No suitable driver found
for jdbc:oracle:thin:#192.168.2.218:1521:xe at
org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:190) at
org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:351) at
org.h2.jdbcx.JdbcDataSource.getPooledConnection(JdbcDataSource.java:383) at
org.h2.jdbcx.JdbcConnectionPool.getConnectionNow(JdbcConnectionPool.java:226)
at
org.h2.jdbcx.JdbcConnectionPool.getConnection(JdbcConnectionPool.java:198)
at
CacheConfiguration<String, TempClass> cacheCfg = new CacheConfiguration<String, TempClass>();
cacheCfg.setName("Test_CacheConfig");
IgniteConfiguration igniteConfig = new IgniteConfiguration();
Factory<TempClassCacheStore> factory = FactoryBuilder.factoryOf(TempClassCacheStore.class);
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setIndexedTypes(String.class, TempClass.class);
cacheCfg.setCacheStoreFactory(factory);
cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
#Override
public CacheStoreSessionListener create() {
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:oracle:thin:#192.168.2.218:1521:xe", "test", "test"));
return lsnr;
}
});
Ignite ignite = Ignition.start(igniteConfig);
IgniteCache<String, TempClass> cache = ignite.getOrCreateCache(cacheCfg);
cache.loadCache(null);
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT ID_, NAME_ FROM TEST_TABLE");
QueryCursor<List<?>> cursor = cache.query(sql);
I have configured CacheStore for TempClass also as shown in
https://apacheignite.readme.io/docs/persistent-store#cachestore
Any help will be highly appreciated
As you're trying to load data from oracle to Ignite, you need to have Oracle JDBC Driver in classpath. Just put the driver JAR into IGNITE_HOME/libs folder prior to starting the nodes and run loading again.
I am a bit new here but I need some help with my code. Here it is:
SVNRepositoryFactoryImpl.setup();
SVNURL url =
SVNURL.
parseURIEncoded("svn+ssh://xxx");
File keyFile =
new File("C://Users/xxxx/Documents/priave_key/private_key.ppk");
System.out.println("PPK file space:"+keyFile.getTotalSpace());
SVNSSHAuthentication sshCredentials =
new SVNSSHAuthentication(Settings.name, keyFile, Settings.pass, 22, false, url, false);
System.out.println(sshCredentials.getPrivateKey()==null);
System.out.println("hasPrivateKey(): "+sshCredentials.hasPrivateKey());
SVNUserNameAuthentication authorNameCredentials = new SVNUserNameAuthentication(Settings.name, false);
SVNPasswordAuthentication passwordCredentials = new SVNPasswordAuthentication(Settings.name, Settings.pass, false);
ISVNAuthenticationManager authManager =
new BasicAuthenticationManager(new SVNAuthentication[] {
sshCredentials,
authorNameCredentials,
passwordCredentials});
SVNRepository repository = SVNRepositoryFactory.create(url);
repository.setAuthenticationManager(authManager);
try {
SVNDirEntry info = repository.info("", -1);
System.out.println(info);
} finally {
repository.closeSession();
}
So after running this I get this output:
PPK file space:107374178304
false
hasPrivateKey(): true
Exception in thread "main" org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication required for 'xxx#svn+ssh://xxx'
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.jav a:47)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.jav a:41)
at
org.tmatesoft.svn.core.auth.BasicAuthenticationManager.getNextAuthentication(BasicAuthentic ationManager.java:223)
at org.tmatesoft.svn.core.internal.io.svn.SVNSSHConnector.open(SVNSSHConnector.java:141)
at org.tmatesoft.svn.core.internal.io.svn.SVNConnection.open(SVNConnection.java:77)
at org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl.openConnection(SVNRepositoryImpl.j ava:1252)
at org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl.info(SVNRepositoryImpl.java:1195)
at SVNTestNew.main(SVNTestNew.java:40)
I think this can be a problem with SVNSSHAuthentication class because it gives null for getPrivateKey() and true for hasPrivateKey(.) Or is this a wrong idea? Can anyone tell me how can this problem be solved?
According to me your public and private keys are not at proper place.
If you are using Linux machine then,
For private key you have default path :-
${USER_HOME}/.ssh/abc.rsa or abc.dsa
And you have to Store your public key at server in :
Default Path :-
${USER_HOME}/.ssh/authorized_keys
You can change your Path in /etc/sshd_config file
I'm trying to access MicroSoft Dynamic CRM 2011 online webservices from Java but no luck so far.
I got Organization WSDL file and generated required java stub files with the help of Axis2 (wsdl2Java).
And my simple client code is
public class TestCRM2 {
public static void main(String[] args) {
try {
// create query
QueryExpression query = new QueryExpression();
query.setEntityName("Contact");
ArrayOfstring colAra = new ArrayOfstring();
colAra.addString("fullname");
ColumnSet columnSet = new ColumnSet();
columnSet.setAllColumns(false);
columnSet.setColumns(colAra);
PagingInfo pageinfo = new PagingInfo();
pageinfo.setCount(10);
pageinfo.setPageNumber(1);
query.setColumnSet(columnSet);
query.setPageInfo(pageinfo);
ConditionExpression condition = new ConditionExpression();
condition.setAttributeName("fullname");
condition.setOperator(ConditionOperator.Equal);
ArrayOfanyType values = new ArrayOfanyType();
values.setAnyType(new String[] {"something"});
condition.setValues(values);
RetrieveMultiple retrieveMultiple = new RetrieveMultiple();
retrieveMultiple.setQuery(query);
OrganizationServiceStub stub = new OrganizationServiceStub();
//set Timeout
ServiceClient serviceClient = stub._getServiceClient();
serviceClient.getOptions().setTimeOutInMilliSeconds( 3 * 60 * 1000);
/*serviceClient.getOptions().setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_10);
serviceClient.getOptions().setProperty(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED,false);*/
RetrieveMultipleResponse response = stub.retrieveMultiple(retrieveMultiple);
EntityCollection collection = response.getRetrieveMultipleResult();
int count = collection.getTotalRecordCount();
System.out.println(count);
} catch (Exception e) {
e.printStackTrace();
}
}}
When i run this from Eclipse, i get the following runtime error
org.apache.axis2.AxisFault: Connection reset
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.microsoft.schemas.xrm._2011.contracts.OrganizationServiceStub.retrieveMultiple(OrganizationServiceStub.java:1177) at test.TestCRM.main(TestCRM.java:105)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
... 9 more
Is there any thing I'm missing in my client code. Your help is highly appreciated.
Regards,
You have to append "/web" at the end of your endpoint url in service client.
You will have to provide NTLM2 authenticator implementation and register it with httpclient used by your stub.
I have a class that is having some dependency problems referencing external library files. Every time I try to run this on the server I get errors saying class not found, such as this:
SEVERE: Class [ org/json/JSONException ] not found. Error while loading [ class com.myproj.logic.Driver ]
this is preventing the class from executing. I tried taking out the specific throws execption by just saying "throws exception" and got the following error:
WARNING: A system exception occurred during an invocation on EJB Driver method public void com..logic.Driver.initURL() throws java.lang.Exception
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton Driver
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils
#Singleton
public class Driver {
#EJB RSSbean rssbean;
#PostConstruct
#Schedule(hour ="*/1", minute ="*/1", second ="*/1", persistent = false)
public void initURL() throws IOException, JSONException{
URL twitterSource = new URL("http://search.twitter.com/search.json?q=news");
ByteArrayOutputStream urlOutputStream = new ByteArrayOutputStream();
IOUtils.copy(twitterSource.openStream(), urlOutputStream);
String urlContents = urlOutputStream.toString();
JSONObject thisobject = new JSONObject(urlContents);
JSONArray names = thisobject.names();
JSONArray asArray = thisobject.toJSONArray(names);
JSONArray resultsArray = thisobject.getJSONArray("results");
JSONObject jsonObject = resultsArray.getJSONObject(0);
String twitterText = jsonObject.getString("text");
//System.out.println(twitterText);
System.out.println("Calling rssbean from Driver");
rssbean.updateDatabase("twitterText");
}
}
I have edited the Java classpath and added a user library for each of these as well as editing the Build Path of the project. The libraries are displayed in the list and I don't get compiler errors so at least Eclipse has recognized them. The problem comes during execution so I think something is wrong there.
Should I edit the classpath in Windows>Preferences>Java>Classpath> and add the Jars there? I have not had to do this for any other libraries before.
I found out you have to add any library files in the Glassfish/domain/lib directory before they're recognized by glassfish on the server.