I get the following error whenever I try to run/deploy a maven project, which I feel is properly developed. The error ..
Build Path is incomplete. Cannot find class file for org/apache/commons/pool/impl/Generic/ObjectPool....is found on the line
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
in my datasource-config file, which is then imported in the applicationContext.xml.
I would be grateful if anyone can help. The application is being implemented on eclipse Luna + tomcat 8,0.
Related
I want to use this JSON parser in my JAX-RS application that runs on Websphere Liberty.
I have done the following:
1) Right-click on Project -> Properties -> Java Build Path -> Add External Jar -> C:\javalib\quick-json.jar
2) Added C:\javalib to enviroment variable CLASSPATH
3) Added fileset xml to serverl.xml
<library id="ExternalLibs">
<fileset dir="C:\javalib" includes="*.jar"/>
</library>
4) Unchecked 'Enable project specific settings' in 'Java Compiler'
5) Cleaned the Project
[EDIT]
I was initially creating a new instance and then I turned it into an #ApplicationScoped bean and injected it. Now I get this error:
The JNDI lookup failed for JNDI name java:module/ConsoleREST with the following Exception CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory.
CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory
The first step was enough to get it to compile. Now I'm getting what I learned to be a runtime error. I would appreciate help!
You also need a <classloader> element in your application definition in the server.xml, which references the shared library. For example,
<application id="myapp" name="My App" type="war" location="somewhere.war">
<classloader commonLibraryRef="ExternalLibs" />
</application>
Alternatively, if your application is the only user of the library, you could package it in the WEB-INF/lib folder of your war. (Putting it in WebContent/lib in Eclipse should accomplish this.)
I recently discovered Yeoman, a tool that greatly facilitates JS dependency and build lifecycle management.
Furthermore, I use Maven as my Java dependency and build tool. I am actually seeking to integrate both tools so that I get the best of both worlds.
It seems the community has put a lot of effort into Maven/Yeoman integration with various articles such as this one: http://addyosmani.com/blog/making-maven-grunt/ as well as a yeoman-maven plugin: https://github.com/trecloux/yeoman-maven-plugin
Last, I use Thymeleaf as my Spring-MVC templating solution.
Assuming the following directory layout (see yeoman-maven-plugin above):
pom.xml
- src
- main
- java
- webapp
- …
- test
- ..
- yo
package.json
component.json
Gruntfile.js
- app
index.html
...
- test
...
- dist
...
My question is where should my Thymeleaf templates reside?
Under the yo/app directory? (they would be subsequently copied into appropriate directory by maven)
Directly under the src/main/webapp/WEB-INF/templates directory?
What I can't figure out in the case of an AngularJS application for instance, is when and how templates/pages including server-side content can interact with the servlet container given that Yeoman assumes they live under its app directory...
If you are using Thymeleaf as your templating engine with Spring, I assume you have something like
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
<bean id="templateEngine"
class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>
<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
</bean>
In other words, your templates should reside in the folder specified in the ServletContextTemplateResolver property prefix. In the above example, that's /WEB-INF/templates. These should therefore be in /src/main/webapp/WEB-INF/templates.
If you are not using a ServletContextTemplateResolver, but instead using a ClassLoaderTemplateResolver, you can put them anywhere on your application classpath and specify it in that bean's properties. There's also a FileTemplateResolver in which you can specify an absolute path to anywhere on your file system.
When building the application with Eclipse (maven plugin), having the folders
/src
/main
/webapp
/WEB-INF
/templates
/some-template.html
/index.html
/java
/com
/yourcompany
/Main.java
/resources
/some-properties.properties
maven will generate the following
/WEB-INF
/templates
/some-template.html
/index.html
/classes
/com
/yourcompany
/Main.class
/some-properties.properties
As a expanded .war and provide that to your servlet container, ex. Tomcat.
I have a development environment based on Eclipse Juno with Spring IDE installed. My project uses also Spring Security. The Spring version I am using is 2.5.5 and Spring Security is at 2.0.6. Now, after updating Spring IDE from 3.1.0 to 3.3.0, I am getting a NoSuchMethodError when Spring compiler is trying to compile this line:
<security:authentication-provider user-service-ref="userDetailsService" />
<bean id="userDetailsService" class="com.mycompany.security.MyUserDetailsService">
<property name="daoFactory" ref="DaoFactory" />
</bean>
MyUserDetailsService implements UserDetailsService and InitializingBean.
schemaLocation for the file has been defined as:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.6.xsd"
The stacktrace looks like this:
!MESSAGE Error occured processing '/Server/WEB-INF/business-layer-context.xml'
!STACK 0
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.BeanDefinitionBuilder.addConstructorArg(Ljava/lang/Object;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;
at org.springframework.security.config.AuthenticationProviderBeanDefinitionParser.parse(AuthenticationProviderBeanDefinitionParser.java:88)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:494)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:402)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:445)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
When compiling the application with Ant script and starting the server, everything works fine, so the problem is limited to Eclipse and Spring IDE. Both my Ant and Eclipse configurations use the same Spring library. addConstructorArg method still seems to exist in the newest version of Spring, so I am puzzled by this error. What could be causing this problem?
I believe this is because Spring Tools Suite comes with it's own spring libraries. So for the XML parsing and validation it does not use libraries on your project classpath.
Please see STS-3679
Check your XML configuration files for both Spring and Spring security.
Do you have correct URLs in xsi:schemaLocation, like:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
I met a configuration problem like below:
when I am executing example by hibernate tool
After I have write
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://127.0.0.1</property>
<property name="hibernate.connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect"> org.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping?resource="com/vaannila/course/Course.hbm.xml"/>
<session-factory>
and open HSQLDB connection(using java -cp ./lib/hsqldb.jar org.hsqldb.Server and java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager), when I use Hibernate Code Generation in Eclipse, why it pop up the error message:
In former step for the jar, instead of using package slf4j* ,I have used log4j, and I remember I have not include the changed jar to my classpath as vannilla required, do it have affects for the error? thanks first :)
hibernate3.jar is responsible for parsing hibernate.cfg.xml.
<property? //wrong
<property> //correct
Those question marks in <property?name.. are wrong - they should not be there. Remove them and try again.
If the ? characters aren't visible in your editor, they are probably some other unicode space character which the XML parser doesn't recognise. You'll have to select each one and re-type a space character. ( maybe?). Did you copy an example configuration from a web page?
I'm developing a web application with Java and Maven build system and the web server is Tomcat 7.0.12. After packaging whole project to a WAR file to \target directory by Maven build command, I have to copy it to the webapps folder of Tomcat home to run it. It's very inconvenient, especially when I modified some source files because I have to do all those things (build, copy to Tomcat, run it) again. I've research some articles about Maven, Tomcat, Eclipse on this problem, but there's no result.
Could you please help me:
1. How to make Tomcat run the WAR file on target directory of project which is built by Maven command directly? No need to copy/paste the WAR file and restart Tomcat?
2. How can I configure the Tomcat to debug the web application on Eclipse?
Thank you so much!
BTW, I've read and tried to configure Tomcat, Maven and pom file many times. But I don't know what is the exact configuration, because there are so many advices! Could you provide a particular example of configuration for me?
Here is my configuration files:
Tomcat tomcat-users.xml
<role rolename="manager-gui"/>
<user username="admin" password="" roles="manager-gui"/>
**<role rolename="manager"/>
<user username="admin" password="" roles="manager"/>**
<role rolename="admin-gui"/>
<user username="admin" password="" roles="admin-gui"/>
Maven settings.xml
tomcat
admin
And the pom.xml file of project:
<build>
<finalName>my-project</finalName>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>tomcat</server>
<warFile> ${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
// Other plugins
</build>
More details:
If I run mvn tomcat:deploy before starting a Tomcat instance, the returned error is "Cannot invoke Tomcat manager: Connection refused: connect."
Otherwise, if a Tomcat instance has been started before calling mvn tomcat:deploy, the error is "Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fmy-project&war=..."
There are a couple of ways to do this.
The tomcat maven plugin http://mojo.codehaus.org/tomcat-maven-plugin/ provides you a way to deploy directly to tomcat from maven. You must have configured your tomcat users first. See http://tomcat.apache.org/tomcat-7.0-doc/config/realm.html for instructions on how to configure your users.
For debugging you can start tomcat with the arguments specified at http://wiki.apache.org/tomcat/FAQ/Developing
The other way would be to configure tomcat to point to your war. See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html particularly the docbase parameter.
EDIT 1
Based on the revised question http 403 is a forbidden this means you didn't authenticate correctly.
Change your tomcat-users.xml to look as follows:
You need to add a refrence to the username/password in your pom.xml.
You settings.xml must contain (based on your configuration)
<server>
<id>tomcat</id>
<username>admin</username>
<password></password>
</server>
Theres a good page http://www.avajava.com/tutorials/lessons/how-do-i-deploy-a-maven-web-application-to-tomcat.html that explains it more fully. However the information may be out of date.
I ran into exactly the same issue.
I suppose it is eclipse-tomcat plugin that is doing this. And I have no idea why it works differently in tomcat 7 opposed to tomcat 6 which I didn't have problem with.
Anyways, what I did was to have maven build into the /web-app/WEB-INF directory
<build>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
...
</build>
After this config, eclipse:eclipse should yield a proper eclipse project/classpath files
resources:resources shoudl work accordingly as well.