Finding a JAR that contains a class

Discussion in 'Java' started by laredotornado, Apr 22, 2010.

  1. 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
     
    laredotornado, Apr 22, 2010
    #1
    1. Advertising

  2. laredotornado

    markspace Guest

    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?
     
    markspace, Apr 22, 2010
    #2
    1. Advertising

  3. 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,
     
    Mike Schilling, Apr 22, 2010
    #3
  4. laredotornado

    Lew Guest

    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
    ....
     
    Lew, Apr 22, 2010
    #4
  5. laredotornado

    Tom Anderson Guest

    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/validation/ValidatorFactory.html

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

    http://findjar.com/jar/org/apache/g...geronimo-validation_1.0_spec-1.0-CR5.jar.html

    Which you can get from:

    http://mirrors.ibiblio.org/pub/mirr...-CR5/geronimo-validation_1.0_spec-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/tutorial/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.
     
    Tom Anderson, Apr 22, 2010
    #5
  6. laredotornado

    markspace Guest

    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.
     
    markspace, Apr 22, 2010
    #6
  7. laredotornado

    Tom Anderson Guest

    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
     
    Tom Anderson, Apr 22, 2010
    #7
  8. In article <>,
    Tom Anderson <> 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>
     
    John B. Matthews, Apr 23, 2010
    #8
  9. laredotornado

    markspace Guest

    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.
     
    markspace, Apr 23, 2010
    #9
  10. laredotornado

    Guest

    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
     
    , Apr 23, 2010
    #10
  11. laredotornado

    Tom Anderson Guest

    On Thu, 22 Apr 2010, John B. Matthews wrote:

    > In article <>,
    > Tom Anderson <> 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


    What i really want is a script which searches the contents of jars. So if
    i know i have a resource bundle somewhere in the hojillions of jars which
    make up my app that has a key 'crucialMessage', i can find it without
    having to know what the file it's in is called.

    I think i wrote such a thing as a script at some point; it's not exactly
    rocket science. But i don't know where i put it, and i'd like something
    that's a bit more efficient than unzipping every jar in turn and then
    grepping the results.

    tom

    --
    No man ever steps in the same river twice, for it's not the same river
    and he's not the same man. -- Heraclitus
     
    Tom Anderson, Apr 23, 2010
    #11
  12. laredotornado

    Tom Anderson Guest

    On Thu, 22 Apr 2010, markspace wrote:

    > 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.


    Oh, certainly, there was nothing wrong with your script at all, and for
    someone who's not in the groove of regular shell scripting to write
    something that works at all in five minutes is pretty good!

    I only got into read-while loops quite recently myself, so i still like to
    pimp them to people who perhaps could benefit from them.

    tom

    --
    No man ever steps in the same river twice, for it's not the same river
    and he's not the same man. -- Heraclitus
     
    Tom Anderson, Apr 23, 2010
    #12
  13. laredotornado

    markspace Guest

    Tom Anderson wrote:
    >
    > What i really want is a script which searches the contents of jars. So
    > if i know i have a resource bundle somewhere in the hojillions of jars
    > which make up my app that has a key 'crucialMessage', i can find it
    > without having to know what the file it's in is called.



    I had to use "unzip" to get a pipe for grep, but unzip is available on
    Cygwin and is part of the GNU packages, so it should be available to
    most folks, so try this, renamed to "jargrep":

    $ cat jargrep
    #!/bin/bash

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

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

    for jar in $jars; do
    files=`unzip -Z -1 $jar`
    for content in $files; do
    if unzip -p $jar $content | grep --binary --label=$jar "$2"; then
    echo JAR: $jar RESOURCE: $content
    fi
    done
    done
     
    markspace, Apr 23, 2010
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyril
    Replies:
    2
    Views:
    3,947
    cyril
    Aug 25, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    631
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,790
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,868
    Roedy Green
    Feb 14, 2006
  5. Joseph Turian
    Replies:
    5
    Views:
    627
Loading...

Share This Page