Results 1 to 4 of 4

Thread: package org.springframework.context does not exist

  1. #1
    Join Date
    Jan 2010
    Posts
    124

    Arrow package org.springframework.context does not exist

    Hi,
    My web application works great without any errors. However, when i am trying to do same stuff using standalone application, i am getting hit with strange errors.

    Code file:
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;

    public class pure
    {
    public static void main(String[] args)
    {
    ApplicationContext context = new
    ClassPathXmlApplicationContext("*.xml");


    }
    }

    All my xml files are stored in the same directory as the above java file.
    My CLASSPATH points to all relevant spring jar files and java 1.6.X jdk jars

    Trial 1: When i try to compile the java program, i get error
    package org.springframework.context does not exist and similar errors on other packages and symbol not found errors etc

    Trial 2: I manually copied all jars to the same directory location where my java programme resides. I still get the same error

    Trial 3: But the errors seem to go away one by one when i incrementally start un jarring each of the spring jar files and all other dependent jar files.
    jar -xvf spring-beans-2.5.5.jar
    jar -xvf commons-logging-1.1.1.jar
    etc

    Note:One thing i noticed was the Manifest files donot have Main-Class attribute in all the jar files. So i am also not able to run the following command
    Java -jar spring-beans-2.5.5.jar

    How can i overcome these errors?
    I don't want to copy all the jars locally to my programme and i certainly don't want to un jar the dependent jar files.
    Whats my solution. I am new to Spring and also to Java.
    Thanks
    Sri

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Code:
    ClassPathXmlApplicationContext("*.xml");
    First time that I see the bold part in such way

    1) use code tags
    2) how are you trying to compile? with only javac command?, it seems yes,

    be sure to include all the long jars need it in your classpath for the javac
    command

    I suggest strongly work with ant

    3) the package is located in spring.jar if you work with 2.5.x series
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Jan 2010
    Posts
    124

    Default

    Dr pompeii,
    Thanks for suggesting me to use code tags. I will use it from here on.
    I am using maven for my web app builds. For my standalone app, since there is only one java file and remaining all are pre-built libraries, i wanted to give it a quick try with javac. Yes, i am using javac to compile my sources.

    I have followed your suggestion to include full path to Spring jars and it seems that this has worked before i got hit by another ClassNotFound exception. I have many jar files and i can't include a full path to all these jars in CLASSPATH env variable.

    Here are my questions
    a) Why can't i include a path to directory that includes all jar files in my CLASSPATH env? Why does it work, only when i give full path to each jar?
    b) I really cannot think of adding full paths to each and every jar my standalone app needs. IS there any better approach?

    Thanks
    Sri

  4. #4
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Sri

    a) Why can't i include a path to directory that includes all jar files in my CLASSPATH env? Why does it work, only when i give full path to each jar?
    Jdk 6 has a special option to handle this, but I used to work with ant

    I really cannot think of adding full paths to each and every jar my standalone app needs. IS there any better approach?
    Yes, ant

    But since you are working with maven you shouldn't had problems

    This is a problem not related with Spring itself, I suggest learn and work with ant
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •