Liferay 7 add salesforce jar library error - salesforce

I am going to integrate salesforce library into liferay 7 mvc portlet, the following steps are what i did:
Add libraries to class path. In Eclipse, go to Project > Properties > Java Build Path > Libraries > Add External JARs, then add the sfdc-wsc JAR to this list
Add below line to build.gradle:
compile group: 'com.force.api', name: 'force-wsc', version: '40.1.1'
The java source code is ok until i use gradle build to build project, the following error occur:
error: package com.sforce.soap.enterprise does not exist import com.sforce.soap.enterprise.EnterpriseConnection;
error: package com.sforce.soap.enterprise does not exist import com.sforce.soap.enterprise.QueryResult;
error: package com.sforce.soap.enterprise does not exist import com.sforce.soap.enterprise.SaveResult;
I also set the bnd file as follow according to blog post of DAVID H NEBINGER: https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies
But nothing is improved
Bundle-ClassPath:.,\lib/externalLib.jar
-includeresource:\
lib/externalLib.jar=externalLib.jar,\
lib/commons-lang.jar=commons-lang=[0-9]*.jar
Please give any suggestion to correct.
Thanks in advance

I recently developed such a solution, but I used a different approach. I've implemented an OSGi bundle that exports Salesforce's SOAP APIs. This way you can use Salesforce APIs in any other Liferay bundle.
On this Salesforce SOAP API Client OSGi Bundle repository you find the sources. The OSGi bundle is also available on Maven Central.
Once you install the Salesforce SOAP API Client OSGi bundle, you can use it in any other Liferay bundle, such as your MVC Portlet. This sample project Salesforce Liferay Gogo Shell Command Client implements a set of Gogo Shell commands that allow us to interact with the Salesforce CRM system.
In your particular case, if you want to include external libraries via Gradle, then you can declare your dependency through the key compileInclude.
dependencies {
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileOnly group: "org.apache.felix", name: "org.apache.felix.gogo.runtime", version: '1.0.6'
compileInclude group: 'org.fusesource.jansi', name: 'jansi', version: '1.16'
compileInclude 'de.vandermeer:asciitable:0.3.2'}
This way you do not have to do anything on the bnd file. The external jar, like magic will be placed inside your bundle and MANIFEST will be correct.
If you want generate your stubs then you go at Force.com Web Service Connector (WSC)

Related

Wrong dependency in Google Cloud SDK for google-auth?

