There seems to be a number of similar questions related to this, but none have been able to provide me with any help. I'm running Microsoft's JDBC driver on SQL Server (I am using sqljdbc4.jar) and using integrated authentication to access my database. The code snippet for connecting is as follows:
String connectionUrl="jdbc:sqlserver://servername:1433;integratedSecurity=true;";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
}//catch, etc...
When I run the project in Eclipse, it starts up without a hitch. When I run Maven clean install and pack it into a .jar, however, I get the error:
java.lang.ClassNotFoundException: Failure to load: com.microsoft.sqlserver.jdbc.SQLServerDriver
at launch.JarClassLoader.loadClass(JarClassLoader.java:964)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at ui.SearchWindow$1.run(SearchWindow.java:97)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I have attempted the solutions posted in other threads; I have a System CLASSPATH variable that directs to the .jar and it is located in my build path and my runtime classpath. Perhaps the problem is staring me in the face. My best guess is that it is related to Maven, but how should I go about solving this?
Also, please let me know if I need to clarify any points; I'd be more than happy to do so.
In your comment you confirm that you manually added it to the build path and not to the maven POM. You really need to add a dependency, otherwise Maven won't know about it when building.
And add the dependency to the POM:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.1.1.jre8</version>
</dependency>
See also:
https://github.com/Microsoft/mssql-jdbc
Related
We have two applications launched using Java Web Start (jnlp file) and each application supporting different java version. One application supports Java/JRE 1.6 (supports java 1.5 but not Java 1.7 or 1.8) and the other supports Java/JRE 1.8 (only).
When we try to launch both the applications on the same desktop using direct JNLP links e.g. <serveraddress>/deploymentfolder/abc.jnlp, looks like the JavaWS cache gets corrupt and the applications are not working as expected.
We tried several methods of launching the applications listed below. In all cases, we configure two different .bat files to launch each application using complete java path e.g.
C:\java\jre1.6\javaws http://serveraddress/deploymentfolder/app1.jnlp
and
C:\java\jre1.8\javaws http://serveraddress2/deploymentfolder/app2.jnlp
Methods
Install JRE 1.6 using Java installer, use a copy-only (no need to install) copy of Java 1.8.
Install JRE 1.8 and used a copy-only copy of JRE 1.6
Install both versions
Use copy-only version of both versions
Along with first four methods, we tried to configure different JavaWS cache folder for different version by specifying it in deployment.properties file.
We could not get both the application running successfully in any try. In application logs, we see exceptions suggesting the cache is corrupt (pasted below).
Can anyone please suggest any ideas on how we can get these two applications running?
java.lang.RuntimeException: ERROR: Failed to recover corrupt cache entry
at com.sun.deploy.cache.CacheEntry.recover(Unknown Source)
at com.sun.deploy.cache.CacheEntry.getCodeSourceCache(Unknown Source)
at com.sun.deploy.cache.CachedJarFile.getCodeSourceCache(Unknown Source)
at com.sun.deploy.cache.CachedJarFile.findMatchingSignerIndices(Unknown Source)
at com.sun.deploy.cache.CachedJarFile.entryNames(Unknown Source)
at com.sun.deploy.cache.DeployCacheJarAccessImpl.entryNames(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler.assertTrust(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler.access$700(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1500(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
....
....
at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
My jar file doesn't work outside the project folder, unless i put it in the same directory as the lib folder. When i run the jar from command line i get this:
C:\Users\Computer>java -jar SG.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/hiber
nate/cfg/AnnotationConfiguration
at view.PessoaView.<init>(PessoaView.java:27)
at view.PessoaView$7.run(PessoaView.java:291)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.AnnotationConfigu
ration
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
The same with other "windows", cause my application has many menu itens. I have extracted the jar file, just to check and there's no lib folder there. I believe it should.
The jar files needed for hibernate and all others required are all in the lib folder. Can someone help?Thanks..
And here is a link to a similar question:
why doesn't my jar file run outside netbeans??
Your problem is that your jar does not includes dependancies that it requires for execution.
Your program requires hibernate jars. You can compile all dependancies with your current jar using maven.
Try this :
Build jar with dependancies
Jar file can not contain any other jar files.
Some tools like ant, can pack several jars inside one you can take a look on the ant.
Another way is directly specify class path to your libraries during running using java -cp instead of java -jar
You can directly specify class path to the needed libraries during running using java -cp /
I have an application that is working for over a year,
All my classes were sitting in the default_package,
Since it got bigger (over 30 classes), I've decided to separate it to different packages.
I refactored everything, made the changes and handled all errors.
now it works perfect when I run it through eclipse, but when I export it to a runnable jar,
it is not working.
I tried both export methods:
Extract required Libraries....
and
Package required Libraries
doesn't work on either...
when I run it from command prompt I get the following error:
E:\Request Server 3.0>java -jar RequestSrvV3DB1111.jar
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at dudug.RequestServer.ServerInfoPanel.<init>(ServerInfoPanel.java:110)
at dudug.RequestServer.RequestServerDB$1.run(RequestServerDB.java:56)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Please HELP !!!
I feel silly.
#Chasmo enlightened me that the number after the class name (ServerInfoPanel.java:110)
was referring to the problematic line,
I checked there
and I found this code:
if (props.getProperty("OfflineDB").equals("0"))
dbOfflineMode.setBackground(Color.green);
else
dbOfflineMode.setBackground(Color.RED);
I forgot to add the value "OfflineDB" to my propFile, and that was the problem.
thanks #Chasmo
I'm using Synthetica Look and Feel in my application and it works fine on Eclipse. But when i export the Jar file and execute it i got these errors :
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI
at de.javasoft.plaf.synthetica.SyntheticaDefaultLookup.getDefault(SyntheticaDefaultLookup.java:105)
at sun.swing.DefaultLookup.get(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.getInputMap(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.AbstractButton.setUI(Unknown Source)
at javax.swing.JButton.updateUI(Unknown Source)
at javax.swing.AbstractButton.init(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel.installCompatibilityDefaults(SyntheticaLookAndFeel.java:925)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel$4.propertyChange(SyntheticaLookAndFeel.java:582)
at java.beans.PropertyChangeSupport.fire(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
at com.evaluator.MainWindow.<init>(MainWindow.java:85)
at com.evaluator.Main$1.run(Main.java:15)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: sun.swing.plaf.synth.SynthUI
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 35 more
I don't know where is the problem exactly. Here is the way I'm applying the Synthetica Blue Steel Look And Feel :
try
{
UIManager.setLookAndFeel(new SyntheticaBlueSteelLookAndFeel());
UIManager.put("Synthetica.rootPane.titlePane.title.center", true);
UIManager.put("Synthetica.translucency4DisabledIcons.enabled", true);
}
catch (Exception e) {}
Please see the error it can't find the sun/swing/plaf/synth/SynthUI
Library. In development mode You are include that jar file in eclipse library but when you are create a jar file then you are not include the Synthui theme jar. Put that Synthui jar file in jar, ext/ folder and it work fine
I think the way you are exporting the jar file is not correct.
Try exporting the jar as a Runnable jar file.
Follow these steps to export your app as a runnable jar.
1) select export from the file menu.
2) select Java->Runnable JAR file
3) Select the launch configuration i.e your main class.
4) first two option of library handling if you want to package the substance library file in your own jar and the third option(copy required library into a sub folder next to the generated jar) if you want to separate the generated jar file and substance libs.
5)Press finish.
I hope this would solve your problem. :)
I am using exe4j and I'm trying generate an exe file, after generated I try execute but does not work.
here the problem
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant
at iguana.Principal.<init>(Principal.java:69)
at iguana.Principal$32.run(Principal.java:1187)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.joda.time.ReadableInstant
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
Any idea?
It looks like you are missing a joda-time class. My only thought might be that you are missing the library for it, which can be downloaded here:
http://joda-time.sourceforge.net/
Or, if you use maven like me, add:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
to your POM file.
Hope this helps!
It looks like you left a library out of your executable. It can't find the org.joda.time package.
There are 2 probable solutions:
If the library got left out, add it.
If the library is already included, check that the classpath shows where it is.
Here is the exe4j help page that shows how to edit the classpath.