Could not find or load main class my-namespace.core

124 views
Skip to first unread message

Mark Watson

unread,
Jun 13, 2014, 11:12:46 AM6/13/14
to clojure-ma...@googlegroups.com
Maven newbie here, I need to convert my lein project to maven to integrate with TeamCity CI.

I can call  mvn clean install and it generates a .jar file.

However, when I try to run the jar file: java -jar target/my-app.jar

I get the message: Error: Could not find or load main class my-namespace.core

My namespace definition looks like:

(ns my-namespace.core
  (:gen-class))

And my pom.xml like:

    <build>
        <plugins>
            <plugin>
                <groupId>com.theoryinpractise</groupId>
                <artifactId>clojure-maven-plugin</artifactId>
                <version>1.3.20</version>
                <configuration>
                    <script>src/my-namespace/run.clj</script>
                    <testscript>test/my-namespace/run_test.clj</testscript>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>my-namespace.core</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>my-namespace.core</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>

        </plugins>
    </build>
What am I doing wrong? Thanks for any help!

Mark Derricutt

unread,
Jun 16, 2014, 9:59:25 PM6/16/14
to clojure-ma...@googlegroups.com
The '-' in the namespace gets replaced with '_' when compiled, so you're
main class would have to be `my_namespace.core`.

IMHO probably not best to use '-' in a namespace.

Mark
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure Maven Plugin" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure-maven-pl...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages