Velchester
Velchester

Reputation: 3

JSP class undefined type after project conversion to maven

Im trying to compile this project h__p://ross-warren.co.uk/my-twitter-clone-using-jsp-and-cassandra/

I have downloaded it, and spend almost one day searching for all dependency jar files and still I was not able to run that project. When I did some search I have discover maven. So I've downloaded it, in eclipse I click convert to maven or something, I've added some dependecy records to pom.xml and I still Im not able to run the project. There are some errors in jsp files. These errors werent there befoe.

for example in file LogChech.jsp

    <jsp:useBean id="User"    
    class="uk.co.ross_warren.litter.stores.UserStore"
    scope="session"
    ></jsp:useBean>

I have error Undefined type: UserStore. I dont know where is the problem but I think there is somethign wrong with packages, becase before project conversion I had all java files in packages (at least eclipse showed package icon) and now there is only normal folder icons and folder tree structure with all java files however the first line in java files is package something which is fine I think.

thank you for your help

EDIT

this is my pom.xml

   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Cinnamon</groupId>
  <artifactId>Cinnamon</artifactId>
  <version>0.0.1-SNAPSHOT</version>

      <dependencies>
          <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>1.6.4</version>
              </dependency>
              <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                        <version>1.6.4</version>
              </dependency>
              <dependency>
                        <groupId>me.prettyprint</groupId>
                        <artifactId>hector-core</artifactId>
                        <version>1.0-4</version>
              </dependency>
      </dependencies>
      <packaging>war</packaging>
</project>

This is the first image how it looked like before maven conversion http://oi39.tinypic.com/2q84o5z.

And this is how it looks like now http://oi44.tinypic.com/14nmgyf.

ok stack overflow says I cant submit images, so please take that url and add jpg extension to see image

Upvotes: 0

Views: 2087

Answers (1)

J&#246;rn Horstmann
J&#246;rn Horstmann

Reputation: 34014

The standard maven directory layout expects java sources to be in src/main/java and web resources in src/main/webapp. So your java sources directly in src weren't even compiled. These directories can be configured in the build section of your pom.xml. To set the directory for web resources you also have to configure the maven-war-plugin.

Edit: It seems you were also missing some dependencies, the pom below compiles without errors on the command line. I'm not an eclipse user myself but this should work in eclipse too.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Cinnamon</groupId>
    <artifactId>Cinnamon</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <directory>build</directory>
        <sourceDirectory>src</sourceDirectory>
        <outputDirectory>build/classes</outputDirectory>
        <!-- not used in your project -->
        <testSourceDirectory>srcTest</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>me.prettyprint</groupId>
            <artifactId>hector-core</artifactId>
            <version>1.0-4</version>
        </dependency>
        <dependency>
            <groupId>org.expressme</groupId>
            <artifactId>JOpenId</artifactId>
            <version>1.08</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.6.2</version>
        </dependency>
    </dependencies>
</project>

Upvotes: 1

Related Questions