Tryint to generate "Cloud Endpoint Client Library" from Google-app-engine project failed in MAC OS X - eclipse

I'm trying to generate "Cloud Endpoint Client Library" from Google App-Engine project using Eclipse plug-in, but it fails with exception: InvocationTargetException - "All API classes with the same API name and version must have the exact same API-wide configuration".
I'm using Eclipse 4.2 with Google App-Engine plug-in 1.8.3 on MAC OS X 10.8.4.
The strange thing is: on PC running Windows with same eclipse and plug-in versions, generating the libraries from the project doesn't raise any exception.

I was having the same problem.
I ended up removing the resource attribute from ALL of the endpoint classes, as it was the only difference.
#Api(name = "shoppingassistant",
// resource = "deviceinfos",
version = "v1", namespace = #ApiNamespace(ownerDomain = ApiKeysAndIds.API_OWNER, ownerName = ApiKeysAndIds.API_OWNER, packagePath = ApiKeysAndIds.API_PACKAGE_PATH), clientIds = {
ApiKeysAndIds.ANDROID_CLIENT_ID, ApiKeysAndIds.IOS_CLIENT_ID, ApiKeysAndIds.WEB_CLIENT_ID }, audiences = { ApiKeysAndIds.AUDIENCE_ID })
The project compiles now, and I was able to generate the client lib.
(I haven't tried the android project yet)

While all properties in the #Api annotation must match for all classes in an API, you can additionally use the #ApiClass annotation to provides properties that do not need to be exactly the same between classes.
For this case:
#Api(name = "shoppingassistant",
version = "v1", namespace = #ApiNamespace(ownerDomain = ApiKeysAndIds.API_OWNER,
ownerName = ApiKeysAndIds.API_OWNER, packagePath = ApiKeysAndIds.API_PACKAGE_PATH),
clientIds = {
ApiKeysAndIds.ANDROID_CLIENT_ID, ApiKeysAndIds.IOS_CLIENT_ID, ApiKeysAndIds.WEB_CLIENT_ID},
audiences = {ApiKeysAndIds.AUDIENCE_ID})
#ApiClass(resource = "deviceinfos")
Read the full tutorial here

Related

Does build pipeline requires internate connection to run

I am using Onprimise AzureDevOps. I am having intranet within the server but no access to internet.
Does the Use Nugget and Nugget installer requires internet to get it success.
If you look here you will find this code:
async function getLatestMatchVersionInfo(versionSpec: string): Promise<INuGetVersionInfo> {
taskLib.debug('Querying versions list');
let versionsUrl = 'https://dist.nuget.org/tools.json';
let proxyRequestOptions = {
proxy: taskLib.getHttpProxyConfiguration(versionsUrl)
};
let rest: restm.RestClient = new restm.RestClient('vsts-tasks/NuGetToolInstaller', undefined, undefined, proxyRequestOptions);
let nugetVersions: INuGetVersionInfo[] = (await rest.get<INuGetVersionInfo[]>(versionsUrl, GetRestClientOptions())).result;
// x.stage is the string representation of the enum, NuGetReleaseStage.Value = number, NuGetReleaseStage[NuGetReleaseStage.Value] = string, NuGetReleaseStage[x.stage] = number
let releasedVersions: INuGetVersionInfo[] = nugetVersions.filter(x => x.stage.toString() !== NuGetReleaseStage[NuGetReleaseStage.EarlyAccessPreview]);
let versionStringsFromDist: string[] = releasedVersions.map(x => x.version);
let version: string = toolLib.evaluateVersions(versionStringsFromDist, versionSpec);
if (!version)
{
taskLib.error(taskLib.loc("Error_NoVersionWasFoundWhichMatches", versionSpec));
taskLib.error(taskLib.loc("Info_AvailableVersions", releasedVersions.map(x => x.version).join("; ")));
throw new Error(taskLib.loc("Error_NuGetToolInstallerFailer", NUGET_TOOL_NAME));
}
return releasedVersions.find(x => x.version === version);
}
And it basically looks for nuget version if it will not find it on local machine. I assume that all this REST calls will not work without internet. So if you do not want to provide access to internet you should use only those versions installed on agents.
Agree with Krzysztof Madej, I think it is feasible to run build pipeline without internet connection. From the description of NuGet tool installer task we can know :
Acquires a specific version of NuGet from the internet or the tools
cache and adds it to the PATH.
So you need to make sure that the nuget version you need is installed on the local machine.
If you don't use upstream packages from the feed in your DevOps server, then your DevOps server machine could just in intranet network.
However, your build agent machine requires internet access, if you to do something that requires to access internet, such as Use Nuget task.

