FUBAR after update to GAE-java-sdk-1.6.0/1.6.1 persistencemanager singleton - google-app-engine

After I updated from GAE-JAVA-SDK-1.5.5 to 1.6.0 and 1.6.1 my app stop functioning properly. it started giving an error on the RPC service.
Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void com.skip.school.client.service.AdminService.addStudent(com.skip.school.shared.Student)' threw an unexpected exception: java.lang.NoClassDefFoundError: Could not initialize class com.skip.school.server.PmfSingleton
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.skip.school.server.PmfSingleton
The whole log can be found here pastebin.
I have a singleton that should be initialized when the user starts there first rpc call.
The singleton I use should be correct there are many example found here on stackeroverflow and everywhere on the web.
public final class PmfSingleton {
private final static PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
private PmfSingleton() { }
public static PersistenceManagerFactory get() {
return pmfInstance;
}
}
I call that class in all my server implementations like so.
PersistenceManager pm = PmfSingleton.get().getPersistenceManager();
this works on sdk 1.5.5 and below but not on sdk 1.6.0 and above, does anyone know what I' doing wrong what i should change if i want to use sdk 1.6.0 and above?

I read somewhere else that this problem is related to an out dated version of the datanucelus jars. I've updated to the latest version, v1.6.1 available from the eclipse plugin and I fixed it by deleting all old references to the old jars, leaving behind just these 3:
datanucleus-appengine-1.0.10.final.jar
datanucleus-core-1.1.5.jar
datanucleus-jpa-1.1.5.jar
I hope that works for you!

I had this same problem after upgrading to a newer version of AppEngine SDK. It turns out the problem was I had an older version of the appengine-api-1.0-sdk jar hanging around in the deployment folder.
Have a look in the war\WEB-INF\lib folder of your application and see if there are two different versions of appengine-api-1.0-sdk-1.x.y.jar. I fixed it by removing the appengine-api-1.0-sdk-1.5.x file.

Related

"cannot find symbol method setBatchPath(String)" in the generated source from generated endpoint

For an unknown reason, when I tried to build my Google App Engine endpoints, I get these errors in all of the API java files generated by Android Studio:
Error:(400, 5) error: method does not override or implement a method from a supertype
Error:(402, 29) error: cannot find symbol method setBatchPath(String)
I did some initial troubleshooting and found out that there's a Builder class inside the java file and it extends AbstractGoogleJsonClient.Builder. I looked at the source for the Builder class and I cannot find the method.
Why all of the sudden am I getting these errors? Help!
Same thing happened to me this morning.
I resolved it by adding this in my backend project
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
and updating this version in my app gradle file.
implementation('com.google.api-client:google-api-client-android:1.23.0')
Faced the same problem. I upgraded google client libs to 1.23.0 and it worked (earlier was 1.22.0)
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.http-client:google-http-client-android:1.23.0'
We already had these in our backend build.gradle:
dependencies {
compile 'com.google.api-client:google-api-client:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.http-client:google-http-client:+'
compile 'com.google.http-client:google-http-client-android:+'
}
All we needed was adding:
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
But it'd have been nice if Google didn't break our codes every once in awhile out of the blue and wasting hours of development time!

The constructor FirefoxDriver(FirefoxOptions) is undefined

