James Brooks

Gunslinger
+ Follow
since Aug 17, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by James Brooks

Jan Cumps wrote:Nothing I can see directly in your code.
But I can see that you call some unknown to us methods (e.g.: populateReadArray ) in your while loop. Have you checked what is happening there?


Yeah, nothing funny that I see:


Jan Cumps wrote:
Do you use recursion in your program?



No, everything is iterative. (while and for with counters)

Jan Cumps wrote:In your code, you don't close connections if exceptions occur.
You should not close a connection - and other jdbc resources - in the try{} block, but in the finally{} block.



This is true; I really didn't think about that. Thank you. I'm going to change it, but any idea why I'm holding these open, even though no exceptions are thrown?
Hi all,

I'm connecting to a SQL Server 2008 DB, and my code is apparently holding connections open in the DB, as evidenced by the Activity Monitor (sleeping - waiting for command), and in reports - Activity All Sessions (Show as a connection, 'no active requests on the session'). I'm closing my ResultSet, my Statement, and my Connection. Is this not enough? I'm using, for example, the following code for DB access, if interested:


also:

also:


also:

also:

Rob Prime wrote:When you use JAR files and the -jar flag, the class path is ignored. Try putting the JavaMail JAR file in a folder relative to your JAR file, then adding it to the Class-Path directive in your MANIFEST.MF file.



Well, I'm using Netbeans, so I don't know of a way of modifying the manifest file. I've put the javamail JAR in both the compile and run-time libraries in Netbeans, but am still getting this error from the JAR that is generated from my project (the JAR in the dist path of my Netbeans project). Do I maybe need to look at building this without the use of Netbeans, so that I have more granularity of control? Surely Netbeans has the capabilities to do what I am wanting to do; maybe I'm just missing a step somewhere? Again, I can double-click the JAR file, and it runs, but when run via the task scheduler under those same account privileges, that's when I get the error.
14 years ago

Wouter Oet wrote:Try using the -classpath (or -cp) option of the java command.



I placed the mail jar in the root of the C drive, then changed the task to the following:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -cp "C:\mail.jar" -jar "C:\CMMS_SCADA.jar"

I still got the same error. Any ideas?

Thank you!
14 years ago
Hi all,

I have a task running on my WS2003 machine as inforadmin.PASCOUTIL via the task scheduler ( "C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -jar "C:\CMMS_SCADA.jar" ). When I'm logged on as this user, I can run the jar file by double-clicking on it, but the task scheduler throws the NoClassDefFoundError pointing to javax.mail. I assume this as a javamail JAR file placement issue? I've attached a .gif showing the screenshot of this JAR file on the local computer, so if anyone would like to look and comment, I would greatly appreciate it.
14 years ago
Also, is there a good resource to learn about the different paths within the JRE/JDK directories? I'm still clueless about this part of it.
14 years ago
OK, thanks for the help :-) I changed the task scheduler's profile for that task to my domain admin login, and voila! I was confused because that username is the same for the local machine and the domain. Now, I'm getting that silly mail messaging exception (class not found) again when it runs, but only when either the task scheduler runs it, or when I navigate to the directory you named below and run it from there. Any thoughts? It apparently has to do with the mail.jar file. I did a search for mail.jar on the entire computer, and got quite a few results. See screenshot of search results if you like; I have a feeling that this a .jar file placement problem, or maybe it is in a directory it should not be and is causing a conflict.

Paul Clapham wrote:

James Brooks wrote: The program creates a .csv file. When run manually, the .csv is output, which I can tell from the file attributes (time created). It does not output the file when the task scheduler supposedly runs it.


No, that just tells you that it didn't work right. You know the task scheduler ran it, so presumably something bad happened and the program crashed. That suggests to me that something is different between your environment and the task scheduler's environment.

By the way, you said it worked correctly when you ran it from the command line. Does it work correctly when you run it from the command line with C:\Program Files\Java\jdk1.6.0_13\jre\bin as the current directory, or did you try it with some other current directory?

And does the command line run the application under your user profile or some other user profile. Could that make a difference?

I'm sure there are plenty of other environment differences that could exist. Keep looking for them.

14 years ago
Hi Paul,

The program creates a .csv file. When run manually, the .csv is output, which I can tell from the file attributes (time created). It does not output the file when the task scheduler supposedly runs it.

Paul Clapham wrote:What makes you think the program doesn't run? Perhaps it does run but the results of its running weren't what you expected.

14 years ago
Hi all,

OK, so, I have my JAR file on a WS2003 machine, and when I double-click on the JAR or run it from the command line, my program executes just fine. The JAR is on the root of my C drive; C:\CMMS_SCADA.jar. I've created a daily scheduled task for this JAR, and when the clock rolls around to its execution time, the task status shows as 'running', but the program does not run. The scheduler is scheduled to run:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -jar "C:\CMMS_SCADA.jar"

and start in:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin"

Am I missing something?

Thanks in advance, as always.
14 years ago
Also, should I take the mail jar out of my project's library in Netbeans, since I'm putting them in the CLASSPATH variable in my WS2003 machine?
14 years ago
Yes, jdk1.6 and jre6. And sorry, which other jars are you referring to?


Stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingE
xception
at cmms_scada.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more

Paul Clapham wrote:I see you didn't add the Java Activation Framework to your classpath, so presumably you're using Java 6 where it is built in?

And do any of those other jars contain JavaMail classes?

Also, the stack trace would be useful information, to see where the class is being requested from.

14 years ago
Thank you for the suggestion. I removed SMTP.jar from my CLASSPATH, and it still occured. Any other ideas?
14 years ago