Class Not Found exception: STS - sts-springsourcetoolsuite

Everything was working properly until i added a new java package to my project, when i run my application the stack trace shows java.lang.ClassNotFoundException, i had to reference another class library as i could not figure out how to compile fresh new classes using eclipse. I added an external folder to my build path to temporarily fix the problem but now i am faced with the same problem.
Stack Trace and web.xml are below:
My question is, how do you do compile a project to create new classes using eclipse?
Caused by: java.lang.ClassNotFoundException: org.bixin.dugsi.security.JpaRealm
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1271)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1242)
... 38 more
WEB XML:
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Dugsi_Manager Vaadin Application Servlet</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>org.bixin.dugsi.web.DugsiManagerApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Dugsi_Manager Vaadin Application Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Did a mvn clean and a mvn build to clear the cache of all old classes and create new classes

Related

Deploying an ear with web.xml on websphere changes the web.xml or create web_merged.xml with changed attributes for multi-part

I have an ear file built which has a war file inside.The war has web.xml which has servlet defined:
<servlet>
<servlet-name>ExcelDownload</servlet-name>
<servlet-class>web.ExcelDownload</servlet-class>
<multipart-config>
**<!--<max-file-size>1048576</max-file-size> -->**
</multipart-config>
</servlet>
The problem here is my in ear file max-file-size is commented that means there are no attributes defined for the multipart-config. But when I deploy my ear on WebSphere 8.5.5.9, it changes my web.xml to:
<servlet>
<servlet-name>ExcelDownload</servlet-name>
<servlet-class>com.ofss.infra.web.ExcelDownload</servlet-class>
<multipart-config>
<max-file-size>0</max-file-size>
**<max-request-size>0</max-request-size>**
<file-size-threshold>0</file-size-threshold>
</multipart-config>
</servlet>
Since the max-file-size attribute is defined as zero in web.xml I am not not able to use HTTP request to upload the file to server.
I need help on to understand why the attribute is being added by WAS though its not available in ear. I did my digging I tried during deployment not to use metadata-complete attribute to false then instead of changing web.xml WAS has created a new file web_merged.xml (this has max-file-size set to zero) and am still facing the issue.

'No suitable driver' exception implementing Olap4J XMLA Server

