Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Servlet class files not included in exported war
Servlet class files not included in exported war [message #227679] Wed, 11 February 2009 20:25 Go to next message
Rich Scott is currently offline Rich ScottFriend
Messages: 63
Registered: July 2009
Member
I have a dynamic web project that I have been running using an embedded
tomcat server. It is running well and I tried to export it to a war file
so that I could deploy it. The resulting war did not include any class
files. It contained jars for all dependent modules in the lib director,
the classes directory contained empty directories for each package that
contained classes. I am using Ganymede 3.4.1 with WST 3.0.3 added.

I created all of the servlets using "new->class" rather than
"new->other->web->servlet" so I tried adding a new servlet through that
mechanism. Its class file is included in the war. I could re-add all of
the servlets using the servlet path and I suspect that will take care of
those. However, there a supporting POJO classes in the project that are
required, which I think will still be left behind.

Is there a better/alternative way to get the servlet classes included?

What do I need to do to include the support classes in the jar?

Thanks for you help
Rich
Re: Servlet class files not included in exported war [message #227686 is a reply to message #227679] Wed, 11 February 2009 21:07 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
It sounds like your POJO source files are not in the right location in the
web project. The default location is <project.dir>/src unless you changed
it at project creation or later in project properties.

Can you compare the location on disk of the original POJO source file with
the location of the source file created by the new source file wizard? It
doesn't matter which wizard you use to create a java source file, but the
location that the file is placed at does matter.

- Konstantin
Re: Servlet class files not included in exported war [message #227739 is a reply to message #227686] Thu, 12 February 2009 11:48 Go to previous messageGo to next message
Rich Scott is currently offline Rich ScottFriend
Messages: 63
Registered: July 2009
Member
Konstantin,

Thanks for the reply. Unfortunately all of the java source files (POJOs,
servlets added as classes, and the test servlet added as a servlet) reside
in packages stored under <project.dir>/src. Also, based upon another post,
I checked .settign/org.eclipse.wst.common.component and it correctly
identifies src as a wb-resource as shown below.

<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>

Any other ideas?

Rich

Konstantin Komissarchik wrote:

> It sounds like your POJO source files are not in the right location in the
> web project. The default location is <project.dir>/src unless you changed
> it at project creation or later in project properties.

> Can you compare the location on disk of the original POJO source file with
> the location of the source file created by the new source file wizard? It
> doesn't matter which wizard you use to create a java source file, but the
> location that the file is placed at does matter.

> - Konstantin
Re: Servlet class files not included in exported war [message #227762 is a reply to message #227739] Thu, 12 February 2009 14:30 Go to previous messageGo to next message
Rich Scott is currently offline Rich ScottFriend
Messages: 63
Registered: July 2009
Member
I went ahead and removed all of the servlets that were just added as
classes and then added new versions using "new->other->web->servlet". This
fixed the problem. Not only are the servlets all now being exported, the
POJOs that they reference are exported. It looks like some dependency
checking is occurring on export to WAR.

Thanks for your help.
Re: Servlet class files not included in exported war [message #1386485 is a reply to message #227762] Tue, 17 June 2014 19:03 Go to previous message
Palmer Eldritch is currently offline Palmer EldritchFriend
Messages: 40
Registered: February 2011
Member
Hmm - I run across the same snug - in my case it is after I converted my project to maven (partly manually). The project is deployed on JBoss fine locally (Right click > Run as ... > Run on server) but when I hit Export > WAR file the servlet classes do not come along in the ride.

Funny thing: if I clean the project then the classes are added in the target/ directory and are packaged in WEB-INF\lib\classes

EDIT: if I shut down the server and then hit Run on server I get resource not found - I need to clean the project, then clean the server in servers view to have it deployed (essentially to create the classes). Makes sense - so the only remaining question is why clean ?

The maven dependencies as well as the contents of the WEB-INF\lib folder end up in the war at WEB-INF\lib always - whether I clean or not - but only if I clean the project I see my classes.

What could be wrong ? Why is cleaning necessary ?

.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="target/classes" path="src">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 7.1 Runtime"/>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 7.1 Runtime JAVA7_25">
		<attributes>
			<attribute name="owner.project.facets" value="jst.web"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>


pom.xml
<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>gr.uoa.di.regas.monitoring.server</groupId>
	<artifactId>DataCollectionServlet</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.glassfish.web</groupId>
			<artifactId>javax.servlet.jsp.jstl</artifactId>
			<version>1.2.1</version>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>1.1.2</version>
		</dependency>
		<dependency>
			<groupId>net.lingala.zip4j</groupId>
			<artifactId>zip4j</artifactId>
			<version>1.3.1</version>
		</dependency>
	</dependencies>
	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<warSourceDirectory>WebContent</warSourceDirectory>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>


.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>DataCollectionServlet</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.wst.common.project.facet.core.builder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.wst.validation.validationbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.m2e.core.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
	</natures>
</projectDescription>



eclipse-kepler JEE
Win7 x64

[Updated on: Tue, 17 June 2014 21:11]

Report message to a moderator

Previous Topic:Web service generation and deployment issue
Next Topic:The content type in preference page can't change the default encoding?
Goto Forum:
  


Current Time: Fri Nov 28 21:01:57 GMT 2014

Powered by FUDForum. Page generated in 0.01836 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software