I am trying to import a Codename One project from my private Bitbucket repo to a second workstation. Both of my workstations run on Windows and are using Java 8. I use IntelliJ IDEA and have checked that all my files have been pushed to my repo.
Strangely, the server can create both Android and iOS builds, but I am unable to run my simulator, which would greatly speed up development. This is the error I get when trying to run the Simulator:
"C:\Program Files\Java\jdk1.8.0_111\bin\java" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\lib\idea_rt.jar=49613:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath C:/Users/mypc/IdeaProjects/myApp\out\production\myApp;C:/Users/mypc/IdeaProjects/myApp\src;C:/Users/mypc/IdeaProjects/myApp\lib\CodenameOne.jar;C:/Users/mypc/IdeaProjects/myApp\JavaSE.jar;native/internal_tmp;lib/impl/cls com.codename1.impl.javase.Simulator org.myapp.app.Main
java.lang.ClassNotFoundException: org.myapp.app.Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.findSystemClass(ClassLoader.java:1004)
at com.codename1.impl.javase.ClassPathLoader.findClass(ClassPathLoader.java:100)
at com.codename1.impl.javase.ClassPathLoader.loadClass(ClassPathLoader.java:50)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.codename1.impl.javase.Executor$1.run(Executor.java:86)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
However, my Main is in the project.
Any ideas?
Thanks.
SOLUTION:
My repository name was different than my project name, as defined on my primary workspace. When the project was downloaded to my other machine, the repo name was used as the project name. Changing the project name by clicking File -> Project Structure and then changing the project name back to its real name fixed the problem. Now the simulator works.
Thanks to #Shai Almog for his directions and for giving me this idea.
The directory listed above is: C:\Users\mypc\IdeaProjects\myApp.
Is that path correct?
Assuming it is open CMD and do the following:
cd C:\Users\mypc\IdeaProjects\myApp
dir
In that listing you should see several files. Two important files are: JavaSE.jar & CodeNameOneBuildClient.jar. I'm assuming both are there as you can send a build.
Next do this:
dir out\production\myApp
This is where idea should store your application classes when it compiles. I have a sense that this will be missing and it's the reason for this failure. Assuming that's the case look in the .idea directory for references to this path and verify that they are correct.
Related
I just moved my Codenameone Project within Eclipse to a new MacBook. When I start the simulator now there is an error shown in the console of eclipse. As a result, new installed skins will not be stored and are gone at the next start of the simulator.
Here is the stack trace of the error. Do you have any idea, what the reason could be? Maybe there are some pathes stored that don't match on the new MacBook?
java.util.prefs.BackingStoreException: Synchronization failed for node '/com/codename1/impl/javase/'
at java.util.prefs.MacOSXPreferences.flush(MacOSXPreferences.java:226)
at com.codename1.impl.javase.JavaSEPort.addSkinName(JavaSEPort.java:3425)
at com.codename1.impl.javase.JavaSEPort.loadSkinFile(JavaSEPort.java:3517)
at com.codename1.impl.javase.JavaSEPort.init(JavaSEPort.java:3673)
at com.codename1.impl.CodenameOneImplementation.initImpl(CodenameOneImplementation.java:169)
at com.codename1.ui.Display.init(Display.java:478)
at com.codename1.impl.javase.Executor$1.run(Executor.java:112)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
This is an exception from the Java SE preferences API see this Where are Java preferences stored on Mac OS X?
Check that the user on Mac OS has the permissions to access that folder and that the Java SE process has such permissions too. Notice we use user nodes which should always work and never store to system nodes.
I have a program in Apache Flink. I tested and ran it on the local machine and every thing works fine. To run the program on a remote cluster, I did necessary changes as mentioned in Apache Flink Official Website.
I did the following changes:
The two points below
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("taskManagerName",
portNo,paralelismNo);
Fixing the necessary paths to read input files and write outputs.
Generate a thin jar out of the program and put the necessary jar
libraries into a folder besides my project jar file called
myproj.jar.
copying the data and the jar library and myproj.jar into the cluster
and run the following command remotely on the cluster:
java -cp pathToJarLib \\* -jar myproj.jar
But, I get the below error and I don't have any clue to fix the issue. There are no relevant log files which can aid me in fixing this issue.
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/api/common/functions/MapFunction
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
at java.lang.Class.getMethod0(Class.java:2813)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.api.common.functions.MapFunction
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Your classpath is obviously not complete. Try to submit via bin/flink run myproj.jar. This sets up the classpath correctly.
I have a big application that worked perfect inside eclipse, I create an executable jar file for my application, My application use jython to define some resources. Also I create `the following .bat file to run the file:
# echo off
java -Xms64m -Xmx512m -Xincgc -Dpython.home=jython-2.1 -Dpython.path=jython-2.1/Lib/alice -Djava.library.path=lib/win32;externalLib/win32; -jar MyProg23.jar
When execute the .bat file an exception appeared, this is a part of this exception:
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at edu.cmu.cs.stage3.alice.authoringtool.JAlice.main(JAlice.java:163)
Caused by: Traceback (innermost last):
File "C:\MyWork\AliceDev\Alice test\resources\Alice Style.py", line 23, in ?
File "C:\MyWork\AliceDev\Alice test\resources\common\StandardResources.py", li
ne 181, in ?
AttributeError: java package 'javax' has no attribute 'vecmath'
at org.python.core.Py.AttributeError(Py.java)
at org.python.core.PyObject.__getattr__(PyObject.java)
at org.python.pycode._pyx1.f$0(C:\MyWork\AliceDev\Alice test\resources\c
ommon\StandardResources.py:181)
at org.python.pycode._pyx1.call_function(C:\MyWork\AliceDev\Alice test\r
esources\common\StandardResources.py)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.__builtin__.execfile_flags(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
at org.python.core.PyObject.__call__(PyObject.java)
at org.python.pycode._pyx0.f$0(C:\MyWork\AliceDev\Alice test\resources\A
lice Style.py:23)
at org.python.pycode._pyx0.call_function(C:\MyWork\AliceDev\Alice test\r
esources\Alice Style.py)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.__builtin__.execfile_flags(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.loadReso
urcesPy(AuthoringToolResources.java:199)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.<clinit>
(AuthoringToolResources.java:108)
... 3 more
The vecmath.jar file and other external lib are founded inside a folder called externalLib which in the same folder of the Myprog23.jar and .bat files
How to solve the problem and what is need to be set?
You need to add all jars used in program to classpath. So, in your case all jars present in externalLib directory should be added in classpath.
For adding jars in classpath you may refer Setting multiple jars in java classpath
I am assuming that you have correctly set your CLASSPATH variable. Also assuming you have correctly installed JyThon. You should really make sure to TEST JyThon hello world OUTSIDE of your application environment as well. You need to take this step by step, Alice is a complex system, and so it is difficult to debug your issue without making sure basic structure of libraries is in place.
With these assumptions, you can proceed with JyThon documentation FAQ:
Jython cannot find your Java class, even though it exists in the class path.
Jython cannot find your Java class, even though it exists in the class
path. This shows up as "ImportError: cannot import name xxx" or
"AttributeError: java package xxx' has no attribute 'yyy'"
This happens when Jython is installed as a Java extension (i.e. when
jython.jar is installed in java\jre\lib\ext) and your classes are
installed in the classpath.
The reason is Java extensions can only see other extensions, not other
classes defined in the CLASSPATH or passed in to java using the
--classpath option.
There are two ways to fix this:
Move your classes to the java\jre\lib\ext directory.
Remove jython.jar from the java\jre\lib\ext directory and put
jython.jar in the CLASSPATH or use the java --classpath option.
Dear Selenium Experts,
I have come across the following run-time error from a JPA 2.0 program which appears to be related to Firefox Profile for some reason:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:56)
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:79)
at model.DownloadCarDetail.getMercedezDetail(model.DownloadCarDetail:72)
at model.DownloadCarDetail.getMercedezDetail.main (model.DownloadCarDetail.getMercedezDetail.java:47)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
Java Result: 1
I have kept Firefox to version 15 so that it is supported by Selenium Webdriver but suspect that the issue is to do with not able to read profile directory.
Your assistance would be very much apprecaited.
Many thanks,
George
The problem you are seeing has nothing to do with your Firefox profile.
Actually, it is the JVM classloader that complains that it can't find the com.google.common.collect.Maps class.
This usually means that you don't have Guava (which is a dependency for Selenium) on your classpath. Clean and rebuild your project, check your classpath, check the various versions of libraries that might be there. If you're using some kind of dependency management system (Maven, Ivy etc.), check it's configured right.
Import the .jar file to Eclipse downloaded from here (depending on the current version).
open this link https://www.seleniumhq.org/download/ and download Java 3.11.0(current version) open zip file to desktop on netbeans or eclips click add jars/file in selenium-java-3.11.0\libs select all file also in selenium-java-3.11.0 select client-combined-3.11.0.jar you will be ok. dont remember to add System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); code. you can download chromedriver this link https://chromedriver.storage.googleapis.com/index.html?path=2.38/
In my case the Guava dependency was corrupt. Worked fine after I deleted the corrupt jars and rebuilt whole project.
Thank you for offerring your suggestion for a solution to this issue. I have found the exact answer from Selenium 2 WebDriver NoClassDefFoundErrorS which has resolved the underlying issue.
George
add below maven dependency and clean and compile your code.
<!-- https://mvnrepository.com/artifact/com.google.common/google-collect -->
<dependency>
<groupId>com.google.common</groupId>
<artifactId>google-collect</artifactId>
<version>0.5</version>
</dependency>
I wrote a couple of REST services using Jersey 1.13 on JRE 1.6. Everything runs fine locally, but after I deploy to GAE I get this error:
****Uncaught exception from servlet
java.lang.IncompatibleClassChangeError: Implementing class
at com.google.appengine.runtime.Request.process-139e1bda14d5aebc(Request.java)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:452)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:458)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:698)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:336)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:328)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:456)
at java.lang.Thread.run(Thread.java:679)****
Any help would be appreciated.
This exception is caused by compatibility issues between asm-4.0.jar and asm-3.1.jar. With the new Version of AppEngine, asm-4.0.jar is used and it is not compatible with Jersey, which relies on asm-3.1.jar. To make Jersey still work on GAE 1.7, you have to remove the dependency on asm-4.0.jar.
See this post : http://cloudvane.com/2012/09/23/problem-with-google-appengine-and-jersey-with-java/
It s tested and verified, like that:
add asm-3.3.1.jar to your war->lib
add it to you re build path
remove physically the asm-4.0.jar
Project -> Properties -> Google -> AppEngine: switch Datanuclueus to v1
That s it!
The instructions on this post took care of my problem.
Apparently the jersey-server 1.13 jar is compatible with asm3.1 and GAE 1.7.1 needs ASM 4.
Using the Jar repackaging tool jarjar you can deploy a asm 3.1 jar that will play with asm 4.
You may need to use JarJar version 1.3 if 1.4 gives an error message.
The new Jersey version 1.18.1 doens't depend on Asm 3, so it's compatible with GAE!
Maybe this will help: java.lang.IncompatibleClassChangeError: Implementing class Mongo
It's not exactly the same class, but the problem occurs when you have a library with 2 different version jars. Make sure you did not include any extra libraries or (I'll explain what happened to me):
You have A-1.0.jar and A-1.0.jar has inside another jar, let's say B-1.0.jar, but you have included separately a B-2.0.jar and in this way the two different version B jars are the problem.
Make sure you did not make this.
Same problem here, but I believe I've fixed it!
The trick was running a clean inside of eclipse, which notified me of the following error:
java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: org.datanucleus.exceptions.NucleusUserException: You seem to have ASM v3 in the CLASSPATH and you need ASM v4
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:173)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1133)
... 7 more
The important bit . . .
Caused by: org.datanucleus.exceptions.NucleusUserException: You seem to have ASM v3 in the CLASSPATH and you need ASM v4
Apparently, GAE does not like having two versions of ASM loaded. On a whim, I went into the eclipse project properties and changed the datanucleus version from v2 to v1. I redeployed and now my app works. So much for catching these kinds of issues in the local dev environment . . .
I think I spent more time configuring GAE to run with jersey than I did actually writing the app. This may be my first and last GAE hosted app.
Did you update your App engine's SDK? (Recently the App engine SDK was updated from 1.7.0 to 1.7.1.)
Try to revert your app engine's SDK to 1.7.0. I have tried many solutions that I found on the Internet, none of them worked for me, but this one worked.
I have no idea how I can safely change my app engine project's sdk version for now. If anyone knows how to change the SDK version of the app, please let me know.
I got this error working on a maven project using Jersey-1.11 to develop a REST service:
cglib-3.0 depends on asm-4.0, and so I excluded it, leaving asm-3.0 to stand. This is because the Jersey version I am using uses asm-3.0.
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.0</version>
<exclusions>
<exclusion>
<artifactId>asm</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
</dependency>
I changed the Persistence from JAP2 to JPA1 and it worked for me.