i am using spring 3.1.0.RELEASE, and my servlet container is tomcat 7 and my IDE is eclipse indigo
and the jar spring-webmvc-3.1.0.RELEASE.jar which contains the DispatcherServlet
exists in the lib folder, and yet when running the application, i am getting the exception:
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
please advise why i am getting this exception, and how to fix it.
EDIT: following are my configuration files:
1- .springBeans:
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.9.0.201203011806-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>src/main/webapp/WEB-INF/checkout-servlet.xml</config>
</configs>
<configSets>
</configSets>
</beansProjectDescription>
2- web.xml:
<web-app>
<display-name>Checkout</display-name>
<servlet>
<servlet-name>checkout</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>checkout</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
</web-app>
3- checkout-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.myapp"/>
<bean id="myService" class="com.myapp.MyService"/>
</beans>
also when trying to access any page in the application, i get the exception:
HTTP Status 404 - Servlet checkout is not available
type Status report
message Servlet checkout is not available
description The requested resource (Servlet checkout is not available) is not available.
Apache Tomcat/7.0.22
You need to add the "Maven Dependency" in the Deployment Assembly
right click on your project and choose properties.
click on Deployment Assembly.
click add
click on "Java Build Path Entries"
select Maven Dependencies"
click Finish.
Rebuild and deploy again
Note: This is also applicable for non maven project.
Two possible answers:
1- You did not include spring-beans and spring-context jars in your lib.
If you are using maven (which will help a lot) those two lines will be enough
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
2- The necessary jars are in your classpath but are not deployed on tomcat.
I had the same problem with Idea Intellij and Spring 4. I fixed the problem and I wanted to share the answer with you.
I use tomcat 7 / idea intellij 13 / spring 4.
pom.xml dependencies:
<properties>
<spring.version>4.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
enter code here
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
In idea Intellij, you need to go to File -> Project Settings -> Artifacts.
Then
clean -> rebuild the project -> build the artifact, and everything will be ok.
This solves the problem for me. It's easy and pretty simply explained.
Step 1
Right click on project
Click on Properties
Step 2
Click on Deployment Assembly Tab in the
Click Add...
Step 3
Click on Java Build Path Entries
Step 4
Click on Maven Dependencies
Click Finish button
Step 5
Redeploy Spring MVC application to Tomcat again
Restart Tomcat
List item
classnotfoundexception
i found that in the deployment assembly, there was the entry:
[persisted container] org.maven.ide.eclipse.maven2_classpath_container
i removed it, and added the maven dependencies entry, and it works fine now.
If all of these advice doesn't work, you should re-create your Server (Tomcat or like that). That solved my problem.
Include below dependency in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>{spring-version}</version>
</dependency>
I was facing the same Issue. When I saw into maven repository .m2 folder(....m2\repository\org\springframework\spring-webmvc) in my local I found two 3.2.0.RELEASE folders. SO I removed one.
Then I went to project, right click->properties->deployment essembly-> add maven dependencies.
clean build and then restart the server.
Then the DispatcherServlet got loaded.
Go to properties of Project which your working
Choose the Deployment Assembly menu and Click on add button
opt the Java Build Path Entries and Click on Maven Dependencies
Build the project and run
In my case I get this trouble after using the maven's update project utility.
I tried all the workarounds you suggested but nothing seemed to work.
At the end the solution was simply to remove the project from the server to ensure that it was clean, and add it again. Then it works, I hope this solution could help any of you.
You can use GlassFish server and the error will be resolved. I tried with tomcat7 and tomcat8 but this error was coming continuously but resolved with GlassFish. I think it's a problem with server.
These are the results with tomcat7:
Here are the results with GlassFish:
right click on your project and choose properties.
click on Deployement Assembly.
click add
click on "Java Build Path Entries"
select Maven Dependencies"
click Finish.
It may be useful for someone, so I'll post it here.
I was missing this dependency on my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
I solved by following these steps:
Right click in the project > Configure > Convert to Maven project
After the conversion, right click in the project > Maven > Update project
This fixes the "Deployment Assembly" settings of the project.
Move the jar files from your classpath to web-inf/lib, and run a new tomcat server.
I found a simple solution,
Simply add your jars inside WEB-INF-->lib folder..
I had this same issue in WebSphere, but couldn't find a solution even though I verified the Spring dependencies were there and it ran in tomcat just fine. I ended up uninstalling the application and was still getting the error so I think WebSphere was hanging onto some corrupt instance.
To fix the issue I had to reinstall the application, stop it, uninstall it and then reinstall it.
For me it was a mistake in the pom.xml - I'd set <scope>provided<scope> on my dependencies, and this was making them not get copied during the mvn package stage.
My symptoms were the error message the OP posted, and that the jars were not included in the WEB-INF/lib path inside the .war after package was run. When I removed the scope, the jars appeared in the output, and all loads up fine now.
Related
I am trying to build a simple Spring MVC Web App with the functionality of file uploading.I got following error:
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
After a quick search,all answers pointed to the missing of dependencies,but it seems not to be true in my case:
I have included the following code in pom.xml:
<dependencies>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
with commons.io-2.4.jar and commons.fileupload-1.3.1.jar added into lib folder.
One interesting thing I found was that whenever I deleted the code:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>10000000</value>
</property>
<property name="maxInMemorySize">
<value>10000000</value>
</property>
</bean>
the web app works fine(of course I removed the form for file uploading as well. )
If you visit the Maven Central Repository and enter the search term:
fc:org.apache.commons.fileupload.FileItemFactory
then every released artifact available containing that class will be listed.
You will find commons-upload 1.3.1 in that list.
Therefore you need to double check your deployment to ensure that jar is present.
Tip: Use fc: to locate jars in Maven Central that contain a specific class.
try to update your jar version, for Example:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
We cann't find versions upper 1.3 on Apache and mvnrepository.com , but you can try this : https://repository.jboss.org/commons-fileupload/commons-fileupload/2.0.0-SNAPSHOT/
In fact, I encountered the same problem and now working fine with version 2.0 under SpringMVC framework.
When I run the app (with Maven support), it works fine, but when I run mvn test (functional test) it gives me the error: Unable to locate NamespaceHandler for namespace [http://www.mulesoft.org/schema/mule/oauth2]
It looks like it comes from this:
<http:request-config name="ApiRest" protocol="HTTPS" doc:name="HTTP Request Configuration" basePath="rest" host="${api.endpointUrl}" port="443">
<oauth2:client-credentials-grant-type clientId="${api.client_id}" clientSecret="${api.client_secret}">
<oauth2:token-request tokenUrl="${api.endpointUrl}/oauth/token" />
</oauth2:client-credentials-grant-type>
</http:request-config>
What exactly is wrong?
I had a similar issue before but it is complaining about spring-ss namespace. See if the same solution will work with you.
Add these jars on your pom.xml which may be responsible for that namespace.
<dependency>
<groupId>com.mulesoft.muleesb.modules</groupId>
<artifactId>mule-module-boot-ee</artifactId>
<version>${mule.version}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-ws</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
Maybe worth trying with mule-module-oauth module as well.
Good luck!
I'm trying to upgrade to Jersey 2.0 and I'm having a lot of trouble because the groupIds and artifactIds of Jersey have completely changed and I can't find a migration plan in the Jersey docs.
Here's what my pom.xml used to look like, and this compiled fine:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server-linking</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.17.1</version>
</dependency>
What should these be changed to? This unrelated StackOverflow question was somewhat helpful, but I'm having trouble finding things like where the #Ref annotation moved to.
Update
It seems that #Ref no longer exists or at least it's not mentioned in the documentation anymore. Now you use a UriBuilder.
I found a very helpful section in the documentation that answers my maven issues.
The HTTPBasicAuthFilter has been renamed to HttpBasicAuthFilter. Notice the capitalization.
Client client = Client.create(); has become Client client = ClientBuilder.newClient();
This:
String json = client
.resource(getBaseUrl() + url)
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
has become
String json = client
.target(getBaseUrl())
.path(url)
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
You don't.
Jersey 2.0 is missing a lot of functionality from Jersey 1.0. Contrary to what the committers will tell you, some things are plain impossible to implement right now (e.g. Guice, Spring integration). Things appear to work on the surface, but once you dig in deeper you will find a lot of features are still broken.
Many of the 1.x plugins do not exist in 2.x, mainly because of the aforementioned breakage.
In light of this, I suggest a holding off on Jersey 2.x for the foreseeable future. Hopefully the committers will clean this up in the coming year.
It is pain in the neck I have to say.
We are currently knee deep into migrating relatively large 3+ years old client-server project and boy do I want to bite my neck off.
Hopefully we are at the end of the struggle...
While there is a migration guide indeed it is not comprehensive by any means.
UniformInterfaceException (and others) is no more.
Instead it is replaced by WebApplication exception and successors. There is not a word about that in the migration guide and this is very very important.
JSON support
The migration guide says:
JSON Support has undergone certain changes in Jersey 2.x. The most
visible difference for the developer is in the initialization and
configuration.
In Jersey 1.x, the JAXB/JSON Support was implemented as a set of
MessageBodyReaders and MessageWriters in the jersey-json module.
Internally, there were several implementations of JSON to Object
mapping ranging from Jersey's own custom solution to third party
providers, such as Jackson or Jettison. The configuration of the JSON
support was centralized in the JSONConfiguration and JSONJAXBContext
classes.
Great. What if you have chosen the "Jersey's own custom solution" (which we did for whatever reason)? There is no alternative to that in jersey 2. I tried to produce the same JSON format using Jettison, Jackson and Moxy providers. I did not succeed. For reference, my unanswered question here: Jersey 2 JSON Jettison unwrapping root element
See the 1.x to 2.0 migration guide in the Jersey docs. (2019 link to 1.x to 2.0 migration guide)
It looks like #InjectLink is the replacement for #Ref.
From that link, I was able to drop this into my pom.xml:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-declarative-linking</artifactId>
<version>2.6</version>
</dependency>
and then I took an existing #Ref and was able to drop in replace with #InjectLink.
public Long id; // This id is referenced below in the link
#InjectLink(resource = FavoriteResource.class, method = "updateFavorites", bindings = {
#Binding(name = "listId", value = "${instance.id}")
})
public URI linkURI;
It looks like some of the JavaDocs from #Ref are in #InjectLink even, which would be further confirmation that it's the replacement:
/**
* ...
* #Ref(resource=SomeResource.class)
* #Ref(resource=SomeResource.class, bindings={
* #Binding(name="id" value="${instance.id}"}
* )
*/
EDIT:
Tricky stuff. I needed one more piece to make this work for me. In web.xml,
I now have:
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.mycompany.root</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>com.mycompany.root.web.filter.AuditResourceFilterFactory;com.mycompany.root.web.filter.OtherAuditResourceFilterFactory</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.mycompany.root.web.resource.config.CustomResourceConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
and finally, CustomResourceConfig.java looks like this
import org.glassfish.jersey.linking.DeclarativeLinkingFeature;
import org.glassfish.jersey.server.ResourceConfig;
public class CustomResourceConfig extends ResourceConfig {
public CustomResourceConfig() {
packages("org.glassfish.jersey.examples.linking");
register(DeclarativeLinkingFeature.class);
}
}
You can follow following steps for migration from Jersey 1 to Jersey 2 :
Add following dependencies in POM file :
Jersey 2.23.2 dependencies
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.23.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-entity-filtering</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.23.2</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>mimepull</artifactId>
<version>1.6</version>
</dependency>
Make Following entry in Web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.jsg.resource.initializer.RestResourceInitializer</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping> '
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/myAppName</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Write following code in RestResourceIntializer
package com.jsg.resource.initializer;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;
public class RestResourceInitializer extends Application {
/**
* Gets the classes.
*
* #return the classes
*/
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
// Resources
classes.add(org.glassfish.jersey.jackson.JacksonFeature.class);
classes.add(org.glassfish.jersey.server.spring.scope.RequestContextFilter.class);
classes.add(org.glassfish.jersey.media.multipart.MultiPartFeature.class);
//Rest classes within Application.
classes.add(com.jsg.rest.AbcRestService.class);
classes.add(com.jsg.rest.CdeRestService.class);
return classes;
}
}
Now if you will deploy code with above changes on websphere,you will get following exception :
Caused by: java.lang.NoSuchMethodError: javax/ws/rs/core/Application.getProperties()Ljava/util/Map; at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:287) at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:311)
Reason for above exception is that,Websphere supports JAX-RS 1 implementation,however we are deploying Jersey 2 code which is Jax-rs 2 implementation.
Steps for resolving above exception:
So basically what we have to do is to force WebSphere to pick our Jersey 2 jars instead of default Jax-rs 1.We need to follow following steps for that
1) Disable in built JAX-RS by setting following JVM property to true
com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true
This property can be set through admin console of WebSphere by going to Servers->All Server -> ->Server Infrastructure -> Java and Process Management ->Process Deifinition ->Additional Properties-> Java Virtual Machine ->Additional Properties-> Custom Properties
2) Create Isolated Shared Library having the Jersey 2 Jars and Spring 4 Jars
Isolated shared library can be created through admin Console of Websphere by going to Environment-> Shared Libraries ->New
n the classpath box,we need to enter path of the folder on the server,where we have placed all Jersey 2 and Spring 4 Jars
/var/was/server2/jerseyLib1/spring-context-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-core-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-beans-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-aop-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-web-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-expression-4.3.4.RELEASE.jar
/var/was/server2/jerseyLib1/spring-bridge-2.5.0-b05.jar
/var/was/server2/jerseyLib1/hk2-locator-2.5.0-b05.jar
/var/was/server2/jerseyLib1/hk2-api-2.5.0-b05.jar
/var/was/server2/jerseyLib1/hk2-utils-2.5.0-b05.jar
/var/was/server2/jerseyLib/javax.inject-2.5.0-b05.jar
/var/was/server2/jerseyLib1/javax.annotation-api-1.2-b03.jar
/var/was/server2/jerseyLib1/javax.ws.rs-api-2.0.1.jar
/var/was/server2/jerseyLib1/jersey-client-2.23.2.jar
/var/was/server2/jerseyLib1/jersey-spring3-2.23.2.jar
/var/was/server2/jerseyLib1/jersey-container-servlet-core-2.23.2.jar
/var/was/server2/jerseyLib1/jersey-server-2.23.2.jar
/var/was/server2/jerseyLib1/jersey-common-2.23.2.jar
/var/was/server2/jerseyLib1/jersey-guava-2.23.2.jar
Also in class loading section ,select "use an isolated class loader for this shared library"
and then finally click on Apply and Ok and we are done with creation of isolated shared library.
Bind this isolated shared library with your application war file as follows in admin Console
a) Application -> All Applications -> Click on your application name
b) Go to References -> Shared Library References -> Reference Shared Libraries ->select your application war(Not ear) and click ok.
c) Select the library that we created in Step 2 in "Available" combo box on left side and put it on right side in "Selected" combo box and click ok.
With this we have associated the isolated shared library with application war file.
Restart Server and application should be up and running.
Im trying to run a ActiveMQ glassfish embedded using the maven-embedded-glassfish-plugin.
I have separately completed below tutorials, so I know the basics.
The goal is to have a setup that builds in one click and avoids 3pp libraries in svn.
1 http://www.hascode.com/2011/09/java-ee-6-development-using-the-maven-embedded-glassfish-plugin/
2 http://javadude.wordpress.com/2011/07/21/glassfish-v3-1-running-embedded-activemq-for-jms-part-1/
Project setup for #2 is used as startpoint from now and I will try to merge the steps from #1
I've setup a glassfish-resources.xml hoping it will do the configuration tutorial 1 did from the glassfish admin-console.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<resource-adapter-config resource-adapter-name="activemq-rar-5.6.0" thread-pool-ids="thread-pool-1">
<property name="ServerUrl" value="vm://localhost:61616"></property>
<property name="BrokerXmlConfig" value="broker:(tcp://0.0.0.0:61616)"></property>
</resource-adapter-config>
<connector-resource enabled="true" jndi-name="amqres"
object-type="user" pool-name="amqpool">
</connector-resource>
<connector-connection-pool
connection-definition-name="javax.jms.ConnectionFactory"
fail-all-connections="false" idle-timeout-in-seconds="300"
is-connection-validation-required="false" max-pool-size="32"
max-wait-time-in-millis="60000" name="amqpool" pool-resize-quantity="2"
resource-adapter-name="activemq-rar-5.6.0" steady-pool-size="2" />
<admin-object-resource res-adapter="activemq-rar-5.6.0"
res-type="javax.jms.Queue" jndi-name="amqmsg"></admin-object-resource>
</resources>
additions to pom.xml
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-rar</artifactId>
<version>5.6.0</version>
<type>rar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.6.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Q1: How is glassfish-resources.xml loaded? Should i use maven admin command or place it in some META-INF?
edit: looks like it goes in web-inf if war and meta-inf if ejb-jar
Q2: Not entirely sure what is the next step. #1 has me copy activemq and log4j libraries to GLASSFISH_HOME/glassfish/lib so far I only added the dependency in the pom.xml, what is the equivalent here?
Q3: The Rar needs to be deployed as well. How can multiple applications be deployed?
there's this issue with JSTL I'm stuck with for the past couple of days. Any help is appreciated.
Tomcat 6.0.28
Eclipse: Helios
pom.xml :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
JSP:
<%# page session="true"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%# taglib prefix="utilfn" uri="/utility-functions" %>
web.xml:
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
When I deploy the Maven-built war on tomcat 6 using the manager it works fine.
When I run it as "Run As > Run On Server" inside eclipse, I get this:
Unable to read TLD "META-INF/c.tld" from JAR file "file:/<- location ->/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/standard-1.1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
Wherever I look, it says the same thing:
Make sure servlet-api and jsp-api are not in lib
Make sure to use the right JSTL version and URI that goes with JSP 2.0.
And they seem to be fine as I can deploy the war independently. So what's wrong here!?
After i moved using Indigo Eclipse 3.7 and took the lasted update of m2e, this problem happened to me, i remove the dependency below it worked well.
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
I'm not sure why the issues was gone, as my understanding new version of m2e has jsp compilation library already.
remove :
javax.servlet.jsp
jsp-api
2.0
provided
from you pom.xml and that should do.. it worked in my case :-)
It looks like there is an issue with maven/m2eclipse plugin. Even I am seeing the same issue. By default it is pushing all the jar files to server lib directory. Which includes the scope "provided" jar files. This issue was fixed in old versions of m2eclipse. But it got introduced again it seems.
Check that
.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/standard-1.1.2.jar is not corrupted (and do some cleanup if required).
Quickfix:
Make a backup of .classpath and .project and .settings/org.eclipse.wst.common.component.
Run this command:
mvn eclipse:eclipse
Or, right-click over the project, in the Maven sub-menu, you have an Update Project... command which I think does the same thing.
Republish.
Explanation:
You likely added all Maven Dependencies as a Deployment Assembly to your project. This copies all Maven class path entries to the WEB-INF/lib directory. Open your .classpath file (at the root of your project) and you'll probably find the following XML:
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
That means copy EVERY .jar file which becomes a problem in this case.
Updating the project should remove the XML block above and explicitly list the JAR files.
So, if you re-open .classpath, you'll see this instead:
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar" sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar"/>
...
This is for the classpath which you still need, but it removed the dependency to copy them to lib. Instead, if you open .settings/org.eclipse.wst.common.component/, you'll see that the JAR files are now explicitly listed:
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
And, you'll note that jsp-api-2.1.jar is now missing. Apply the same logic to the other JAR files.
Does anyone know how to make this automatic?
platform: eclipse 3.7 indigo, tomcat 6.0.29
commented out the following dependencies in pom.xml:
javax.servlet
org.apache.taglibs
this cleared up the issue (as they are provided via tomcat) ...
I agree with Jay's answer. I have same issue here. If I remove jsp-api from pom.xlm, maven test will fail because it cannot find jspWriter class in jsp-api jar. If I keep jsp-api in pom and set it to 'provided' or 'test', tomcat side will fail as the m2e plugin pushes jsp-api jar to maven dependencies which is then included in my tomcat deployed lib. I would say it's plugin issue as jsp-api has to be declared in pom.xml as provided because it is provided by application servers.
I can't find any way of solving this issue but to manually delete the jsp-api every time after tomcat server synch.
With Eclipse, please assure that you installed 'Maven Integration for Eclipse WTP '
With the other plugin without WTP, eclipse change your classpath and include servlet-api.jar in your webapps.
You must exclude jsp-api dependency from jstl import in your pom.xml :
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<artifactId>jsp-api</artifactId>
<groupId>javax.servlet.jsp</groupId>
</exclusion>
</exclusions>
</dependency>
Removed jsp-api 2.0 from
.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/
this worked for me .
I was getting the same error in netbeans IDE 8.0.2. It turns out my part was set to 8080 for outgoing and shutdown. I changed the outgoing to 8081 for Tomcat server. It worked! I then changed my shutdown port 8005. To change go to Tools>Servers>
My tomcat server now works.