Managed VM JDO Datastore - google-cloud-datastore

I am trying to migrate an AppEngine project to MVM, custom runtime environment.
I faced an issue with Memcache, which was solved by replacing:
CacheManager.getInstance().getCacheFactory().createCache ...
...
with:
new XMemcachedClient(
System.getenv.get("MEMCACHE_PORT_11211_TCP_ADDR"),
Integer.parseInt(System.getenv.get("MEMCACHE_PORT_11211_TCP_PORT")))
...
(BTW, if anyone is having same issues, then maven for XMemcached is:)
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>2.0.0</version>
</dependency>
I am now facing an issue with DataStore JDO and PersistenceManager (using DataNucleus in the project).
Basically, I am looking to replace this:
JDOHelper.getPersistenceManagerFactory("xxx").getPersistenceManager() ...
...
with ?...
Are there any "magic" environment variables I can use for composing the address (like the MEMCACHE_PORT_11211_TCP_ADDR and MEMCACHE_PORT_11211_TCP_PORT is the case of Memcache)? Any other means I can communicate the datasource with (from a MVM project)?
Thanks in advance,
Ohad

You may want to consider using the gcloud-java project for accessing datastore. The big advantage here is that you can use the same code/client from App Engine, Container Engine, and Compute Engine:
https://github.com/GoogleCloudPlatform/gcloud-java
Hope this helps!

Related

Spark UI appears with wrong format (broken CSS)

I am using Apache Spark for the first time. I run my application and when I access localhost:4040 I get what is shown in the picture.
I found that maybe setting
spark.ui.enabled true
could help but I don't know how to do that.
Thanks in advance.
I have faced the same issue while using Spark on Google Cloud Dataproc.
If you will access Spark Job UI not through 4040 port directly, but through YARN Web UI (8088 port) you will see correctly rendered web pages.
To workaround this issue when accessing Spark UI directly through 4040 port you need to reset spark.ui.proxyBase property inside your Spark job (not in CLI/job submission command), because it gets overridden by Spark UI proxy:
sys.props.update("spark.ui.proxyBase", "")
Here is detailed description of this issue.
I Had the same problem.
Also the calls to http://localhost:4040/api/v1/applications failed returning with no response.
This happened due to a collision between 2 versions of Jersey in my classpath.
Mainly conflict between 1.x and 2.x.
What worked for me was to exclude in my Maven build the Jersey library that came from other dependencies that are not from Spark.
For example:
<dependency>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-avro</artifactId>
<version>1.9.0</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Excluding version Jersey 1.x (My Spark distro used 2.x) solved the problem.
Edit:
Also -> happened when servlet api 2.5 JAR was in classpath instead or together with 3.x
In case you are using WildFly, see if https://issues.apache.org/jira/browse/SPARK-27795 can help (there you find also (a quite ugly) workaround).
I was also facing the same problem and tried with sys.props.update("spark.ui.proxyBase", ""). Spark UI was fixed but it was still triggering errors in logs for wrong CSS related to javax.
I added below dependency and it fixed all errors:
libraryDependencies += "javax.servlet" % "servlet-api" % "2.5" % "provided"

IdentityServer4.Services.InMemory not working

I google a lot but not find any solution. Below is my problem :
I make a simple project where I use reference "IdentityServer4.Postgresql": "1.0.0"
where "using IdentityServer4.Services.InMemory" works perfectly.
But when I use "IdentityServer4.Postgresql": "2.0.0" then IdentityServer4.Services.InMemory always shows error.
That means version 2 of IdentityServer4.Postgresql not support IdentityServer4.Services.InMemory.
How can I use IdentityServer4.Services.InMemory for "IdentityServer4.Postgresql": "2.0.0"?
Thanks in advance.
IdentityServer4.Postgresql is not a part of the IdentityServer project, but sounds like a community contribution. You may have a better result by contacting the library creator.
Otherwise, you could try the official IdentityServer4.EntityFramework package that is maintained by the IdentityServer team in combination with an Entity Framework Core database provider for PostgreSQL.
The official quickstarts only show adding Entity Framework in the 8th quickstart. You'll have to do each one in succession up to the eighth one to fully understand / make sure to have the code you need.
After you have Entity Framework added to the configuration, you can support a Postgres database by just adding dependencies.

Using Express.js modules in Sails.js

Sails.js does not yet have official Sqlite adapter. There are some attempts, but having read the comments, they are buggy and not reliable.
Since Sails.js uses Express.js, and Express has decent sqlite modules, I was thinking how to use it in Sails?
Any idea is appreciated.
I managed to do it. Very easy. First Install the sql3lite package
Lets Assume I have UserController. At the start of the controller, use this:
sqlite3 = require('sqlite3').verbose(),
db = new sqlite3.Database('myDbName');
db object has all that is needed. You can check the link for detailed CRUD reference :)

SOAPUI: how to refer to external jars?

Commonly known, that for usage of different jars we need add them to SoapUI/../ext/ directory. for example, for correct work of jdbc requests with IBM/..AS400JDBC Driver we need to add jt400.jar to /ext dir.
But I have problem: my client implements new policy - direct forbidding of using any jars locally, only as dependencies like
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400-full</artifactId>
<version>6.0</version>
</dependency>
I successfully uses it in my POM's for CI, but I also need to run my projects in SOAPUI.
So, question is: is there any way to add dependency for external jars, - exists in SoapUI preferences somewhere/somehow? Goal is to remove all jars from soapui/../ext and somehow add dependencies on official.
Sincerely,
Dmitry.
I have thought about this some more: You should be able to roll your own soapui.bat, based on the provided one.
Copy the provided soapui.bat to your desktop.
Modify the variable SOAPUI_HOME to point to your install.
Modify the variable CLASSPATH to include your jars.
Run the modified soapui.bat.

How to secure RESTful interface in JBoss AS 7

After successfully migrating my RESTful application to JBoss AS7, I would like to re-enable authentication (I used BASIC auth over SSL). It seems that this is now possible without writing XML configuration, just by using annotations.
Unfortunately, I cannot find which maven dependency I need to use to import the #WebService and #SecurityContext annotations.
Or is this completely going the wrong way? Is there a working example somewhere?
Thanks for your help!
#javax.jws.WebService is part of JDK
you might also need:
org.jboss.ws.api.annotation.WebContext;
that has option to configure authMethod #WebContext(authMethod=AuthMethod.BASIC) and is part of
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

Resources