Results 1 to 8 of 8

Thread: to be a physics scientist is easier than doing a hello world example in STS

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    4

    Default to be a physics scientist is easier than doing a hello world example in STS

    For 2 weeks I've been trying to make a very veeeeeeeeeeeerrrrrrrrrrrryyyyyyyy basic hello world example in STS MVC.
    okay,
    I use this
    File - New - Dynamic we project
    and then try to run it,
    I get this:
    Code:
    Dec 07, 2011 6:13:47 PM com.springsource.tcserver.security.PropertyDecoder <init>
    INFO: tc Runtime property decoder using memory-based key
    Dec 07, 2011 6:13:47 PM com.springsource.tcserver.security.PropertyDecoder <init>
    INFO: tcServer Runtime property decoder has been initialized in 187 ms
    Dec 07, 2011 6:13:48 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Dec 07, 2011 6:13:48 PM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init
    INFO: Started up JMX registry on 127.0.0.1:6969 in 68 ms
    Dec 07, 2011 6:13:48 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 786 ms
    Dec 07, 2011 6:13:48 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Dec 07, 2011 6:13:48 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.6.1.RELEASE/7.0.20.B.RELEASE
    Dec 07, 2011 6:13:48 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor EchoSpringMVC.xml from D:\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\spring-insight-instance\conf\Catalina\localhost
    Dec 07, 2011 6:13:48 PM org.apache.catalina.startup.SetContextPropertiesRule begin
    WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:EchoSpringMVC' did not find a matching property.
    Dec 07, 2011 6:13:48 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
    INFO: Context [localhost|EchoSpringMVC] will not be woven
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: org/apache/log4j/Level
    	at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
    	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
    	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
    	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
    	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:191)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    	at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    	... 18 more
    
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/EchoSpringMVC] startup failed due to previous errors
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.StandardContext listenerStop
    SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
    java.lang.ExceptionInInitializerError
    	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
    	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763)
    	at org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5473)
    	at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit
    	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
    	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
    	at org.springframework.web.context.ContextCleanupListener.<clinit>(ContextCleanupListener.java:43)
    	... 4 more
    
    Dec 07, 2011 6:13:49 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor insight.xml from D:\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\spring-insight-instance\conf\Catalina\localhost
    Dec 07, 2011 6:13:49 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
    INFO: Context [localhost|insight] will not be woven
    Dec 07, 2011 6:13:49 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    Dec 07, 2011 6:13:58 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
    Dec 07, 2011 6:14:00 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory manager
    Dec 07, 2011 6:14:00 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
    INFO: Context [localhost|manager] will not be woven
    Dec 07, 2011 6:14:00 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory ROOT
    Dec 07, 2011 6:14:00 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
    INFO: Context [localhost|ROOT] will not be woven
    Dec 07, 2011 6:14:01 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-bio-8080"]
    Dec 07, 2011 6:14:01 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 12564 ms
    why do I get these errors while I havn't added any thing to the project?
    it is the very basic thing and I can't pass it!
    please somebody help
    Last edited by AladdinHoms; Dec 7th, 2011 at 09:29 AM.

  2. #2

    Default

    This is more of a java-related problem. It has nothing to do with spring, or spring mvc. You do not have the log4j library in your classpath.

    Are you using maven or gradle? You should use some kind of a build system where you declare which libraries you are using, such as spring and spring mvc, and it should include your log4j dependency for you. If not, it's pretty easy to add log4j as a dependency.

    If you're not using maven, you'll have to download log4j, and then add the .jar file to your libraries.

    I use IntelliJ IDEA and not STS... I think you might have an easier time with that too.

    If you're new to Spring or even Java, I don't think this stuff is a good place to start. In fact, you might have a better chance of being productive by using Ruby and Rails or something like that.

    In any case, don't expect your knowledge of being a physics scientist to instantly translate into being an amazing java developer. It's an entirely different profession that requires a time commitment. I know physics people are actually expected to be decent programmers, but I never understood why they don't just pair up physics people with a software developer and have them pair program. Would be more efficient.
    Last edited by egervari; Dec 7th, 2011 at 12:26 PM.

  3. #3
    Join Date
    Dec 2008
    Location
    India
    Posts
    295

    Default

    add log4j jar into your classpath it will work.
    Enjoy
    Rohan Chauhan
    ------------------------------------------------------------------------------
    SpringSource Certified Spring 3.0 Professional


  4. #4
    Join Date
    Nov 2011
    Posts
    4

    Default

    Quote Originally Posted by rohan123 View Post
    add log4j jar into your classpath it will work.
    I wish I know how to!

  5. #5

    Default

    I would say learning about classpaths would be a good place to start This is knowledge you have to know before you start working with web containers and such things. The problem you're running into is not a spring mvc related problem at all - it is a classpath issue, and learning about your IDE.

    If you learn about Maven, which is a build tool, you will learn how to add log4j to your classpath automatically without having to get into the nitty-gritty details of how to do it. This is how most people build projects with Spring. Spring has a lot of libraries it depends on, and unless you know what those are in advance, you should use a tool like Maven to go download them and include them into your classpath on your behalf.

    I don't use eclipse/sts, but I'm sure there's a way to manually add jars to your classpath too. I use maven though because usually IDE's are smart enough to automatically include all of the necessary jars by simply reading in the maven pom.xml file.

    Personally, I think IntelliJ IDEA is easier to use too. I don't like STS. Maybe give that IDE a try. You may find it easier. I think they focus a lot more on usability.

  6. #6

  7. #7
    Join Date
    Nov 2011
    Posts
    4

    Default

    thank you @egervari,
    What previous knowledge should I have before I am ready to start learning Spring MVC?
    I know JAVA and OOP basics very well. what else do I need?

Posting Permissions

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