Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Finding a JAR that contains a class

Reply
Thread Tools

Finding a JAR that contains a class

 
 
laredotornado
Guest
Posts: n/a
 
      04-22-2010
Hi,

I'm running Java 1.6 on a Tomcat 6.0.26 server. I'm getting a
ClassNotFoundException, comlpaining about
javax.validation.ValidatorFactory. What JAR file is this included in
and is there a generic web site I can visit that will tell me class-
JAR relations and download sites?

Thanks, - Dave
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      04-22-2010
laredotornado wrote:
> Hi,
>
> I'm running Java 1.6 on a Tomcat 6.0.26 server. I'm getting a
> ClassNotFoundException, comlpaining about
> javax.validation.ValidatorFactory. What JAR file is this included in



If it's "javax" then it should be Sun:

<http://java.sun.com/javaee/6/docs/api/javax/validation/ValidatorFactory.html>

JEE thing perhaps?

 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      04-22-2010
laredotornado wrote:
> Hi,
>
> I'm running Java 1.6 on a Tomcat 6.0.26 server. I'm getting a
> ClassNotFoundException, comlpaining about
> javax.validation.ValidatorFactory. What JAR file is this included in
> and is there a generic web site I can visit that will tell me class-
> JAR relations and download sites?


Google

This appears to be part of JSR 303, so look for an implementation of that,


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      04-22-2010
laredotornado wrote:
>> I'm running Java 1.6 on a Tomcat 6.0.26 server. *I'm getting a
>> ClassNotFoundException, comlpaining about
>> javax.validation.ValidatorFactory. *What JAR file is this included in

>


markspace wrote:
> If it's "javax" then it should be Sun:
>


Then it has to be Sun. OP: If you see that the package begins with
'java.' or 'javax.', it's part of the Standard API and you should look
in those Javadocs.

Otherwise GIYF.
<http://www.google.com/search?q=javax.validation.ValidatorFactory>

> <http://java.sun.com/javaee/6/docs/api/javax/validation/ValidatorFactory.html>
>
> JEE thing perhaps?


$ find /cygdrive/c/java/jdk1.6.0_20/ /cygdrive/c/java/glassfish/ -name
\*.jar \
| xargs grep ValidatorFactory
Binary file /cygdrive/c/java/jdk1.6.0_20/jre/lib/rt.jar matches
....
Binary file /cygdrive/c/java/glassfish/glassfish/modules/bean-
validator.jar matches
Binary file /cygdrive/c/java/glassfish/glassfish/modules/container-
common.jar matches
Binary file /cygdrive/c/java/glassfish/glassfish/modules/
jsftemplating.jar matches
....

$ unzip -l /cygdrive/c/java/jdk1.6.0_20/jre/lib/rt.jar
....
(Pattern not found)
....

$ unzip -l /cygdrive/c/java/glassfish/glassfish/modules/bean-
validator.jar
....
291 11-08-2009 20:49 javax/validation/
ValidationProviderResolver.class
1138 11-08-2009 20:49 javax/validation/Validator.class
524 11-08-2009 20:49 javax/validation/ValidatorContext.class
620 11-08-2009 20:49 javax/validation/ValidatorFactory.class
....
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      04-22-2010
On Thu, 22 Apr 2010, laredotornado wrote:

> I'm running Java 1.6 on a Tomcat 6.0.26 server. I'm getting a
> ClassNotFoundException, comlpaining about
> javax.validation.ValidatorFactory. What JAR file is this included in
> and is there a generic web site I can visit that will tell me class- JAR
> relations and download sites?


Funnily enough:

http://findjar.com/

That says:

http://findjar.com/class/javax/valid...orFactory.html

It's in geronimo-validation_1.0_spec-1.0-CR5.jar:

http://findjar.com/jar/org/apache/ge...0-CR5.jar.html

Which you can get from:

http://mirrors.ibiblio.org/pub/mirro...ec-1.0-CR5.jar

Before you go haring off to download that, i should point out that judging
by the class and jar name, that's part of the new JSR-303 Beans Validation
framework:

http://java.sun.com/javaee/6/docs/tu...doc/gircz.html

There may or may not be a vendor-specific version of it you should use in
concert with whatever app server, persistence framework, or whatever
you're using. I would guess it's an API class, though, in which case you
are almost certainly looking for something like validation-api.jar from
Sun, and not whatever that Geronimo thing above is.

tom

--
3.141592666666 and then it's just all sixes for the other 298 digits. Then
after that there's just hieroglyphs of scary eyes.
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      04-22-2010
Lew wrote:

>
> $ find /cygdrive/c/java/jdk1.6.0_20/ /cygdrive/c/java/glassfish/ -name
> \*.jar \
> | xargs grep ValidatorFactory



Great mind think alike, I suppose. I was having a hard time getting the
class name and the jar name together:

Brenden@Homer /cygdrive/c/Program Files/glassfish-v3-b68
$ find . -name "*.jar" -print0 | xargs -0 -I {} jar -tf {} | grep
ValidatorFactory

will find something, but it's not clear where it's finding it.

So a bit of bash shell scripting worked it out.

$ cat findit
#!/bin/bash

jars=`find . -name "*.jar"`

for i in $jars; do
# echo JAR: $i
jar -tf $i | grep ValidatorFactory
if [ $? == 0 ] ; then
echo JAR: $i
fi
done

