I am working on a java plugin that utilizes Hibernate JPA for my database interactions. I am using a Hibernate configuration file to accomplish this task.
When I export my project into a jar file and run it, I get the following error:
[23:23:12] [Server thread/ERROR]: Error occurred while enabling nationsatwar v1.1 (Is it up to date?)
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at net.mcnations.nationsatwar.PluginMain_Load.onEnable(PluginMain_Load.java:31) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugin(CraftServer.java:493) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugins(CraftServer.java:407) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at net.minecraft.server.v1_16_R1.MinecraftServer.loadWorld(MinecraftServer.java:438) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at net.minecraft.server.v1_16_R1.DedicatedServer.init(DedicatedServer.java:219) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:810) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at java.lang.Thread.run(Thread.java:830) [?:?]
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
at java.net.URLClassLoader.findClass(URLClassLoader.java:436) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:167) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:96) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
With the actual error being thrown on this line of code:
SessionFactory factory = new Configuration().configure("hibernate.cfg.xml")
This immediately suggests my hibernate.cfg.xml file is not being exported in the project. I checked the project files in the export wizard, and I could not even find the configuration file in the window.
(Note the missing hibernate.cfg.xml file!!! (should be under the worldedit package))
Finally, in case its relevant, I am using the following dependency in my POM for Hibernate:
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.18.Final</version>
</dependency>
What am I doing wrong?
As stated Alex Funk in the comments:
java do not find org/hibernate/cfg/Configuration when trying to execute new Configuration
The problem is that the dependency is not packed into the jar file. Then, if you don't specify the .jar in the classpath and provide it at runtime, the JVM will not be able to create or access instances of classes of the dependency. In this case, the error indicates that the class org.hibernate.cfg.Configuration is not found. So you have two approaches:
Approach 1. Create a jar with the dependencies (Bigger .jar but recommended)
To do this you must override the maven assembly plugin and configure it the following way:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>jar-with-dependencies</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Then you can generate the jar via:
mvn install
Approach 2. Add the hibernate into the .jar classpath and provide it on runtime
I do not recommend this approach because it breaks one of the main advantages of plugins. The user will have to download the library and place it in a lib folder in its server. So the plug-in will require more installation steps by the end-user instead or just 'plugging in' the plugin in the server plugins folder.
The maven configuration will be:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.example.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Then in the server, users will have to provide the library jar into a lib folder inside the plugins folder:
MyServer
|--- plugins
| |--- lib
| |--- hibernate-core-5.4.18.Final.jar
| |--- YourPlugin-1.0.0.jar
|--- spigot-1.16.1.jar
... other server files and folders
Then execute:
mvn install
Let me know if this solves your problem!
Related
I am trying to create a .jar for my app. This app contains many things such as another .jar.
Using this plugin in my pom configuration :
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.rilent.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
And I have this link to a local jar
...
<dependency>
<groupId>it.sauronsoftware.jave</groupId>
<artifactId>jave</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jave-1.0.2.jar</systemPath>
</dependency>
I am using this command to build my app which returns BUILD SUCCESS :
mvn clean compile assembly:single
but when I try to execute my program, It crashes at some point returning this error :
Exception in thread "main" java.lang.NoClassDefFoundError: it/sauronsoftware/jave/InputFormatException
( a class from the .jar)
I tried decompressing my main jar to see its content :
what is wrong with the way I am creating my jar?
edit #Thorbjørn Ravn Andersen
I tried this way too, I added this to my pom :
<!-- https://mvnrepository.com/artifact/com.jolira/onejar-maven-plugin -->
<dependency>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
</dependency>
then I m compiling with mvn compile and when I try to run the .jar I get this error
no main manifest attribute, in .\myapp-0.0.1-SNAPSHOT.jar
what am I doing wrong again ...?
Note : My jar also contains a .exe
The standard classloaders cannot load classes from jars inside jars. EXE files cannot be run from inside jars.
This does not mean that it is impossible, but a bit cumbersome and perhaps above your current skill level. You might find One Jar (http://one-jar.sourceforge.net/) interesting as it automates exactly this.
For a Maven project I have had good experience with creating a deployment structure and scripts with appassembler. http://www.mojohaus.org/appassembler/appassembler-maven-plugin/
I'm making an eclipse plugin that I also want to make it work command line. As normal the usual problem is encountering the eclipse dependencies in command-line:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
Now I know there is an eclipse FAQ for this problem however here is a bit different. I'm using Maven for build with the maven-dependency-plugin to add jars I need from other project to this jar as dependencies:
<build>
<plugins>
<plugin>
<!-- Copy non-Eclipse plugins to target/dependency so that may be referenced
for runtime use. -->
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- seems the line below is needed otherwise every second run the
copy-dependencies fails , link to bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=393978 -->
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The dependencies in my Manifest file looks like this:
Rsrc-Class-Path: ./
lib/jcommon-1.0.23.jar
lib/jfreechart-1.0.19.jar
lib/jfreechart-1.0.19-swt.jar
lib/jfreechart-1.0.19-experimental.jar
lib/swt.jar
target/dependency/my.first.package.jar
target/dependency/my.second.package.jar
Class-Path: .
Rsrc-Main-Class: my.package.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Bundle-ClassPath: .,
lib/jcommon-1.0.23.jar,
lib/jfreechart-1.0.19-experimental.jar,
lib/jfreechart-1.0.19-swt.jar,
lib/jfreechart-1.0.19.jar,
lib/swt.jar
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
my.first.package;visibility:=reexport,
my.second.package;visibility:=reexport,
ca.odell.glazedlists,
org.eclipse.nebula.widgets.nattable.core,
org.eclipse.core.resources,
org.eclipse.swt
As you can see I added an swt.jar to a lib inside my project and am referencing it there as to have all my dependencies inside my jar.
Still I get the above error when I try to run it command line as if the swt.jar isn't there.
What am I missing?
If you want to make an Eclipse plugin command-line friendly, the best thing is to have the plugin also define an Eclipse application that you can then invoke from command-line: https://wiki.eclipse.org/FAQ_How_do_I_create_an_application%3F
I have read quite a few answers on this forum, so hopefully I am asking something.
Recently we moved to Tomcat 7 and usual procedure is to pick up a war file from Nexus repository, stick it in tomcat webapps dir and start the server and use it.
But due to war file artifact name in Nexus being my-app-war-1.0.war context path in tomcat is not what is expected. I know that this can be configured by context.xml, but I was wondering if there is a way to add ## to artifact name that is deployed in Nexus.
I tried changing #{project.build.finalName} but it only changes artifact name in target directory, maven deploy plugin still uses artifactId, which is 'my-app-war'. So artifact in Nexus ends up being 'my-app-war-1.0.war' As artifactId in maven has a quite strict structure and ## is not allowed there I was wondering what would be the right way of adding ## to artifact name, as we are very likely to consider to use parallel deployment, so I am looking for ways to enable this functionality.
I guess I could deploy two versions of the same war file to Nexus, one being named slightly different(with ##), but then it`s easier to just rename it and save some space. I wonder was there any plan how would the ## would be added to application name, when Parallel naming feature was implemented in Tomcat.
You can use <classifier> configuration of maven-war-plugin. This way your war will be installed to the repository with the name ${project.artifactId}-${project.version}-my-app-war.war
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<classifier>##my-app-war</classifier>
</configuration>
</plugin>
The problem is that Nexus returning the following error if you include in maven version ##.
Illegal character in fragment at index 103
You can enter in <path> by deploying to Apache7 the characters ## for the paralell deployment as folowing:
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<executions>
<execution>
<id>remote</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<mode>war</mode>
<path>/${project.artifactId}-##${project.version}</path>
<url>http://tomcat7.../manager/text</url>
<username>user</username>
<password>password</password>
<update>true</update>
</configuration>
</execution>
</executions>
</plugin>
My first use of Maven and I'm stuck with dependencies.
I created a Maven project with Eclipse and added dependencies, and it was working without problems.
But when I try to run it via command line:
$ mvn package # successfully completes
$ java -cp target/bil138_4-0.0.1-SNAPSHOT.jar tr.edu.hacettepe.cs.b21127113.bil138_4.App # NoClassDefFoundError for dependencies
It downloads dependencies, successfully builds, but when I try to run it, I get NoClassDefFoundError:
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonParseException
at tr.edu.hacettepe.cs.b21127113.bil138_4.db.DatabaseManager.<init>(DatabaseManager.java:16)
at tr.edu.hacettepe.cs.b21127113.bil138_4.db.DatabaseManager.<init>(DatabaseManager.java:22)
at tr.edu.hacettepe.cs.b21127113.bil138_4.App.main(App.java:10)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonParseException
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 3 more
My pom.xml is like this:
<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>tr.edu.hacettepe.cs.b21127113</groupId>
<artifactId>bil138_4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>bil138_4</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Can anyone help me?
By default, Maven doesn't bundle dependencies in the JAR file it builds, and you're not providing them on the classpath when you're trying to execute your JAR file at the command-line. This is why the Java VM can't find the library class files when trying to execute your code.
You could manually specify the libraries on the classpath with the -cp parameter, but that quickly becomes tiresome.
A better solution is to "shade" the library code into your output JAR file. There is a Maven plugin called the maven-shade-plugin to do this. You need to register it in your POM, and it will automatically build an "uber-JAR" containing your classes and the classes for your library code too when you run mvn package.
To simply bundle all required libraries, add the following to your POM:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
Once this is done, you can rerun the commands you used above:
$ mvn package
$ java -cp target/bil138_4-0.0.1-SNAPSHOT.jar tr.edu.hacettepe.cs.b21127113.bil138_4.App
If you want to do further configuration of the shade plugin in terms of what JARs should be included, specifying a Main-Class for an executable JAR file, and so on, see the "Examples" section on the maven-shade-plugin site.
when I try to run it, I get NoClassDefFoundError
Run it how? You're probably trying to run it with eclipse without having correctly imported your maven classpath. See the m2eclipse plugin for integrating maven with eclipse for that.
To verify that your maven config is correct, you could run your app with the exec plugin using:
mvn exec:java -D exec.mainClass=<your main class>
Update: First, regarding your error when running exec:java, your main class is tr.edu.hacettepe.cs.b21127113.bil138_4.App. When talking about class names, they're (almost) always dot-separated. The simple class name is just the last part: App in your case. The fully-qualified name is the full package plus the simple class name, and that's what you give to maven or java when you want to run something. What you were trying to use was a file system path to a source file. That's an entirely different beast. A class name generally translates directly to a class file that's found in the class path, as compared to a source file in the file system. In your specific case, the class file in question would probably be at target/classes/tr/edu/hacettepe/cs/b21127113/bil138_4/App.class because maven compiles to target/classes, and java traditionally creates a directory for each level of packaging.
Your original problem is simply that you haven't put the Jackson jars on your class path. When you run a java program from the command line, you have to set the class path to let it know where it can load classes from. You've added your own jar, but not the other required ones. Your comment makes me think you don't understand how to manually build a class path. In short, the class path can have two things: directories containing class files and jars containing class files. Directories containing jars won't work. For more details on building a class path, see "Setting the class path" and the java and javac tool documentation.
Your class path would need to be at least, and without the line feeds:
target/bil138_4-0.0.1-SNAPSHOT.jar:
/home/utdemir/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.6/jackson-core-asl-1.9.6.jar:
/home/utdemir/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.6/jackson-mapper-asl-1.9.6.jar
Note that the separator on Windows is a semicolon (;).
I apologize for not noticing it sooner. The problem was sitting there in your original post, but I missed it.
You have to make classpath in pom file for your dependency. Therefore you have to copy all the dependencies into one place.
Check my blog.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>$fullqualified path to your main Class</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
This is due to Morphia jar not being part of your output war/jar. Eclipse or local build includes them as part of classpath, but remote builds or auto/scheduled build don't consider them part of classpath.
You can include dependent jars using plugin.
Add below snippet into your pom's plugins section
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
For some reason, the lib is present while compiling, but missing while running.
My situation is, two versions of one lib conflict.
For example, A depends on B and C, while B depends on D:1.0, C depends on D:1.1, maven may
just import D:1.0. If A uses one class which is in D:1.1 but not in D:1.0, a NoClassDefFoundError will be throwed.
If you are in this situation too, you need to resolve the dependency conflict.
I was able to work around it by running mvn install:install-file with -Dpackaging=class. Then adding entry to POM as described here:
Choosing to Project -> Clean should resolve this
I'm using proguard with a spring mvc application and maven.
My pom.xml's build section looks like:
<build>
<finalName>myapp</finalName>
<plugins>
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<!--<options>-->
<!--<option>-keep public class</option>-->
<!--</options>-->
<injar>${project.build.finalName}</injar>
<injar>${project.build.finalName}</injar>
<inFilter>com.myapp.*</inFilter>
</configuration>
</plugin>
</plugins>
I also tried:
<injar>${project.build.finalName}.war</injar>
When I run:
mvn clean install
Build failure message:
[proguard] Reading program war [/Users/me/dev/git/myproject/myapp/target/myapp.war] (filtered)
[proguard] Error: The input doesn't contain any classes. Did you specify the proper '-injars' options?
ERROR] Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project myapp: Obfuscation failed (result=1) -> [Help 1]
It seems to have picked up my jar correctly as the messages before show:
[INFO] --- proguard-maven-plugin:2.0.4:proguard (default) # myapp ---
[INFO] execute ProGuard [-injars, '/Users/me/dev/gitserver/myproject/myapp/target/myapp.war'(!META-INF/maven/**,com.myapp.*), -outjars, '/Users/me/dev/git/myproject/myapp/target/myapp_pg.war', -libraryjars, ....
Also, what options do you suggest I use? This is a spring mvc so I have annotations like:
#Autowired
#Service
#Repository
#Controller
So any of those classes/fields should not be renamed I would imagine.
(My goal is just to make it a headache to someone who decompiles, such that they can't just decompile and use the code. Obfuscating will let them use it, but they won't be able to maintain the codebase unless they re-write it. I don't have any fancy algorithms so I have nothing really to hide in that respect.)
Update
Let me be clear here, my spring mvc using maven for some reason (I'm new to maven) when doing a mvn clean install produces both a myapp.war file and a exploded war myapp/ (this is what I want to deploy in production, not the myapp.war file)
My myapp folder has:
/target/myapp/
/target/myapp/meta-inf (empty folder)
/target/myapp/web-inf
/target/myapp/web-inf/classes (com.myapp. ...)
/target/myapp/web-inf/lib/
/target/myapp/web-inf/ web.xml, application.xml (for spring)
/target/myapp/web-inf/views/
So proguard should be obfuscating in the /target/myapp/web-inf/classes folder right?
How do I tell it to do so?
Update 2
I'm getting this now:
OK, I am not getting: failed to execute goal ...proguard .. Can't rename /Users/me/dev/git/project1/myapp/target/myapp/web-inf/classes (see my updates section for what I changed in my pom.xml)
I changed my pom.xml with:
<configuration>
<obfuscate>true</obfuscate>
<injar>${project.build.finalName}/WEB-INF/classes/</injar>
<inFilter>com/myapp/**</inFilter>
</configuration>
ProGuard filters work on file names, so
.....(!META-INF/maven/**,com.myapp.*)
probably won't match any class files. You probably want
.....(!META-INF/maven/**,com/myapp/**)
See ProGuard manual > Usage > File Filters
Can you post your entire pom?
Normally, Maven compiles to /target/classes (Even for WAR files) and the WAR plugin does the copy to web-inf/classes right before the package phase. You should not be manually compiling classes to web-inf/lib with Maven.
EDIT: OK this has take quite a bit of research, but I've found an answer for you. First, according to the ProGuard documentation, you should not have ANY classes in your war project:
Notably, class files that are in the WEB-INF/classes directory in a
war should be packaged in a jar and put in the WEB-INF/lib directory
You need to refactor your project so your web classes are built in a separate jar. Once you have built that jar project, you must add it as a dependency in your war project.
Once I created that setup, I was successfully able to build a war project with the following configuration:
<build>
<plugins>
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<inFilter>com/example/**</inFilter>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
<options>
<option>-keep class com.example.echo.EchoServlet</option>
<option>-injar ${project.build.directory}/${project.build.finalName}.${project.packaging}</option>
<option>-outjar ${project.build.directory}/${project.build.finalName}-proguarded.${project.packaging}</option>
</options>
</configuration>
</plugin>
</plugins>
</build>
Note the "com.example.echo.EchoServlet". Since progaurd was going to change the name of my classes, I had to "keep" this servlet name so I could reference it in the WAR project's web.xml. If you use annotation based servlet configuration, I imagine this won't be necessary.