i am using google cloud storage and google cloud datastore api (locally, for now), in a Standard Environment app.
I am having a very weird behaviour trying to running my tests (with pytest): i have discovered that, during tests, the dev_appserver.fix_sys_path command run by pytest-beds that i am using (https://github.com/kaste/pytest-beds/blob/master/testbeds/plugin.py#L35) puts the bundled google-cloud libraries before my custom versions:
/Users/username/google-cloud-sdk/platform/google_appengine
/Users/username/google-cloud-sdk/platform/google_appengine/lib/antlr3
/Users/username/google-cloud-sdk/platform/google_appengine/lib/fancy_urllib
/Users/username/google-cloud-sdk/platform/google_appengine/lib/ipaddr
/Users/username/google-cloud-sdk/platform/google_appengine/lib/yaml-3.10
/Users/username/google-cloud-sdk/platform/google_appengine/lib/rsa
/Users/username/google-cloud-sdk/platform/google_appengine/lib/pyasn1
/Users/username/google-cloud-sdk/platform/google_appengine/lib/pyasn1_modules
/Users/username/google-cloud-sdk/platform/google_appengine/lib/httplib2
/Users/username/google-cloud-sdk/platform/google_appengine/lib/oauth2client_devserver
/Users/username/google-cloud-sdk/platform/google_appengine/lib/six-1.9.0
/Users/username/google-cloud-sdk/platform/google_appengine
/Users/username/google-cloud-sdk/platform/google_appengine/lib/simplejson
/Users/username/google-cloud-sdk/platform/google_appengine/lib/django-1.4
/Users/username/google-cloud-sdk/platform/google_appengine/lib/endpoints-1.0
/Users/username/google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6
/Users/username/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0
/Users/username/google-cloud-sdk/platform/google_appengine/lib/PyAMF-0.6.1
/Users/username/google-cloud-sdk/platform/google_appengine/lib/markupsafe-0.15
/Users/username/google-cloud-sdk/platform/google_appengine/lib/webob-1.2.3
/Users/username/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2
/Users/username/dev/project
/Users/username/.virtualenvs/project/bin
/Users/username/dev/project/app
/Users/username/.virtualenvs/project/lib/python27.zip
/Users/username/.virtualenvs/project/lib/python2.7
/Users/username/.virtualenvs/project/lib/python2.7/plat-darwin
/Users/username/.virtualenvs/project/lib/python2.7/plat-mac
/Users/username/.virtualenvs/project/lib/python2.7/plat-mac/lib-scriptpackages
/Users/username/.virtualenvs/project/Extras/lib/python
/Users/username/.virtualenvs/project/lib/python2.7/lib-tk
/Users/username/.virtualenvs/project/lib/python2.7/lib-old
/Users/username/.virtualenvs/project/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Users/username/.virtualenvs/project/lib/python2.7/site-packages
This causes the import of google.auth.crypt.base module import to fail, because it does not exist in the package version shipped with google-cloud-sdk, while i can see that version 1.3.0 on github, that is apparently the same version of the one shipped with the sdk, does.
Same for pyasn1_modules package: version 0.2.1 existing, shipped 0.11
The import errors I am having are:
from google.auth.crypt import base
ImportError: cannot import name base
and:
from pyasn1_modules import pem
ImportError: cannot import name pem
Last, but not least, the environment: MACOSX.
Google Cloud SDK 184.0.0
app-engine-python 1.9.65
app-engine-python-extras 1.9.63
beta 2017.09.15
bq 2.0.28
cloud-datastore-emulator 1.3.0
core 2018.01.05
gcloud
gsutil 4.28
UPDATE: apparently, i was using the google.cloud.storage while instead i should be using, according to the examples for standard environment (https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/storage/appengine-client/main.py#L23), the package cloudstorage. I will change the code, try and update the post here.
UPDATE 2: i have created a specific github repo that should replicate the problem, just in case. Here it is:
https://github.com/brunoripa/gae_import_error
If the problem is entirely on localhost during testing, you can run:
pip install cryptography
so that the Google libraries won't even need pem to begin with.
We typically add libs to remote API with vendor system.
from google.appengine.ext import vendor
vendor.add('lib')
Module pyasn1_modules gets installed as a dependency when you install google-cloud and I am not sure of the reason behind it but, in remote API, I have observed it misses pem.py. The simple workaround would be:
# within remote API console
>>> import sys
>>> sys.modules.pop('pyasn1_modules')
<module 'pyasn1_modules' from '/Users/pjamkhande001/google-cloud-sdk/platform/google_appengine/lib/pyasn1_modules/pyasn1_modules/__init__.pyc'>
About your other issue of not being able to import from google.auth.crypt import base, you are required to gcloud auth login.
gcloud auth application-default login restores your default authentication credentials but if you want to login to the application as user, you have to gcloud auth login. Hope this helps.

Using library with Google play service vision

I am trying to add a library that uses google play service vision. My library works well on a native android project as long as I add the play service vision lib to the app. I have added the following build hints in a Codename One project:
With that build hint i have the following build error:
/tmp/build731648870085799025xxx/MyApplication/build/intermediates/res/merged/debug/values/values.xml:64: AAPT: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Dark.ActionBar'.
/tmp/build731648870085799025xxx/MyApplication/build/intermediates/exploded-aar/materialbarcodescanner-release/res/values/values.xml:9:5-12:13: AAPT: No resource found that matches the given name: attr 'windowActionBar'.
/tmp/build731648870085799025xxx/MyApplication/build/intermediates/exploded-aar/materialbarcodescanner-release/res/values/values.xml:9:5-12:13: AAPT: No resource found that matches the given name: attr 'windowNoTitle'.
/tmp/build731648870085799025xxx/MyApplication/build/intermediates/res/merged/debug/values/values.xml:69: AAPT: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Light'.
That issue is not related to the google play service lib: I have the same issue when I try to use a simple library that just uses a toastbar. Perhaps android studio generated some resources that can not be used in codename one ?
When I try to change the google play service version with the following build hint:
The google play service lib is not found anymore:
Could not find com.google.android.gms:play-services-vision:10.0.
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.pom
https://jcenter.bintray.com/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.jar
file:/tmp/build3506878302752944909xxx/MyApplication/libs/play-services-vision-10.0.jar
file:/tmp/build3506878302752944909xxx/MyApplication/libs/play-services-vision.jar
file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.pom
file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.jar
file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.pom
file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/android/gms/play-services-vision/10.0/play-services-vision-10.0.jar
Required by:
:MyApplication:unspecified
How can I change the google play service version and how can I add my libraries properly ?
Change the android.playServicesVersion to 10.0.0 or 10.0.1. Either of those should work.

How to import existing Java.class Files to Android Studio Project

I need to know how I can properly add existing Java.class files to an Android Studio Project. My goal is to use these classes in an Android Project.
The Class Files are already written in Eclipse for another Java Project.
I've already tried File->New->New Module->selecting Java Library->Finish but that doesn't work properly.
As you probably all know it makes the MyClass Class by default.
For testing I imported com.example.* in my MainActivity and tried to build an Object of that Class inside the onCreate() Method.
The problem is it can't compile the Project. I got the following Errors:
Error:(7, 1) error: package com.example does not exist
Error:(16, 9) error: cannot find symbol class MyClass
Note: C:\Users\...\MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Can anybody explain how to import my Java.class files correctly so that I can use them in my project?
You can add as a local library package to your project in Android Studio.
In android Project window, right click on app and select New -> Module.
In the Create New Module window, select Java Library and click next. Then give the module name, for example HttpClient in Library Name field. Then give Java package name as same as your existing package com.example.xxx. Then give one existing class file name AnyFileName in Java Class Name field.
Now new module is created with the name HttpClient and the package name is com.example.xxx. With an empty class file Anyfilename.java
Now copy all your .java files to the HttpClient folder created inside your android project. Now it would have overwritten the empty file Anyfilename.java also.
After copying all .java files would have automatically added to the library module.
And you will get 3rd build.gradle file for your module. Already you might be having 2 build.gradle for your android project.
In your app's build.gradle file, include local library dependency compile project(":HttpClient"). Now you can import java files in HttpClient module to android app's java files.
Note : Above information is given based on Android Studio 2.3.3

Gxt 3 Neptune Theme Setup Issue

I just installed GXT SDK 2.6 and created a new google web project.
added the following jars to the lib folder and to the build path
gxt-3.1.1.jar
gxt-theme-neptune.jar
but when i run my page on the browser i get the following error pls help.
[ERROR] [ia] - Errors in 'jar:file:/C:/Anant%20Choubey/Eclipse%20Workspace/GXT%20-%20IA%20-%2003Oct2014/IA/lib/gxt-theme-neptune.jar!/com/sencha/gxt/theme/neptune/client/base/Css3ThemeAppearance.java'
[ERROR] [ia] - Line 58: The method moreIcon() of type Css3ThemeAppearance must override or implement a supertype method
I have made no other changes elsewhere.
I think you have old version of theme plugin. Download new gxt-theme-neptune.jar-3.1.1 and try again.
Download link of gxt-theme-neptune.jar-3.1.1...

gwt-dev.jar conflicts with icu jar on war/lib classpath when using GAE

Ok I have to rewrite my question after further investigation.
I run into below problem in my GWT/GAE project :
java.lang.RuntimeException: Class com.google.appengine.tools.development.agent.runtime.Runtime$21 can not access a member of class com.ibm.icu.text.CollatorServiceShim with modifiers ""
at com.ibm.icu.text.Collator.getShim(Collator.java:456)
at com.ibm.icu.text.Collator.getInstance(Collator.java:478)
at com.google.visualization.datasource.datatable.value.TextValue$1.<init>(TextValue.java:126)
at com.google.visualization.datasource.datatable.value.TextValue.getTextLocalizedComparator(TextValue.java:125)
at com.google.visualization.datasource.datatable.value.Value$1.<init>(Value.java:141)
at com.google.visualization.datasource.datatable.value.Value.getLocalizedComparator(Value.java:140)
at com.google.visualization.datasource.query.engine.TableRowComparator.<init>(TableRowComparator.java:66)
at com.google.visualization.datasource.query.engine.QueryEngine.performSort(QueryEngine.java:234)
at com.google.visualization.datasource.query.engine.QueryEngine.executeQuery(QueryEngine.java:128)
at com.google.visualization.datasource.DataSourceHelper.applyQuery(DataSourceHelper.java:410)
at com.klawt.server.resources.chart.InvoicesChartServerResource.retrieve(InvoicesChartServerResource.java:129)
Some more investigation revealed that gwt-dev.jar contains a copy of the icu library :
public abstract class com.ibm.icu.text.Collator implements
java.util.Comparator, com.ibm.icu.util.Freezable
is part of gwt-dev.jar
My project has a dependency on icu4j 4.0.1 (for the Google Visualization Datasource library). But GAE SDK insists on using the version included in gwt-dev.jar;
I guess there must a way to setup my development environment so this kinda works, it did before.
I have tried moving GWT SDK to the bottom in the 'Order and export' tab of my build path and the icu jar to the top, but no luck.
Switching from OpenJDK to Oracle JDK fixes it !! It is not the first time I ran into issues with OpenJDK !

Resources