The output of this script is:

$ ./findit
com/sun/messaging/jmq/jmsclient/validation/ValidatorFactory.class
JAR: ./glassfish/lib/install/applications/jmsra/imqjmsra.jar
javax/validation/ConstraintValidatorFactory.class
javax/validation/ValidatorFactory.class
org/hibernate/validation/engine/ConstraintValidatorFactoryImpl.class
org/hibernate/validation/engine/ValidatorFactoryImpl.class
org/hibernate/validation/util/LazyValidatorFactory.class
JAR: ./glassfish/modules/bean-validator.jar
com/sun/jsftemplating/component/factory/ri/ValidatorFactory.class
JAR: ./glassfish/modules/jsftemplating.jar
org/jboss/webbeans/bean/builtin/DefaultValidatorFactoryBean.class
JAR: ./glassfish/modules/webbeans-osgi-bundle.jar
com/sun/messaging/jmq/jmsclient/validation/ValidatorFactory.class
JAR: ./mq/lib/imq.jar

So yes it's in glassfish/modules/bean-validator.jar for me too.

I think this implies that other containers might use a different .jar
however. JBoss, Weblogic, etc. might supply their own implementation
elsewhere, so the script above might be handy for the OP.
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      04-22-2010
On Thu, 22 Apr 2010, markspace wrote:

> Lew wrote:
>
>> $ find /cygdrive/c/java/jdk1.6.0_20/ /cygdrive/c/java/glassfish/ -name
>> \*.jar \
>> | xargs grep ValidatorFactory

>
> Great mind think alike, I suppose. I was having a hard time getting the
> class name and the jar name together:


The handy fact you're missing is that jar files store filenames
uncompressed. You don't need to do jar -tf - you can just grep over the
file. So:

find $SOMEWHERE -name \*.jar -print0 | xargs -0 grep -l ValidatorFactory

Will give you the names of the matching jars. No script needed!

If you wanted jar names and filenames, probably the easiest thing (IMHO)
is a while-read loop:

find $SOMEWHERE -name \*.jar -print0 | xargs -0 grep -l ValidatorFactory | while read jarfile; do echo $jarfile $(jar tf $jarfile | grep ValidatorFactory); done

Saves having to put all the jar names into a variable. But does read each
jar twice.

> So a bit of bash shell scripting worked it out.
>
> $ cat findit
> #!/bin/bash
>
> jars=`find . -name "*.jar"`
>
> for i in $jars; do
> # echo JAR: $i
> jar -tf $i | grep ValidatorFactory
> if [ $? == 0 ] ; then


Kids today! Nobody remembers that the original use of if was directly on
exit statuses:

if jar -tf $i | grep ValidatorFactory
then
whatever
fi

> I think this implies that other containers might use a different .jar
> however. JBoss, Weblogic, etc. might supply their own implementation
> elsewhere


For JBoss 6.0.0.M2, it's $JBOSS_HOME/common/lib/validation-api.jar.

Which is actually exactly what i hypothesised earlier - christ, you know
you've been in the game too long when you can guess the name of the jar
just by looking at the class name.

tom

--
The world belongs to the mathematics and engineering. The world is as
it is. -- Luis Filipe Silva vs Babelfish
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      04-23-2010
In article <(E-Mail Removed) i>,
Tom Anderson <(E-Mail Removed)> wrote:

> > So a bit of bash shell scripting worked it out.
> >
> > $ cat findit
> > #!/bin/bash
> >
> > jars=`find . -name "*.jar"`
> >
> > for i in $jars; do
> > # echo JAR: $i
> > jar -tf $i | grep ValidatorFactory
> > if [ $? == 0 ] ; then

>
> Kids today! Nobody remembers that the original use of if was directly on
> exit statuses:
>
> if jar -tf $i | grep ValidatorFactory
> then
> whatever
> fi


Now, with more parameters!

#!/bin/sh

if [ $# != 2 ]; then
echo "Usage: `basename $0` path string"
exit 1
fi

jars=`find $1 -name \*.jar`

for i in $jars; do
if jar -tf $i | grep $2; then
echo JAR: $i
fi
done

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      04-23-2010
Tom Anderson wrote:

> find $SOMEWHERE -name \*.jar -print0 | xargs -0 grep -l ValidatorFactory
> | while read jarfile; do echo $jarfile $(jar tf $jarfile | grep
> ValidatorFactory); done
>


Nice one!

>
> Kids today! Nobody remembers that the original use of if was directly on
> exit statuses:


Thanks for pointing that out. I admit I did that script while reading
the bash scripting How-To. Overall I think it wasn't bad for five
minutes of study and trial and error. I so seldom write shell scripts,
nothing sticks in my brain.
 
Reply With Quote
 
vincentdeygas@gmail.com
Guest
Posts: n/a
 
      04-23-2010

Hy,

I suggest you this site http://www.jarvana.com/jarvana/

You can use Jarvana site to search for classes and their associated
jar files to resolve NoClassDefFoundError and ClassNotFoundException
issues.
Source code and javadocs can be viewed when available.

Classes, artifacts, and content in the maven central repository are
searchable. You can obtain dependency information for classes and
artifacts, inspect POM files, and inspect plugins.

Vince
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
instanciate a class in a jar file with class.forname, while my main class is in another jar cyril Java 2 08-25-2004 06:55 AM



Advertisments