I have an application which I can't deploy or run in Tomcat because as soon as I attempt to start Tomcat in Eclipse (with this application configured in Add/Remove Project), I get this error:
Could not publish to the server.
org.eclipse.wst.common.componentcore.internal.flat.FlatFile cannot be cast to org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder
This happens on starting, publishing, and cleaning the Tomcat server in Eclipse, as long as my application is configured there. When I remove the application, I can publish fine.
What is this error about? I couldn't find any resources in Google.
Check for 'org.eclipse.wst.common.component' in your '.settings' folder in your maven project location. Check that the dependencies in that file are configured correctly. Make sure that a file (jar) is not added as a dependency at a placeholder for a folder.
I faced this issue when I added jar dependencies which were sibling modules to my project. I removed the 'dependency' tags and let maven configure the deployment descriptor for me automatically.
This worked for me and I cannot seem to find any other resource on google for this.
Related
I'm trying to migrate a maven project from Eclipse to IntelliJ and would like to start/run/deploy to WebSphere portal.
My problem is that Eclipse IDE allows multiple open projects and one of the projects is an EAR that deploys a war file to WebSphere portal.
Eclipse Project structure:
Websphere Artifact deployed:
So how can I achieve the same thing in IntelliJ IDE using the already installed WebSphere?
I already configured successfully Websphere Portal and I can start the server but I donĀ“t know what type of artifact I'm supposed to configure here because there's no EAR artifact because that was a project back in eclipse:
If I go to artifacts setting for WebSphere I can add the war file, but it is not deployed.
I have googled a lot about this in IntelliJ documentation, IBM documentation but there are no concrete solutions, at least that I have the knowledge to implement. I'm a bit new to IntelliJ. Can someone share a light on this please, thx.
If it is a Maven-based project - just open and import it from the main pom.xml in IntelliJ IDEA - IDE will automatically configure project structure.
If Maven project has corresponding configuration for ear artifact - IDE will automatically create the artifact of the same ear type which then you will deploy to an application server.
If you do not configure ear in Maven, you can create one manually, see examples in documentation.
The name of your artifact is important, even if deployed as an exploded-archive. The file (archive) or directory (exploded) must end with .ear, .war or .jar. The default name set by Intellij may not work.
myProject_ear/ is wrong
myProject.ear/ is correct
The deployment system of your application server is likely configured to only deploy files or directories ending with the correct file-type. This is especially true if the server is using the file scanner to detect modules to deploy or un-deploy.
I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.
I have an application which is able to run properly in tomcat, but when added a dependency of another application in maven I encountered the error below when deploying on Tomcat (the build works just fine):
java.lang.NoSuchFieldError: REFLECTION
There could be conflicts in the jars as imported by your application and as that are already present in the lib folder of tomcat directory.
Remove the duplicate jars from the lib folder tomcat directory. That may resolve the issue.
Teja: has maven shade helped you anyhow? I'm following a similar issue in Jetty now and I'm interested in trying different approaches. So far I've discarded different versions that may be adding noise.
I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.
I have a Java project using the Spring MVC framework and Maven as its build system. The primary IDE I wish to use is Eclipse for Java EE. I am using a standard Maven project structure for my application: source code is in src/main/java, resources for the application are in src/main/resources and code related to the web container are in src/main/webapp. In src/main/webapp/WEB-INF, I have a web.xml file for configuring my server and multiple folders for Spring-related files, such as context XML files and views. These Spring files are linked to legally in web.xml.
When I try to run the project using the Maven-Tomcat7-Plugin (via the mvn tomcat7:run-war goal), my project launches successfully and I am able to view my web pages and see my REST controller in action without issue.
However, when I try to run the project in Eclipse, using its Run As Server option, it never works and I have no idea why not. I keep getting an error dialog box titles Server Error and with the message The selection cannot be run on any server. I have already configured a Tomcat 7 server runtime legally in Eclipse; I can use this runtime without any problem for my other Java projects. I have tried everything that Google, Stackoverflow and blogs suggest to get an Eclipse Maven Spring project working on an Eclipse server. I've tried to delete the Eclipse project, delete the Eclipse-workspace files and reimport the project (both as a Maven project and as a regular Java project), but to no avail. I've also tried enabling the Dynamic Web Module in the Project Facets and setting the web directory to src/main/webapp, but also to no avail.
I'm baffled; I've worked with Tomcat servers in Eclipse many times before but it is just not working for this specific Spring project, even though it deploys just fine on Tomcat using Maven. Does anyone have any idea what might be going wrong? Have I forgotten a trouble-shooting step? Is there something wrong with my project setup that is conflicting with what Eclipse expects in a Web Server project? Thanks in advance.
I think I figured it out. There may be a bug in Eclipse's Dynamic Web Module, version 3.1. My project was being imported using this version because I am using version 3.1 of javax.servlet-api in my pom.xml. When I changed the version down to version 3.0, I am now able to run it as a server.
Basically, to do this change, I had to go into the .settings/org.eclipse.wst.common.project.facet.core.xml and change the <installed facet="jst.web" version="3.1"/> tag to instead be <installed facet="jst.web" version="3.0"/>.
Time to file a bug with Eclipse...