How to use U2.Data.Client for .NET Core Web API?

I am looking to create a connection with Universe DB using .NET Core Web API and run SELECT queries but I am getting an error and have heard that U2.Data.Client cannot be used for .NET Core. Is there any workaround for this?
Below is the code which I am trying to execute but an exception is thrown while initializing U2Connection:
U2Connection con = new U2Connection();
U2ConnectionStringBuilder csb = new U2ConnectionStringBuilder();
csb.AccessMode = "Native";
csb.RpcServiceType = "uvcs";
csb.Database = "HS.SALES";
csb.UserID = "user";
csb.Password = "password";
csb.Server = "localhost";
csb.ServerType = "universe";
con.ConnectionString = csb.ToString();
con.Open();
These are the exceptions which I get when calling the U2Connection constructor:
System.TypeInitializationException: 'The type initializer for 'U2.Data.Client.U2Connection' threw an exception.'
MissingMethodException: Method not found: 'System.Security.Policy.Evidence System.Reflection.Assembly.get_Evidence()'.
There is no .Net core version of Universe database connector yet! If you are using .Net core 2.x you can target .Net Framework as workaround to be able to use a .Net Framework library where you manage you Universe database access by using the available connector from U2 Toolkit for .NET.
Hope this will help you.

Calling Watson on Bluemix from java causes Trust Manager error

Trying out some code to call a Watson Service I provisioned on Bluemix. I get the following error:
Unable to extract the trust manager on
okhttp3.internal.Platform#e19ef72e, sslSocketFactory is class
com.ibm.jsse2.SSLSocketFactoryImpl
Here is my code:
try {
DocumentConversion service = new DocumentConversion("2016-05-25");
service.setUsernameAndPassword("*****", "*****");
File doc = new File("C:/Sample1.pdf");
Answers htmlToAnswers = service.convertDocumentToAnswer(doc).execute();
System.out.println(htmlToAnswers);
} catch(Exception e) {
System.out.println("Error! -> " + e.getMessage());
}
Thoughts? Do I need to import a cert from Bluemix? Thanks.
Looks like it is a known problem in the okhttp library. Are you using Java SDK to use the IBM Watson version 3.0.0-RC1? If so, try with 2.10.0 as it has an older version of the okhttp library which may not suffer from this problem.

Grails rest spring security plugin does not store generated token using GORM in database

I am using the GORM option to store the generated token in database for my Grails 3.x application using grails spring security rest plugin.
The application generates the token but does not get stored in database. Do we need to override the tokenStorage method and have our own implementation to store the token in database
The plugin properties configured in application.groovy are listed below
grails.plugin.springsecurity.rest.token.validation.useBearerToken = false
grails.plugin.springsecurity.rest.login.endpointUrl = '/api/login'
grails.plugin.springsecurity.rest.token.validation.headerName = 'X-Auth-Token'
grails.plugin.springsecurity.rest.token.storage.useJwt = false
grails.plugin.springsecurity.rest.token.storage.useGorm=true
grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName='com.auth.AuthenticationToken'
grails.plugin.springsecurity.rest.token.storage.gorm.tokenValuePropertyName='token'
grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName='username'
grails.plugin.springsecurity.rest.login.passwordPropertyName = 'password'
grails.plugin.springsecurity.rest.login.useJsonCredentials = true
grails.plugin.springsecurity.rest.login.useRequestParamsCredentials = false
grails.plugin.springsecurity.rest.token.rendering.authoritiesPropertyName = 'permissions'
Make sure you have added the following to your build.gradle:
compile 'org.grails.plugins:spring-security-rest:2.0.0.M2'
compile 'org.grails.plugins:spring-security-rest-gorm:2.0.0.M2'
And you have defined the following in application.groovy or application.yml
grails.plugin.springsecurity.rest.token.storage.useGorm=true
grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName = 'com.yourdomain.AuthenticationToken'
grails.plugin.springsecurity.rest.token.storage.gorm.tokenValuePropertyName = 'tokenValue'
grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName = 'username'
There is almost no information to help you. No build configuration, no logs, no idea how the requests are made...
But from the description of your problem, my guess is that you are missing the GORM module in your classpath. It's clearly stated in the documentation.
Be also sure to read the what's new in 2.0 chapter.
I had the same problem, token not stored and no error messages seen.
After installing the GORM plugin:
compile "org.grails.plugins:spring-security-rest-gorm:2.0.0.M2"
I could login and a token was saved into the table.