I'm trying to implement olap4j-xmlaserver to access Mondrian via HTTP/XMLA. I compiled the project, created a war file (including a web.xml file) and deployed it in Tomcat 7. Problem is that I'm getting an exception when the pivot client application sends an XMLA request:
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=xxx;Catalog=/WEB-INF/FoodMart.xml'
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at mondrian.xmla.impl.Olap4jXmlaServlet$Olap4jPoolingConnectionFactory.getConnection(Olap4jXmlaServlet.java:300)
at mondrian.xmla.XmlaHandler.getConnection(XmlaHandler.java:2917)
... 33 more
Caused by: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver (DriverManager.java:315)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 37 more
The web.xml I put together (I couldn't find a sample in the olap4j-xmlaserver project). I'm sure this web.xml file needs to be fixed to solve the problem, especially the connection string:
<web-app ....
<display-name>olap4j-xmlaserver</display-name>
<description>
Olap4J XML/A server
</description>
<servlet>
<servlet-name>xmla</servlet-name>
<servlet-class>mondrian.xmla.impl.Olap4jXmlaServlet</servlet-class>
<init-param>
<param-name>OlapDriverClassName</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
<init-param>
<param-name>OlapDriverConnectionString</param-name>
<param-value>
jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=xxx;Catalog=/WEB-INF/FoodMart.xml
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>xmla</servlet-name>
<url-pattern>/xmla</url-pattern>
</servlet-mapping>
</web-app>
Any ideas how to fix the web.xml configuration or pointers to relevant documentation will be greatly appreciated.
You are missing the Java driver for MySQL in your classpath. Add it to your webapp in the folder named 'WEB-INF/lib'.

Usage of PortalDelegateServlet in Liferay

I'm trying to create a servlet which shares liferay session contents with my application.So I need to use PortalDelegateServlet.But I can not find in how to import this library to my project.I can not find any .jar files or something.
How can I import liferay java library to my project?
PortalDelegateServlet is in portal-service.jar which is a required part of the Liferay container. If you grabbed a bundle (which in comment you mention the Tomcat bundle), then it is provided for you. All you should need to do is configure your web.xml:
<servlet>
<!-- http://issues.liferay.com/browse/LEP-2297 -->
<servlet-name>service</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortalDelegateServlet</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>com.example.MyServlet</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
This Liferay issue (which is linked to in the source for PortalDelegateServlet) makes it sound as if this has been available since version 4.3.0

How does Spring 3.1 Java based configuration work

Just a general question, when you define a Java based configuration web app. Ie.e have a class for : ApplicationContext and a WebApplicationInitializer class.
How does Spring know it has to load the beans, as no xml config files exists.. how does tomcat know anything about the webapp without a web.xml
Its a newbie question.. i appreciate that. :)
See this blog post from SpringSource blog, important part about web.xml has an example, basically you point to JavaConfigWebApplicationContext instead of default XmlWebApplicationContext in DispatcherServlet's <init-param>:
<web-app>
<!-- Configure ContextLoaderListener to use JavaConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.config.java.context.JavaConfigWebApplicationContext</param-value>
</context-param>
<!-- Configuration locations must consist of one or more comma- or space-delimited
fully-qualified #Configuration classes -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>example.RootApplicationConfig</param-value>
</context-param>
<!-- Bootstrap the root application context as usual using ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Declare a Spring MVC DispatcherServlet as usual -->
<servlet>
<servlet-name>dispatcher-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- Configure DispatcherServlet to use JavaConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.config.java.context.JavaConfigWebApplicationContext</param-value>
</init-param>
<!-- Again, config locations must consist of one or more comma- or space-delimited
and fully-qualified #Configuration classes -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>example.web.WebBeansConfig</param-value>
</init-param>
</servlet>
</web-app>
I have a VERY GOOD WAY to help you learn Spring MVC if you have Maven up and running.
IF SO: go to your command line (Cygwin) I use...
mvn archetype:generate
It will ask for an 'archetype number'. For you... type 16
Enter the group ID which is just the main package.
Enter Artifact ID which is your project name.
SNAP-SHOT --- just press enter and same with version.
Package - is the same as your group ID name. EX: com.spring
Confirm it by entering the letter 'y' and press enter.
DO all of the above after your are in your workspace directory. That way it is created there.
You can do "mvn eclipse:eclipse" to load it in Eclipse OR you can just import it. I prefer the old fashioned importing an existing project.
Everything will be 'already' set up for you in terms of ALL configuration (Java-Based) which is good for you. It will have all the Maven dependencies you need as well already in your pom.xml. You can add or take from it if you want.
The point here is that you will have a running project already and you can play with it from there. I create all my projects like this at first and erase what I don't need and add what I do and then go from there.
Good luck!!!
Anywho... add this to your web.xml. This will help you in your answer. Research this below:
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Tomcat7 deploy Fail: org.apache.catalina.LifecycleException: Failed to start component /w org.springframework.web.servlet.DispatcherServlet

I have a very sample web.xml written below:
The problem is...If I remove org.springframework.web.servlet.DispatcherServlet section, I can successfully deploy my project in Tomcat7 as a simple JSP-Servlet app. However, once I use Spring MVC, my deployment will FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebMVCProj2]]
How can I fix this error?
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
Spring Web MVC Application
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<!-- I can remove the part below to make deployment successful -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
I add Spring MVC dependency from Enterprise Bundle Repository (EBR). I also use Eclipse Dynamic Web Module 3.0 which Tomcat7 should support. My jre is 1.6.x 64bits used by Tomcat and my project. I also use Web Deployment Assembly in Eclipse.
Here is my complete exception:
SEVERE: Error deploying web application archive E:\MyServers\apache-tomcat-7.0.30\webapps\WebMVCProj2.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebMVCProj2]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
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)
You should have applicationContext.xml in web-inf folder or you have to define contextConfigLocation in your web.xml
<!-- Spring Context -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/application-contexts/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
It would be more helpful, if you could post exception trace.
you can check your servlet class is having any annotation like #WebServlet(". I resolved the similar issue by removing the annotation in servlet class.

Resources