• Post Reply Bookmark Topic Watch Topic
  • New Topic

Disambiguating a class defined in multiple libs  RSS feed

 
deb platt
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a small app that has a local variable declared as: Since the DataSource class is from our company library, I import the associated namespace at the beginning of my file:
When I run the app from Eclipse, it works fine. When I move the class file over to a Solaris machine where it is invoked via a shell script, an exception is thrown in which the JVM complains it can't find the class definition for javax.activation.DataSource.

On the Solaris machine, I have verified that the jar containing mycompany.companypkg.DataSource is in the CLASSPATH. I have also executed to make sure the class definition is in the jar. It is. I then modified the source code to use the fully qualified class name. So the local variable is now declared as The code continues to run without difficulty from Eclipse on my laptop. However, I still get the Class Definition not found for javax.activation.DataSource when I run the program on the Solaris machine.

What am I overlooking?

Thanks in advance,
Deb
[ April 21, 2008: Message edited by: deb platt ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the JVM is complaining that it can't find javax.activation.DataSource, then somewhere in your code you must be referencing that class instead of your own class named DataSource.

Check your source code files, especially the import statements. Maybe somewhere you have an "import javax.activation.DataSource;", which you accidentally added (if you're using an IDE, the IDE may have added it automatically without you noticing it).

It's also possible that on Solaris you have some old versions of your class files or JAR files somewhere, which are still getting used instead of the most recent ones where you've fixed the problem. Make sure that you're really using the newest versions on the Solaris machine, and check if there aren't any old versions in a directory or JAR file that's in the classpath.
[ April 21, 2008: Message edited by: Jesper Young ]
 
deb platt
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've got it figured out. The program I'm working on queries our database and then notifies an email recipient of pertinent information that the query uncovered. Searching the web, I found someone who said that if you use Sun's javamail product, you have to include activation.jar (the library holding JavaBeans Activation Framework) in your CLASSPATH. Apparently something in javamail tries to access the class I mistakenly thought the JVM was complaining it couldn't find the class definition for my company's DataSource class, but that wasn't the case.

The new mystery is why the program was running without difficulty on my laptop under Eclipse. As far as I can see, there is no activation.jar in the build path.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which JRE are you developing under?
Since Java 6, the Java Activation Framework is part of the JRE. Even though you may be compiling for a different version, it will still look in the JRE's libraries, and find JAF there. On the Solaris machine it won't be there if it's an older JRE version.
 
deb platt
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bingo. On my laptop I'm running JRE 1.6; I set up this Eclipse project to be compliant with 1.5 because that's what the Sys Admin has installed on the Solaris machine. I did poke around the 1.6 libraries trying to see if I was inadvertently using activation.jar, but I hadn't realized that it had been rolled into 1.6. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!