I'm trying to run example of web-app with use of Spring MVC on Spring tool Suite 3.3. I found someone who explains step by step how to do it, but at some point he wrote:
b) Right click on spitter-web project, select Properties>Deployment
Assembly
-Add... Folder "/src/main/webapp", Deploy Path is /
Unfortunately there isn't Properties>Deployment Assembly option in my STS - he used 2.8.1 version. Where I can find that option, or it was renamed ?
Properties is usually at the bottom of the drop down list when right clicking a project.
Alternatively, right click project, then go "build path" -> "configure build path". A new menu will come up, and if you look on the left hand side, you should see deployment assembly there.
Related
I learning Java Spring Framework by listening to
the "Spring & Hibernate for Beginners" udemy course.
I struggled while trying to
import org.springframework.context.support.ClassPathXmlApplicationContext;
Eclipse shows me the error:
ClassPathXmlApplicationContext cannot be resolved
The author of the course to which I'm listening is still not involving Maven
(and pom.xml) because he is concentrating on
"pure" Java and Spring in his course,
so please don't direct me to use Maven for organizing the project.
I added all jars from spring-framework-5.0.2.RELEASE-dist to my projects buildpath.
The funny thing is that when i do CTRL+Shift+O Eclipse automatically imports
the org.springframework.context.support.ClassPathXmlApplicationContext package,
but it shows error in import line (red line under org)
and shows an error in my main function
on the line where I try to use context as:
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Please help.
I just want to share that Ш have found a solution to my problem.
My execution environment JRE was set to be JAVA SE 10. After I change it to be JAVA SE 1.8 everything started working, and no errors are showing now.
I do it like this:
Right click on your project, then open Properties
Java build path
Click on Add Library
Choose JRE system library
Click on environments and choose JAVA SE 1.8
After that, I removed JAVA SE 10 from my build path and everything becomes right.
Delete the module-info.java file in your project, It's only used if you're using Java's built-in module system.
Hope that helps:)
I would check the following:
a. right click the project -> properties -> Java Build Path -> Libraries (tab)
Make sure spring-context jar is present and there is only one version of it.
If that is the case, try closing and reopening the IDE.
I solved this problem in intelliJ by doing the following:
File > Project Structure
Modules
Dependencies Tab
Click (+) button
Add JARs or Directories
Navigate to the correct .jar to import ClassPathXmlApplicationContext
Because I have been using maven in the past, I already had the .jar file downloaded. My .jar file was at the following location on my drive:
home folder
Unhide hidden folders
.m2 folder
repository > org > springframework > spring-context > 5.2.4 RELEASE
Select .jar file
I also had to import the "spring-beans" and "spring-core" libraries to get the code to run in my environment.
Step 1: Right Click your Project --> move mouse to "Build Path" tab
Step 2: Choice "Configure Build Path"
Step 3: on tab "Libraries" and click "Classpath". If "Classpath" is empty, it mean you still not add .jar and can't import ClassPathXmlApplicationContext.
How to:
create a new folder equal level src. i suggest name folder is "lib".
Download .jar file and copy to folder lib.
Follow step 3 above and click "Add jar" on right tab and choice .jar file on "lib" folder.
Finish and enjoy!
I am developing a plugin for IntelliJ as part of a larger research team. The logic for the plugin was developed and tested as a Java project in IntelliJ IDEA. Now the time has come to develop the front end, and the module is not configured as a plugin. How should I go about converting the Java project to a plugin project?
It is not reasonable to start the project over as a plugin project, because it has complex dependencies on several other modules.
This is a similar question to how to import existing plugins, but is different because the code is not a plugin yet.
These are the steps I have followed so far:
Create a new action class (that extends AnAction) to be the main class for the plugin.
Create a run configuration for the plugin. I get this error: Run Configuration Error: No plugin module specified for configuration
Follow the instructions given by OpherV in the question I linked to above to change type="JAVA_MODULE" to type="PLUGIN_MODULE" in the .iml file.
The third step did not resolve the "Run Configuration Error: No plugin module specified for configuration issue." What additional steps are needed?
I am using IntelliJIDEA (Community Edition) 14.1.4 Build #IC-141.1532 on OSX 10.11.1.
I was able to successfully convert the project into a plugin by following these additional steps:
Create a META-INF directory in the root of the project. Inside of this directory create the plugin.xml file. In plugin.xml, register your action. See the IntelliJ code samples for examples of what this file should look like.
Right-click on your project root in the project view (Cmd-1 if it’s not open already) and choose “Open Module Settings” (Cmd-down). This will open Project Structure > Modules > Dependencies.
5.1. Alternately, you can get here by opening the Project Structure with Cmd-; and then choosing Modules and picking your project from the list and going to the Dependencies tab.
Make sure the module SDK is the IntelliJ Community Edition instead of the normal Java 1.8 (or whichever version you have). (I noticed that this changed a line in the .iml file, but you should change the SDK here so you can create it as described here.)
At the bottom of the dependencies window, there is a plus. Click it, and follow the instructions given by samkass in the answer to this question, which I will reiterate here with more context-specificity for ease of following them:
7.1. Once you have clicked on the plus button, select “Jars or directories…”
7.2. Navigate to the META-INF folder, select it, and click OK
7.3. In the dialog that comes up, select “classes” and NOT “jar directory”
7.4. Make sure you’re using that Module in your run target
Once I followed all of these steps, the "Run Configuration Error: No plugin module specified for configuration issue" went away and the Run Configuration I had created worked. I ran it and my action was available in the Refactoring menu as I had registered it in plugin.xml.
I'm trying to do an initial setup with Hibernate in Eclipse, while deploying with Tomcat.
I encountered the following problem:
java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
db.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
db.HibernateUtil.<clinit>(HibernateUtil.java:8)
I've goggled my problem online and I understand that it has something to to with the project class path.
I've added a user library to my project containing all the jars under the "required" directory in the hibernate download, but that doesn't seem to work.
Please find a screen shot of my project here:
You're getting the error because the hibernate libraries are not available to Tomcat. In your picture, below the hibernate library set there is an empty set called 'Web App Libraries' - this is the set your hibernate libraries need to be in.
Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path. Now import the jars into the WEB-INF/lib folder. Refresh your project and now you should see them listed in the 'Web App Libraries' set (i appreciate this is somewhat annoying that you have to import them into your code base - someone else might know a better way to do this that doesn't involve copying the jars in)
This error can happen when your jar files has not been exported with your web archive. You can do what #Chris White has said or you can follow below steps if you are using Eclipse.
Right click the project -> Build Path -> Configure Build Path
In the list at left side click on Deployment Assembly. Click "Add" button. Select "Java Build Path Entries" and click next. Now select your hibernate jar files or library. Click finish. Then click Ok.
Restart the server if necessary.
Simpler way than Chris White's way.
You're getting the error because the hibernate libraries are not available to Tomcat. Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path.
Do the same stuff, but instead of importing the jars everytime for a new project, **copy the required hibernate jars in lib folder of Apache Tomcat **(or whatever the server u are using).
You don't have the hibernate jar present in your library folder
Visit the below link for the possible solution, http://www.smashplus.info/2012/11/javalangnoclassdeffounderror.html
To achieve the same with IntelliJ :
File -> Project Structure
Project Settings -> Artifacts
Select your .war artifact
expand Available Elements
right click the Hibernate lib -> Put into /WEB-INF/lib
Done.
I'm learning SpringMVC framework and checked out a copy of their code:
https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/
I can do maven build, install and everything. But on Eclipse, run on server option never appeared. I have tomcat server up and running, also got plugin for eclipse. Why run on server option is missing? This is a Ubuntu machine.
When I tried the exact same thing on my Windows machine, everything was fine. It has the same version of eclipse and all sorts of plugins installed as the Ubuntu machine. I was able to launch it from Eclipse "run on server" option there.
Can someone help me to figure out why? Thanks.
Did you create a Web Project? If you right click on the project and go to Properties > Project Facets is Dynamic Web Module selected?
I had a similar issue. The Maven projects have different structure than "Dynamic Web Projects". Eclipse knows only how to deploy the Dynamic Web Projects (project structure used by Web Tools Platform).
In order to solve this and tell Eclipse how to deploy a "maven style" projects, you have to install the M2E Eclipse WTP plugin (I suppose you are already using the m2e plugin).
To install:
Preferences->Maven->Discovery->Open Catalog and choose the WTP plugin.
After reinstalling, you will be able to "run on server" those projects which are maven web projects.
Hope that helps,
The topic is old but today I was facing the same problem, I imported a Maven project and when I tried adding to Tomcat it did not show the project. What worked for me:
Properties >> Project Facets and then check the options: Dynamic Web Module + Java then click in apply.
I hope it helps :)
For me worked:
Right click on project > Properties > Project Faces > change Configuration from "custom" to "Default configuration for Apache Tomcat v7.0" > OK and then Run on Server option has appeared.
Follow the below steps:
1) Right click on your maven project.
2) Select Maven
3) Update Project
4) check the
update project configuration from pom.xml
refresh workspace resources from local filesystem.
clean projects.
That's it.
Do you see any servers in server view in eclipse? Probably simply you have not created any server instances.
Perhaps you lost some configuration, check jar dependencies in properties -> Deployment Assembly. If you miss something, try to add dependencies again.
in my case, fixing this, Run on Server appear again.
There is only 1 thing that fixed this for me. In the pom.xml, add the tag:
<packaging>war</packaging>
Then after saving that, when you right click on the project you should now see the "Run As... Run on Server" option showing up.
I had to do the following
remove /WebContent from Deployment Assembly and add /src/main/webapp
Add Library (Properties->Java Build Path->Libraries), Server Runtimes
This got me working, in addition to #alanbartczak answer.
we have to install the M2E Eclipse WTP plugin
To install: Preferences->Maven->Discovery->Open Catalog and choose the WTP plugin.
And restart eclipse
I was facing similar issue when i created a new workspace in STS.
Project => right click => Maven option was also missing.
I tried this below steps and it worked.. hope it helps someone else.
Project => right click => configure => convert to maven project and then the option to run on server appeared.
Right click on the project, go to "Run as", select "Run configurations" and create a run configuration.
I've installed the m2eclipse plugin with WTP integration in my eclipse workbench. When I use to run the project on a server, the dependencies which has to be provided at runtime (e.g. spring) are not deployed. Is this working like intended? Maybe some of you can provide me the right way.
Is this working like intended?
No.
Maybe some of you can provide me the right way.
Not with the level of detail you provided (like your POM, especially your spring dependency, your eclipse version, the m2eclipse version...).
P.S. On the basis of your wording, I suspect that you are using a runtime scope for some dependencies and you could face MNGECLIPSE-1231. If you do so for the Spring artifacts, then I don't know why and I'd suggest to use the default scope. But this is a big guess.
Right click on your project, select "Properties"
From the properties menu click "Deployment Assembly"
Click "Add" -> "Java Build Path Entries" then click "Next"
Select "Maven Libraries" on the list and click "Finish"