0

My application's JNLP file inside tomcat\webapps\swingapp\simple.jnlp

<?xml version="1.0" encoding="utf-8"?> 
<jnlp 
  spec="1.0+" 
  codebase="http://localhost:8080/swingapp/" 
  href="simple.jnlp"> 
  <information> 
    <title>Simple Swing application</title> 
    <vendor>Me</vendor> 
    <description>Simple Swing Demo Application</description> 
    <description kind="short">Simple Swing Demo Application.</description> 
    <offline-allowed/> 
  </information> 
  <resources> 
    <j2se version="1.7.0+"/> 
    <jar href="simple.jar"/> 
  </resources> 
  <application-desc/> 
</jnlp>

My MANIFEST.MF file inside simple.jar contains these entries :

Manifest-Version: 1.0
Class-path: mysql-connector-java-5.1.18-bin.jar
Sealed: true
Created-By: 1.7.0_01 (Oracle Corporation)
Main-Class: com.ui.LoginForm

simple.jar - I have a simple swing login window where I check the username/password against a mysql table.

When I execute the jar from the command it works fine. It connects to the mysql database and checks the username/password.

But when I launch the application using the url "http://localhost:8080/swingapp/simple.jnlp", it cannot find the mysql driver. Though I can see its in the jar when I unjar using 'jar xf'. Log file from "C:\Documents and Settings\user\Application Data\Sun\Java\Deployment\log"

<record>
  <date>2012-03-18T23:15:39</date>
  <millis>1332092739265</millis>
  <sequence>0</sequence>
  <logger>com.sun.deploy</logger>
  <level>FINE</level>
  <class>com.sun.deploy.trace.LoggerTraceListener</class>
  <method>print</method>
  <thread>8</thread>
  <message>user name : admin
</message>
</record>
<record>
  <date>2012-03-18T23:15:39</date>
  <millis>1332092739265</millis>
  <sequence>1</sequence>
  <logger>com.sun.deploy</logger>
  <level>FINE</level>
  <class>com.sun.deploy.trace.LoggerTraceListener</class>
  <method>print</method>
  <thread>8</thread>
  <message>password  : swingAdmin
</message>
</record>
<record>
  <date>2012-03-18T23:15:39</date>
  <millis>1332092739281</millis>
  <sequence>2</sequence>
  <logger>com.sun.deploy</logger>
  <level>FINE</level>
  <class>com.sun.deploy.trace.LoggerTraceListener</class>
  <method>print</method>
  <thread>8</thread>
  <message>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
</message>
</record>
<record>

What could be the cause here?

sachinrahulsourav
  • 742
  • 1
  • 7
  • 16
  • Check the JNLP using [JaNeLA](http://pscode.org/janela/). Is the http://localhost:8080/swingapp/mysql-connector-java-5.1.18-bin.jar URL valid in a browser (e.g. you can copy/paste it to the address-bar, hit enter and get the Jar)? Did you have another question earlier about MySQL for a server? – Andrew Thompson Mar 18 '12 at 17:52
  • @AndrewThompson localhost:8080/swingapp/mysql-connector-java-5.1.18-bin.jar this obviously throws 404 as the jar is inside the jar 'simple.jar' And this is my first question regarding Mysql – sachinrahulsourav Mar 18 '12 at 17:57
  • *"the jar is inside the jar 'simple.jar'"* That will not work using the standard class-loader. Put it at the URL I showed in the link (so it is not a 404). Also, please answer the questions that I asked on [this comment](http://stackoverflow.com/questions/9755756/no-suitable-driver-when-running-but-not-in-ide#comment12413555_9755756) to an entirely different person (in a very similar situation). – Andrew Thompson Mar 18 '12 at 18:06
  • `` Has the 7 version of the J2SE even been pushed to the public yet? Here I'm still running 1.6.0_29. – Andrew Thompson Mar 18 '12 at 18:10
  • @AndrewThompson Ok, I extracted the mysql driver to the location of the URL and mozilla asks to download the jar file when i type the URL in the browser 'localhost:8080/swingapp/mysql-connector-java-5.1.18-bin.jar'... But amazingly i still get the 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'. I believe Java 1.7 is out on Oracle site. – sachinrahulsourav Mar 18 '12 at 18:16
  • OK what about the answers to the questions I asked on the other thread? They amount to "Where is that class?". Is it in the one MySQL Jar mentioned? I doubt it would be, given the name. – Andrew Thompson Mar 18 '12 at 18:25
  • I read your comment there, 'com.mysql.jdbc.Driver' is inside 'mysql-connector-java-5.1.18-bin.jar' which i can see in my webapps context directory 'swingapp'... and I can verify the driver class is there by running 'jar xf' and my application window is inside the jar simple.jar and the main class is invoked. Its after the form tries to connect to mysql does it fail. – sachinrahulsourav Mar 18 '12 at 18:33
  • Thanks for confirming. Try uninstalling the app. and doing a fresh launch. – Andrew Thompson Mar 18 '12 at 18:40

1 Answers1

0

extract the mysqlconnect.jar. copy the com,META-INF,org folder in the parent folder of package. create jar file. create keystore bind keystore to jar create jnlp file run! NOTE: the mysql driver permits to use "localhost" and so the application can run on same computer domain only. for keystore, binding concepts check: http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/