I googled my problem several times. Some of them was good, but not the solution for my problem. Since now, I took hours, to solve my problem.
I started a project in eclipse using maven. After that, I added spring and hibernate as dependencies. This project isnt a normal static void main() project. It is a plugin, which i can implement in an other running program.
Now let me explain my problem: When I try to start my plugin (FYI: putted it into /plugins folder of the main program), I get a I/O Exception:
org.bukkit.plugin.InvalidPluginException: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException:
class path resource [applicationContext.xml] cannot be opened because it does not exist
The applicationContext.xml is in my src/main/resources folder and also in my classpath. I checked it with winRar. After the build process, the applicationContext.xml was in the root directory. CLICK TO OPEN THE IMAGE
I also use the apache maven-shade-plugin, to include all my dependencys.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<mainClass>com.lostforce.core.LostForceCore</mainClass>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
The applicationContext.xml can be found! I checked it with
System.out.println("Is null: " + (getClassLoader().getResourceAsStream("applicationContext.xml") == null));
This returned false for me!
I load the applicationContext.xml with this code:
context = new ClassPathXmlApplicationContext("applicationContext.xml");
I dont know why it happens. All things I read about this problems, dont work.
My Project: CLICK TO OPEN THE IMAGE
A little checklist: - src/main/resource is in my classpath - applicationContext.xml is in the src/main/resource folder - build my proect with maven mvn: clean package - Use the maven-shade-plugin to include dependencys
Hope anyone can help me. Thank you