I am using Selenium 3.5.3 and following is my code.
I am trying to use Firefox options in the constructor as in
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/firefox/FirefoxDriver.html#FirefoxDriver-org.openqa.selenium.firefox.FirefoxOptions-
FirefoxOptions options=new FirefoxOptions();
options.setProfile(profile);
driver =new FirefoxDriver(options);
I am getting an error in instantiating the Firefox driver:
The constructor FirefoxDriver(FirefoxOptions) is undefined
How can I solve this?
Firefox version 55.0.3 64 bit
Geckodriver v0.18.0
Try this code:
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
public class FirefoxOptionsDemo {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "E:\\software and tools\\geckodriver.exe");
FirefoxProfile profile =new FirefoxProfile(new File("C:\\Users\\sys\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\ejtrne37.QAProfile"));
FirefoxOptions option=new FirefoxOptions();
option.setProfile(profile);
// Initialize Firefox driver
WebDriver driver = new FirefoxDriver(option);
//Maximize browser window
driver.manage().window().maximize();
//Go to URL which you want to navigate
driver.get("http://www.google.com");
//Set timeout for 5 seconds so that the page may load properly within that time
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//close firefox browser
driver.close();
}
}
This is the image for your reference:
The issue is due to older selenium version coexisted. mvn clean install resolved the issue.
Your problem may be related to different causes.
The common cause is a misaligned version of your firefox browser and/or gecko driver and/or selenium library.
I solved this problem upgrading gecko driver and selenium library to the latest version.
In my case, mvn clean install does not resolved the problem
Since an upgrade to current available release versions is not a doable action by many since it is not acceptable to their teams due to the impact - so they need a working fix for current in use version itself hence my answer -
I may be answering it a lot late but my solution is a workable one for this problem and I can even explain why it is workable and why above one is not workable as asked in your query -
For older selenium and gecko driver versions, the above suggested method i.e. Options class utilization used to work from Selenium 3.5 and upwards (officially) but for versions lower than 3.5 - the options class was not available, so the above suggested method does not work.
I backtracked and found that even in the most widespread popular Selenium version 3.14(which I ended up using for project specific needs, even though the current stable release is at Selenium 4.5 :D) the options class and above suggested method does not work.
So the alternative is just to replace the import of options class and utilization of any of its methods.
In my code I just used direct paths for geckodriver and firefox exe paths and then instantiated the FirefoxDriver class object via WebDriver interface and the constructor is undefined error stops troubling as it is we are not passing any argument in constructor as expected by Eclipse JVM:
Here are my exact lines of code to solve this -
System.setProperty("webdriver.gecko.driver", "D:\\Selenium Projects\\BrowserDrivers\\geckodriver.exe");
System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe" );
driver = new FirefoxDriver();
Rest of the code remains as is originally.
The above method of options class utilization or multiple arguments in constructor are supported only after Selenium 3.6. If you use latest selenium and geckodriver, then I dont think you will run in above problem at all as I was able to see it working in the latest versions.
But sometimes we can't just upgrade to our wishes, and we need a fix in the current used versions itself, hence this solution has been suggested by me.

Firebase access within GAE

It seems that the latest sdk com.google.firebase:firebase-server-sdk:3.0.0 relies on creating threads for most calls, e.g., com.google.firebase.database.FirebaseDatabase.getReference
This is a problem when using GAE since it promptly throws an Exception:
servlet java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
Are we suppoed to just use the JVM sdk (com.firebase:firebase-client-jvm) instead?
The instructions aren't so clear and it seems like the legacy website is the only one where we can get the secret. The new website gives us the .json file.
Has anyone had any success with using the new v3 version with GAE?
Yes. Just tested.
As with the 2.x SDKs, you can work around the threading limitation by using manual scaling.
While the Cloud guide on using Firebase with GAE is a bit outdated, the section on manual scaling should still be useful to help you through this.
More on ThreadManager here.
I was experiencing the same problem and discovered the cause in this blog thread.
When adding dependences, I had included appengine-java-sdk but overlooked appengine-api-1.0-sdk. Adding it eliminated the exception. The full dependencies block is:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.48'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.firebase:firebase-server-sdk:3.0.3'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.48'
}
Include the JSON file in the "Resource Files" of appengine-web.xml.
Example:
<resource-files>
<include path="/**.xml" />
<exclude path="/feeds/**.xml" />
</resource-files>
See the link https://cloud.google.com/appengine/docs/java/config/appref#resource_files .
"The files that listed in the element are accessible by the application code using the filesystem. These files are stored on the application servers with the app as opposed to how static files are stored and served.".

appengine error - java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.org.apache.xerces

I re-deployed my app (google appengine), it seems to be working fine, but when I try to parse Xml I get:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.org.apache.xerces.internal.parsers")
what does it mean? and how I can solve it?
on previous version of the app I didn't got this error.
when running the app locally I don't get this error.
I made minor changes - I pass some data from the UI to the datastore
Here is the code that parse the XML:
public static <T extends BaseDataObject> T xml2Bean(Class<T> clazz,
String xmlData) throws UnsupportedEncodingException, JAXBException {
Reader reader = new StringReader(xmlData);
JAXBContext context = getContext(clazz);
Unmarshaller um = context.createUnmarshaller();
return (T) um.unmarshal(reader);
}
My guess is that Google use to support com.sun.org.apache.xerces.internal.parsers but now they don't, and my old code still working because it was pushed when it was still supported...
how can I verify this guess? i.e. where can I find the list of unsupported packages?
I'm thinking of dropping the XML code and use json instead, how can I make sure json is supported?
Problem was solved: I've downloaded xerces and added the jars to war\WEB-INF\lib and to the build path in eclipse.
I also upgrade to the latest JDK (java 7).
I'm not sure which of those solved the problem...
Something in your code or a dependency of your code, is trying to refer to the package com.sun.org.apache.xerces.internal.parsers, which is not allowed on GAE. Just a guess: maybe a dependency has been upgraded and this dependency is trying to access that package.

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