Eclipse's "serve modules without publishing" equivalent in IntelliJ - java

When I checked the "serve modules without publishing" in eclipse,eclipse would add all of my maven dependencies to context xml like
And the tomcat would run with adding this jars to command line classpath.
But in Idea,I set deployment to exploded,all of my maven dependencies were copided to output/WEB-INF/lib
Project Structure
How can i acheive running tomcat without coping maven dependencies?

Related

to make maven project to dynamic web project so that i can debug in eclipse

I am having 4 maven project they are project_1, project_2, project_3, project_4
here project_1 is having project_2 jar in its dependency along with other dependency jars
project_2 is having project_1 jar in its dependency along with other dependency jars
project_3 is having project_1 jar and project_4 jar in its dependency along with other dependency jars
project_4 is having project_1 jar and project_2 jar in its dependency along with other dependency jars.
The way i am running this project in wildfly is that i am putting all the projects mvn clean install jar inside DEMO.war of the wildfly
then i am deploying it and testing it .
i need convert this maven project to dynamic web project so that i can debug the project on eclipse how will i do it ?

How do we deploy the binary dependencies?

Let's say we have a simple Java project compiles into a simple.jar with its POM depends on log4j.jar. When I open the simple-1.0.jar, inside there is no log4j.jar. And then we upload this simple-1.0.jar onto Nexus.
Now when deploy this simple-1.0.jar to the target server, how do we deploy the log4j.jar?
Thanks
Jirong
You can either package the dependencies with your application (i.e. create an uber-jar, WAR, or EAR file) or you can deploy the dependent jars to a location on the server and then set that location as the classpath when you run the jar.
Packaging an application as an Uber-JAR
One way of creating an uber-jar with Maven would be to use the maven-shade-plugin
Deploying the dependent jars and setting classpath
In this scenario you would create a "libs" folder somewhere on the target machine and copy all of the dependent jars into this folder.
Then when you launch your application you would set the classpath like so:
java -classpath /{libs directory} -jar simple-1.0.jar
Multiple classpath entries can be specified by separating them with a : like also:
java -classpath /{directory1}:/{directory2} -jar simple-1.0.jar
You can have Maven list the resolved dependencies using the dependency plugin:
mvn dependency:list

Eclipse Luna, m2eclipse: empty dependency when dependency is a workspace project

I am working with Eclipse Luna.
I have a dynamic web project into my workspace: project-web. This project depends on another project into my workspace: project-lib.
So I get this scenario: project-web[:war] ---depends on--> project-lib[:jar]
I have checked "Resolve dependences from workspace projects" option into Properties -> Maven for the web project.
When I run "mvn clean package" for project-web Maven creates war file into the target directory but I have
an issue. If I explode the war file, I find an empty folder called "project-lib" into the WEB-INF/lib directory.
Since the library is empty I get some java exceptions on Tomcat startup.
How to create the war for project-web correctly?
Thanks in advance.
Enrico

Glassfish deployed project's dependency libraries

I'm new to Java and dependency management.
I have an EJB jar project with a few maven dependencies. When deploying the project to glassfish I get exceptions, that the classes from those dependencies are not found.
So I've added a maven plugin to copy over the dependencies from the local repository to {glassfish_dir}/glassfish/domains/domain1/lib every build.
I'm also using Netbeans.
Is copying over the the dependencies the proper way to go about this? Is there a better way to make dependencies work with glassfish?
The best way is to make the Maven pom.xml that builds the .war declare a dependency on your EJB jar project. That way your EJB jar and any libraries that it has a dependency on, will be included in the .war file that Maven builds.

IntelliJ NoClassDefFoundError for jar Dependencies in other Modules

I had a perfectly running Eclipse project with Maven and project dependencies. Now I want to switch to IntelliJ IDEA - the import of my projects worked nicely (now called module with Maven and module dependencies), all the Maven configuration seemed to work out of the box (can expand libs and see source code).
When I run my module I get:
Exception in thread "main" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/XStream
From a dependent module, xstream-1.4.2.jar is correctly in the build path of that module.
What I tried and did not work:
Importing projects as Eclipse projects, applying Maven nature/framework support afterwards
Importing projects as Maven projects
Invalidate caches
Maven Reimport & Generate Sources and Update Folders
What worked but is not a solution: I can add the xstream-1.4.2.jar to the dependencies of the module I am running, but then it fails with the next missing jar. So it seems as if it does not find the jars referenced in referenced modules.
Often one encounters the NoClassDefFoundError when there are two libs in different versions on the classpath - I double checked, there is only one xstream*.jar file there.
I appreciate any help.
Thank you, Marcel
Is xstream-1.4.2.jar located in the correct groupid/artificatid/1.4.2/ folder under .m2 repository?
If you are running on linux, .m2 will be located under /home//.m2
If you are running on Windows, .m2 folder will be located under C:\Users\.m2

Categories

Resources