Eclipse base HTML5 Websocket and GlassFish

Env for project: -
Eclipse 3.6 (Eclipse-jee-helios) + HTML5 + JavaScript + Websocket + (grizzly) Glassfish 3.1.1
I have deployed sample project and able to run using GF.
When i try to connect websocket it always call onClose.
I tried: -
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true
GF 3.1.1 supports web socket (Downloaded from http://glassfish.java.net/downloads/3.1.1-final.html)
Browser like safari and Google Chrome supports websocket (i am using latest browser and checked with http://websocket.org/echo.html URL)
Java Script:-
var webSocket;
$(document).ready(
function() {
**var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";**
//Tried using and lot of combination of URLS
var URL = "ws://localhost:8080/";
var URL = "ws://localhost:8080/SampleGF";
var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";
webSocket = new WebSocket(URL);
//alert("WebSockets are " + (window.WebSocket ? "" : "not ") + "supported");
webSocket.onopen = function(event) {
alert("OPEN")
}
webSocket.onmessage = function(event) {
var $textarea = $('#messages');
$textarea.val($textarea.val() + event.data + "\n");
$textarea.animate({
scrollTop : $textarea.height()
}, 1000);
}
webSocket.onclose = function(event) {
alert("CLOSE")
}
});
function sendMessage() {
var message = $('#username').val() + ":" + $('#message').val();
webSocket.send(message);
$('#message').val('');
}
i have used ChatSocket.java, WebSocketChatServlet.java, ChatApplication.java as it is from below link: -
http://java.dzone.com/articles/creating-websocket-chat
i have added servlet-api.jar in my project library.
Ref. Link: - http://tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/
Web.xml: -
I have added servlet and servlet-mapping as below:
servlet
description WebSocketChatServlet description
servlet-name WebSocketChatServlet servlet-name
servlet-class org.trivadis.websocket.servlet.WebSocketChatServlet servlet-class
servlet
servlet-mapping
servlet-name WebSocketChatServlet servlet-name
url-pattern /WebSocketChatServlet url-pattern
servlet-mapping
I am not sure what i am doing wrong....
How can i check URL i am using is correct or not for websocket.
GF location is D:\glassfish3\glassfish for my project.
Project location D:\workspace\SampleGF
Another reason: -
Even I tried WAR sample from below link: -
http://jarvana.com/jarvana/search?search_type=project&project=grizzly-websockets-chat
WAR File Name: -grizzly-websockets-chat-1.9.45.war
I have imported above war file in Eclipse and deployed it on glassfish 3.1.1 server. After running it application always call onclose event.
I have executed below command: -
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true
and I am using browser like safari and Google Chrome supports websocket (i have tested it with below link http://websocket.org/echo.html URL)
Can anyone help me out…..
It's been months since I tried to run published sample-code against grizzly. I may be out of date, but it didn't work when I tried it. The guy who published the sample eventually admitted problems in the discussion posts below his article. Since I haven't tried it since, I don't know whether it's been fixed yet; i.e. I don't have confirmation that grizzly works yet. (If someone knows of a working sample, I'm as interested as you are.)
In the mean time, you can try this alternative for running your client code. You can even check what you're doing against the free downloadable JavaScript code if you wish.
http://highlevellogic.blogspot.com/2011/09/websocket-server-demonstration_26.html
If you get your code to work against this server, then try again with grizzly. I'll be interested in the results.