Corda Whitelist not getting updated - corda

I am using Springboot RPC webserver to run my apis. I have put java.util.Date in Whitelist still throwing error.
Class java.util.Date is not annotated or on the whitelist, so cannot be used in serialization
I created a class
import net.corda.core.serialization.SerializationWhitelist
class RequiredSerializationWhitelist : SerializationWhitelist {
override val whitelist: List<Class<*>> = listOf(java.util.Date::class.java)
}
and put the file net.corda.core.serialization.SerializationWhitelist in \src\main\resources\META-INF\services with following code
com.p2p.RequiredSerializationWhitelist
While deploying Nodes I get
No existing whitelist file found.
Calculating whitelist for current installed CorDapps..
CorDapp whitelist generated in <path>\build\nodes\whitelist.txt
Updating whitelist
Bootstrapping complete!
When I open my Whitelist file in the path given only my Contracts are shown. What am I missing.

I think there are not the same whitelist.
\build\nodes\whitelist.txt is file for Corda contract whitelist class. But your problem is net.corda.core.serialization.SerializationWhitelist that should be in JAR file under META-INF/services. Can you check that in your JAR file and this path it's contain SerializationWhitelist file?

Related

Find out if you are running in a command and the command parameters in Symfony

We have a service that can be called from a Symfony command and from a normal web request. Is there a way to find out if the service was called from a command or from a web request? If so, if it was called from a command, is there a way to find out the parameters that were used when running the command?
In symfony Console,
the command line context does not know about your VirtualHost or domain name
It means that you can check the request scheme, host, base_url and base path since these request properties have no values in the console context unless you configure them (https://symfony.com/doc/current/console/request_context.html#configuring-the-request-context-globally)
Hi you can use this to know if the service is used from the cli, if it runs with apache you will get this apache2handler
if(php_sapi_name() === 'cli') {
//some code
}
https://www.php.net/manual/en/function.php-sapi-name.php

Java application with Apache Livy

I decided to build a web service(app) for Apache Spark with Apache Livy.
Livy server is up and running on localhost port 8998 according to Livy configuration defaults.
My test program is a sample application in Apache Livy documentation: https://livy.incubator.apache.org/docs/latest/programmatic-api.html
While creating LivyClient by LivyClientBuilder class,
client = new LivyClientBuilder().setURI(new
URI("http","user:info","localhost",8998,"","",""))
.build();
I got "URI is not supported by any registered client factories" exception:
Exception in thread "main" java.lang.IllegalArgumentException: URI 'http://%5Bredacted%5D#localhost:8998?#' is not supported by any registered client factories.
at org.apache.livy.LivyClientBuilder.build(LivyClientBuilder.java:155)
at Client.<init>(Client.java:17)
at Client.main(Client.java:25)
I found out client instance stays null in LivyClientBuilder class.
client = factory.createClient(uri, this.config);
factory is an instance of LivyClientFactory interface.
The only class which implements the interface is RSCClientFactory.
In RSCClientFactory we have this piece of code:
if (!"rsc".equals(uri.getScheme())) {
return null;
}
I've tried "rsc" instead of "http", this is the error:
2018-09-15 11:32:55 ERROR RSCClient:340 - RPC error.
java.util.concurrent.ExecutionException: javax.security.sasl.SaslException: Client closed before SASL negotiation finished.
javax.security.sasl.SaslException: Client closed before SASL negotiation finished.
at io.netty.util.concurrent.AbstractFuture.get(AbstractFuture.java:41)
at org.apache.livy.rsc.rpc.Rpc$SaslClientHandler.dispose(Rpc.java:419)
at org.apache.livy.rsc.JobHandleImpl.get(JobHandleImpl.java:60)
at org.apache.livy.rsc.rpc.SaslHandler.channelInactive(SaslHandler.java:92)
at Client.main(Client.java:39)
Apache Livy is running on http://localhost:8998 then I think we need submit our jar file to this address, but I don't understand "rsc" there.
I would appreciate if anyone guides me about these problems.
You just need to pass your URL as a String:
LivyClient client = new LivyClientBuilder()
.setURI(new URI("http://localhost:8998"))
.build();
After that you can add your *.jar file with:
client.addJar("file://...yourPathToJarHere.../*.jar");
or
client.uploadJar(new File("...."));
It depends on your cluster configuration. You can find full java API description here: https://livy.incubator.apache.org/docs/latest/api/java/index.html
The only class which implements the interface is RSCClientFactory.
Just add livy-client-http to your classpath.
https://github.com/apache/incubator-livy/blob/412ccc8fcf96854fedbe76af8e5a6fec2c542d25/client-http/src/main/java/org/apache/livy/client/http/HttpClientFactory.java#L29
https://github.com/apache/incubator-livy/blob/56c76bc2d4563593edce062a563603fe63e5a431/examples/src/main/java/org/apache/livy/examples/PiApp.java#L79
Docs: https://livy.incubator.apache.org/docs/latest/programmatic-api.html

Elasticsearch serivce not found

I'm trying to integrate elasticsearch into my symfony application. But I couldn't find any appropriate example on the internet. Now I'm getting this service not found error:
Service "fos_elastica.finder.inscriptions.inscription" not found: even though it exists in the app's container, the container inside "App\Controller\SearchController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "SearchController::getSubscribedServices()".
For:
$finder = $this->container->get('fos_elastica.finder.inscriptions.inscription');
As:
Symfony\Component\DependencyInjection\Exception\
ServiceNotFoundException
I don't know how to solve this problem because of insufficient experience with Symfony. Does anyone know how to solve this or any Elasticsearch example with Symfony on the internet?
Thanks!
In your config/services.yaml file you have to bind this service as argument for your controller like that:
App\Controller\SearchController:
bind:
$finder: '#fos_elastica.finder.inscriptions.inscription'
Then you can use it in your controller by injecting it through autowiring:
public function index($finder) {
// your code here
}
For more information refer to the documentation.

JDG on OpenShift Online - HotRodClientException despite proper permissions assigned to roles

I deployed JDG on OpenShift Online with the following
- Image stream "jboss-datagrid71-openshift-rhel7.json" v1.2
- username 'admin' with role 'admin' and '___schema_manager'
- And given the permissions of READ, WRITE, EXEC, ADMIN, ALL for both the roles. Tried with just 'ALL' also.
- Refer images, Config-env-vars.png and Cache-env-vars.png within the Info.zip for the environment configurations done. (Available # https://drive.google.com/file/d/12EWF1AUB4d60mP_gmTkN4Qlh2pzzv6xi/view?usp=sharing)
While deploying client-side Java application (basically Hotrod with security enabled and with Protobuf based query feature), we are getting the following exception. Attached the logs from the DataGrid server and client application pods
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException: java.lang.SecurityException: ISPN000287: Unauthorized access: subject 'Subject with principal(s): [SimpleUserPrincipal [name=admin], InetAddressPrincipal [address=10.131.14.124/10.131.14.124], admin#ApplicationRealm, admin#ApplicationRealm, ___schema_manager#ApplicationRealm, admin, ___schema_manager]' lacks 'WRITE' permission
FYI,
I use the following version of Infinispan from redhat repository
<version.org.infinispan>8.4.2.Final-redhat-1</version.org.infinispan>
In Java, while creating a Configuration Builder, I did in this way. Full code is available # https://github.com/techtantric/JDG-Remote-Hotrod-Secured
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer()
.host(host)
.port(hotrodPort).security().authentication().serverName("jdg-server").saslMechanism("DIGEST-MD5").callbackHandler(new LoginHandler("admin", "password".toCharArray(), "ApplicationRealm")).enable()
.marshaller(new ProtoStreamMarshaller()); // The Protobuf based marshaller is required for query capabilities
cacheManager = new RemoteCacheManager(builder.build());
Please help us resolving this issue. Thanks in advance.
You should not be touching the ___schema_manager role.

Alfresco CMIS Web Scripts API for 'getContent' by path is not working

I have a file in my Alfresco (4.1.5) repository of which I want to read the content through the Alfresco services REST API.
For the lookup, I want to use the file path, not the UUID. However, the lookup by path does not work, only the lookup by UUID works. I cannot find the mistake.
This is the file path:
DisplayPath & File Name:
/Company Home/Data Dictionary/Cleaner Configs/cleaner.properties
QNamePath:
/app:company_home/app:dictionary/cm:Cleaner_x0020_Configs/cm:cleaner.properties
Lookup by UUID works with the following REST API url:
http://localhost:8080/alfresco/service/cmis/i/2391adf9-365c-4959-bf30-8f001154c100/content
However, lookup by path only does not work. Neither with the primary path nor the display path:
http://localhost:8080/alfresco/service/cmis/p/app:company_home/app:dictionary/cm:Cleaner_x0020_Configs/cm:cleaner.properties/content?a=false
http://localhost:8080/alfresco/service/cmis/p/Company%20Home/Data%20Dictionary/Cleaner%20Configs/cleaner.properties/content?a=false
I am getting a 404 error in both cases:
Message: 10080001 Unable to find ObjectPathReference[storeRef=workspace://SpacesStore,path=/app:company_home/app:company_home/app:dictionary/cm:Cleaner_x0020_Configs/cm:cleaner.properties]
Exception: org.springframework.extensions.webscripts.WebScriptException - 10080001 Unable to find ObjectPathReference[storeRef=workspace://SpacesStore,path=/app:company_home/app:company_home/app:dictionary/cm:Cleaner_x0020_Configs/cm:cleaner.properties]
Reference:
http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Get_Content_.28getContent.29
Gets the content stream for the specified document, or gets a
rendition stream for a specified rendition of a document.
GET /alfresco/service/cmis/p{path}/content{property}?a={attach?}
I found the problem, thanks to #Gagravarr for the hint:
I have to use the display path, but leave out /Company%20Home/ in the path, because the path used in the request url is taken as relative to the /Company%20Home node.
This works:
http://<host:port>/alfresco/service/cmis/p/Data%20Dictionary/Cleaner%20Configs/cleaner.properties/content?a=false

Resources