Build error deploying javafx application when added jna 4.1.0 library - deployment

I am trying to build my app, but I have the next error.
The jar libs\jna-4.1.0.jar has a main class com.sun.jna.Native that does not match the declared main com.bp.ocr.MainApp
I do not know how to solve it, I am looking for but I am not understand why happens.
Using base JDK at: C:\Program Files\Java\jdk1.8.0_31\jre
The jar libs\jna-4.1.0.jar has a main class com.sun.jna.Native that
does not match the declared main com.bp.ocr.MainApp
Bundler EXE Installer skipped because of a configuration problem:
Main application jar is missing.
Advice to fix: Make sure to use fx:jar task to create main application jar.
BUILD SUCCESSFUL

Related

IntelliJ build wrong JAR: Could not find or load main class

I have a simple example
public class FileSystemReadFile {
public static void main(String[] args) throws IOException {
System.out.println("Reading the file" + args[0]);
}
}
which is created in IntelliJ where I want to build JAR file; So what I did:
Added Artifact with dependencies (presumably I have some);
Ensure that MANIFEST.MF is located in src\main\resources\META-INF\ as it is already mentioned somewhere here on the site.
Run Artifact build which gave me JAR file in out folder and I run that jar file that said me "Could not find or load main class" java <name>.jar
You may see that main class is added into MANIFEST and location of manifest is also fine.
When I open that created JAR file, I see the same MANIFEST content, I see lots of dependency modules, but I don't see my class!
I suspect that is a cause. Any ideas?
If you include any signed JARs in your app and then use IntelliJ to build artifacts, it will extract the JARS and bundle them with your compiled output.
This then causes a JAVA security exception. I've seen this with Eclipse Paho and Bouncy Castle which are signed.
You can check if any of the library JARs you are using are signed using the jarsigner tool.
jarsigner -verify -verbose <path to library JAR>
Change your IntelliJ artifact setup so that these get bundled as libraries instead of being extracted. Extraction invalidates the certificate as you'd expect.
Try creating a dummy project with just Main. Add 1 library JAR (that you are trying to build with) at a time. Build an output JAR each time until Main breaks. That's how I found this.
IntelliJ should warn you.....
Not sure what was with IntellJ, but I rebuilded artifacts again and it was ok.
hadoop jar <Jar-name>
java -jar <Jar-name>
Everything is working fine.

Gradle project.sourceSets.main.runtimeClasspath always blank

I'm writing a Gradle plugin to generate Java code from WSDL. Problem is, my task does not find the Java class I'm trying to execute and blows up at runtime with a ClassNotFoundException even though the necessary jar is listed as a compile dependency. I'm using project.sourceSets.main.runtimeClasspath but have tried compileClasspath, adding a build script section to the build file, using configurations.runtime, all to no avail. Note that my project has no Java src code, just Groovy.
Any ideas? The task, a unit test and the build file can be found here:
https://gist.github.com/abhijitsarkar/8432347
c.f.: cross posted on the Gradle forum
It turns out that because my plugin uses project.sourceSets.main.runtimeClasspath, the client needs to declare the dependencies with runtime scope. It is not enough to have the dependencies declared in the plugin project only.

java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging

I am trying to implement push notification for my app. i had set up the project in eclipse added google-play-services.jar in the java buildpath and checked it in order and export.so my app was working absolutely fine when i was doing registration with gcm and was getting the registration id from gcm too.but when i try to build my app from command line i am getting the below error
java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging
i added the google-play-services.jar in the classpath so the code compiled without any issue but at runtime i am getting the above exception.looks like its not able to find the jar at runtime. how can i make the jar available at runtime also please help.
Go to configure build path -> order and export and select(check box) the packages(jars).
No matter what the build path contains in eclipse, it has nothing to do with an application. All the jars have to be added to the classpath.
I would use the following command to start the application after build:
java -cp google.jar;jarA.jar;jarB.jar;jarC.jar -jar application.jar
After the -cp option fill in the semicolon separated list of jars that you use.

NoClassDefFoundError in Eclipse when adding project in build path

I am receiving an NoClassDefFoundError in Eclipse when I try to run my project.
My Project looks like this:
JavaProject: BulkAdmin
- src
- com.mycompany.bulkadmin.SDK.util
- Login.java
Dynamic Web Project: JSPTesting
- src
- com.mycompany.bulkadmin.jspController
- Controller.java
- WebContent
- index.html
- execute.jsp
This is the control flow:
index.html loads
index.html has a form that redirects to execute.jsp
execute.jsp takes the info returned in the form and makes a static call to Login.java
execute.jsp prints the results of the call
Controller.java uses Login.java. I was receiving compilation errors. To resolve them I did this:
Right click on JSPTesting -> properties
Choose java build path on the left bar
Choose projects tab
Click add
Choose BulkAdmin (Project)
I am not sure why but now when I am getting a NoClassDefFoundError. I have done some googling. I think that this means that I have messed up my classpath somehow but I am not sure how to resolve this.
java.lang.NoClassDefFoundError: com/myCompany/bulkadmin/SDK/util/Login
at com.myCompany.bulkadmin.jspController.Controller.process(Controller.java:44)
at org.apache.jsp.execute_jsp._jspService(execute_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Other information:
I am using tomcat (in Eclipse) as my server
The exception shows up in the browser and the eclipse console
execute.jsp is a JSP
It seems like there are many similar questions to this on SO. I have read about 15 of them and tried various things however I think that my question has a different solution. I can provide more information.
Rightclick your dynamic web project, go to Properties > Deployment Assembly and add the dependent projects there. This way they will end up as JAR in /WEB-INF/lib, exactly there where you want it to be.
In Eclipse versions older than 3.5 you need to go to Properties > Java EE Module Dependencies.
See also:
ClassNotFoundException when using User Libraries in Eclipse build path
Difference between Deployment Assembly and J2EE Module Dependencies in Eclipse
The NoClassDefFoundError indicates that a class that was available during compilation is no longer available at runtime. Your problem is that the com/myCompany/bulkadmin/cSDK/util/Login class is available in the compilation classpath (in Eclipse via the Project reference you added to the build path) but not in the runtime classpath (Tomcat, which has no idea how to find this class).
You need to add the BulkAdmin project to the web-app class path when deployed on Tomcat as well.
One way to do this would be to export the BulkAdmin project as a JAR and put it into the WEB-INF/lib directory of your JSPTesting project.

Eclipse VM Argument and external JAR file error

I just added "-Djava.library.path=" to the "VM Arguments" under Run Configuration in Eclipse and everything works fine until I tried to add an external JAR file. I get the following error:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
Am I not setting something properly in Eclipse?
If your interested I forked RXTXserial a while back since thier update "schedule" sucks. I have just ported it over to the Android platform too. We decided to move the native libs into the jar and use reflection to deploy them. The API is the same as RXTX, but everything just works. You can find jars and full project sources at:
http://code.google.com/p/nrjavaserial/
The exception indicates that the class gnu.io.RXTXCommDriver tries to load a native library, which would be named rxtxSerial.dll on Windows and rxtxSerial.so on Linux, and the JVM cannot find it in the directories listed in java.library.path. Have you tried to add a JAR containing the library to java.library.path? I don't think that's possible, it has to be a directory containing the extracted library file.
Appearently that external library has a dependancy with another class gnu.io.RXTXCommDriver
. Perhaps you will need to add that library to class path.