w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
What is the correct procedure for including a Maven-Spring-Roo-Hibernate jar in a Non-Maven-Non-Spring project?
Because the application context don't aware about the model. You are creating the model out of the appcontext. if you get the Model using getBean("MyUser"); some thing like that will work. else auto-wire the model and use that model for your crud operations. You can see the following code in MyUser - @PersistenceContext rotected transient EntityManager entityManager; Then only the entityManager object will initialized inside the the Myuser. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath*:/META-INF/spring/applicationContext.xml"}) public class SomeTest extends AbstractJUnit4SpringContextTests { @Autowired MyUser myUser; // use this object for ur crud operations @Test public void someTest() throws Exce

Categories : Java

Spring, JPA, Hibernate, Tomcat: Unable to find persistence unit when loading Spring application context
As far I understood from my recent expirience of setting up 2 EntityManagerFactory in the same application - @PersistenceUnit(unitName="myPU") just doesn't work at all. I would suggest to inject EntityManager, not EntityManagerFactory. This is clear since you always know which EMF is used. Same for specifying right TransactionManager. Updated code of the service class: @Service public class CompetenceAreaManager { @PersistenceContext(unitName = "emf1") private EntityManager em; @SuppressWarnings("unchecked") @Transactional(transactionManager="transactionManager1", readOnly=true) public List<CompetenceArea> getCompetenceAreas() { List<CompetenceArea> competenceAreaList = null; Query q = em.createNamedQuery(CompetenceArea.FIND_ALL);

Categories : Java

Tomcat 7, Hibernate 3.6, PostgreSQL 9.2 | Maven java.lang.NoClassDefFoundError
Take a look at this post: Hibernate java.lang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver They removed 'hibernate-tools' and added 'hibernate-core'.

Categories : Hibernate

How to avoid Classloader Leak with JPA, Hibernate and Spring on Tomcat
Configure a logging framework other than java.util.logging e.g. Logback. If no logging is configured at all, or if java.util.logging is configured, jboss logging will create a classloader leak via the JDK bug Level.known can leak memory. See the stack trace in the question where jboss logging creates the custom java.util.logging.Level.

Categories : Spring

Spring can not load properties when webapp is deployed on Maven embedded Tomcat
/WEB-INF/conf is not in the CLASSPATH; /WEB-INF/classes is. Try putting your .properties file there and see if you do better. If that doesn't work, I'd wonder if it's a class loader hierarchy problem. Java EE containers have a hierarchy of class loaders: first is the bootstrap, second is the app server, last is the application. It might be that you have the .properties file in the application loader when it's needed at the app server level.

Categories : Maven

Getting Session Closed. Spring+Jpa/Hibernate+Maven
The code bellow worked for me: public class AbstractDao<T> { /** entity manager */ @PersistenceContext(unitName = "dbschema") protected EntityManager entityManager; public Session getHibernateSession() { return ((Session) this.entityManager.getDelegate()).getSessionFactory().openSession(); } @Repository

Categories : Hibernate

Spring Hibernate integration with maven and mysql
I see following two problems: First Issue: In your controller, you use @RequestMapping(value="/student.do", method=RequestMethod.POST) but in your form you use <form:form action="student.do" method="POST" commandName="student"> Shouldn't your form also use /student.do? Only reason I suspect this is because you have indicated that you get 404 (Page not found) error on trying to add/update. Second Issue: You use four submit buttons each with its own name <input type="submit" name="action1" value="Add" /> <input type="submit" name="action2" value="Edit" /> <input type="submit" name="action3" value="Delete" /> <input type="submit" name="action4" value="Search" /> but, your controller method's @RequestParam assumes that you will get the value in one pa

Categories : Spring

After maven dependency update from spring 3.0 to 3.1.1 and hibernate 3.6 to 4.0 . Lots of error are coming
This will answer it spring 3.1, hibernate 4, sessionfactory http://blog.springsource.org/2012/04/06/migrating-to-spring-3-1-and-hibernate-4-1/

Categories : Java

how to access tomcat servlet in maven project structure with embeddable tomcat
Your application context path is /Archery (defined in context.xml) Your servlet path is also /Archery (urlPatterns property of @WebServlet) It's also duplicated by your web.xml So, your URL should be localhost:8080/Archery/Archery First server[:port], followed by context path, followed by servlet path Anyway, you will have to fix project structure in order for this to work. If you are following Maven conventions web resources directory should be src/main/webapp The web.xml (and context.xml) should be put under WEB-INF directory under this directory. After you have packaged the war, just make sure these files are there (under WEB-INF)

Categories : Maven

How to deploy war with automatic buildnumber to tomcat using maven tomcat plugin
Use tomcat 7, with '##' tomcat7 is possible to use the aritfactId as context and the version as version in tomcat. <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcatserver</server> <path>/${project.artifactId}##${project.version}</path> </configuration> </plugin> Parts in your pom that you use in more that one pom like 'maven-compiler-plugin' put in the parent pom and include in all your project poms.

Categories : Maven

How to configure Logging for an Embedded Tomcat from Maven plugin 'tomcat7-maven-plugin'
The documentations says, that tomcatLoggingFile refers to "the path of the Tomcat logging configuration", not the logging file itself. Besides you shall ensure, that the logging libraries are on the classpath. See http://tomcat.apache.org/tomcat-7.0-doc/logging.html

Categories : Tomcat

Need spring maven errors explanation, after applying maven-enforcer-plugin
I have not used 'maven-enforcer-plugin' plugin. It seems that that plugin will raise an error for different version of libs in dependency. In you pom dependency, there are jar like org.springframework:spring-core has different version dependent by different jar. 3.1.4 and 3.2.3. If you didn't add that plugin, there should not any error. In the normal, we will exclude the un-necessary (or conflict) lib from dependency. for example: +-pk.training.basitMahmood:ch17_i18nSupport:0.0.1-SNAPSHOT +-org.springframework.data:spring-data-commons:1.5.1.RELEASE +-org.springframework:spring-core:3.1.4.RELEASE and +-pk.training.basitMahmood:ch17_i18nSupport:0.0.1-SNAPSHOT +-org.springframework:spring-webmvc:3.2.3.RELEASE +-org.springframework:spring-core:3.2.3.RELEASE both data com

Categories : Spring

Spring + Hibernate: No Hibernate Session bound to thread
If you have defined a TransactionManager in your spring context you have to specify @Transactional somewhere in the stack. Otherwise you will get the exception you encountered because you are trying to run a query outside of a transaction. There are workarounds to this such specifying current_session_context_class in your hibernate configuration to thread or <property name="current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property> but it's not production safe.. The possible values for current_session_context_class are jta, thread and managed. Further to that, jta and thread are supported by hibernate out of box. thread context is used in most stand alone hibernate apps or those based on light weight frameworks like Spring and jta is used in

Categories : Java

spring mvc 3 with hibernate (and hibernate.hbm2ddl.auto)
You seem to be missing the spring-tx jar from your classpath given this line 15:49:04,031 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroy method on bean with name '(inner bean)' threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization You can get it here. You actually seem to be missing much more than that. java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean Get all the spring jars from the here.

Categories : Java

using hibernate with tomcat 7 (without any IDE)
These are just some on top of my head Java EE API jars (JSP, servlet, etc) Hibernate jars Your DBMS driver jar (eg: mysql-connector-java) Datasource connection pooling jar (eg: commons-dbcp) Logging jar (eg: log4j) Unit testing jar (eg: JUnit) Hopefully you decided to use some package management tool such as Maven in which case you can just search for those jars on http://search.maven.org Also since you did not mention it, hopefully you also decided to use some web framework such as JSF / Spring. IDE to programmers are like mechanical tools for carpenters, so try considering the merits and benefits before blindly avoiding it :)

Categories : Hibernate

Spring MVC bind hibernate session factory other thread in spring web mvc
You need to either go through AOP decorated transactional bean (e.g. your service layer annotated with @Transactional), or you need to use TransactionTemplate: new TransactionTemplate(txManager).execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { // Your Hibenrate stuff return null; } });

Categories : Spring

can not run maven project in Tomcat 7
Regardless of why or how maven processes your web.xml file, it might be a good idea to check to deployed war file what kind of web.xml file is there and if it meets the requirements and if it is the one you wanted to be there.

Categories : Java

CXF- FileNotFoundException with Maven and Tomcat 7
Keystores (as identified by the sec:keyStore element above) can be identified via any one of three ways: via a file, resource, or url attribute. File locations are either an absolute path or relative to the working directory, the resource attribute is relative to the classpath, and URLs must be a valid URL such as "http://..." "file:///...", etc. Only one attribute of "url", "file", or "resource" is allowed. Source: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html

Categories : Java

got 403 when trying to deploy war to tomcat with maven
According to the tomcat7-maven-plugin usage docs, you probably don't need to define a url, as the default (http://localhost:8080/manager) should be proper. More importantly, you'll need to use the same server name for the pom.xml server field as you do in the settings.xml server>id field to use your login credentials. Also, if you haven't already, you'll need to install the manager portion of Tomcat as it isn't part of the default install. (run: apt-get install tomcat7-admin)

Categories : Java

Tomcat maven plugin - what's the difference between run-war and run-war-only
tomcat7:run-war-only target will run the tomcat in the same process (shell). If you terminate the shell, the tomcat will die and the webapp is not available anymore tomcat7:run-war will launch the war in 'background'. Maven will finish the job and you'll be able to reuse the shell. Webapp will still be available

Categories : Maven

maven tomcat plugin configuration
You can get embedded tomcat7 plugin like this: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> </plugin>

Categories : Java

How to deploy a hibernate application on Tomcat?
It turned out that it is necessary to copy the hibernate-jpa (hibernate-jpa-2.1-api-1.0.0.Draft-16.jar) library to CATALINE_HOMElib. It is not sufficient to have it in the warWEB-INFlib as one would expect.

Categories : Java

Spring and tomcat or Spring and Glassfish
It is perfectly possible to run a Spring application as a stand-alone Java application without any form of J2EE container at all. Assuming the application is some form of web based application then (unless you like re-inventing wheels) you will need a container and you have a choice of three categories: Servlet container (usually includes JSP & EL support). e.g. Apache Tomcat J2EE Web Profile container. e.g. Apache TomEE Full J2EE container. e.g. Apache Geronimo The options are listed in order of increasing functionality. Generally, I'd recommend pickign the class of container with the minimum functionality you need now and are likely to need in the short to medium term. I've listed the Apache containers as examples but there are plenty of others, both open and closed source. The

Categories : Spring

How to start tomcat using maven in debug mode
we can cheat. use java opts in *IX export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044" then run your maven, it should go to debug mode

Categories : Maven

Multiple wars on Maven Embedded Tomcat
Seems like it isn't possible to deploy more than 1 WAR to the embedded tomcat. That's too bad. You need to deploy your wars to a running tomcat server. This way you'll loose your hot code replacement features.

Categories : Maven

How to configure maven tomcat port in eclipse?
In pom.xml, where you declared the apache tomcat maven plugin, you would set or change the port number, Ex: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <!-- or if you want to use tomcat 6.x <artifactId>tomcat6-maven-plugin</artifactId> --> <version>2.0</version> <configuration> <!-- http port --> <port>9090</port> <!-- application path always starts with /--> <path>/</path> ... </plugin> See Run an embeded Tomcat

Categories : Eclipse

Set JavaAgent in Java EE Maven project on Tomcat
I was being a big noob concerning Maven and Surefire. The above configuration works as expected: It sets a javaagent for tests during buildtime. That's however, not what I wanted. Through my Netbeans IDE, I managed to set the -javaagent correctly as a VM Option on my TomEE/Tomcat server: In Netbeans (OS X, 7.3): Tools > Servers > (your server) > Platform. Fill in next to VM Options: -javaagent:/path/to/javaagent.jar P.S.: A Maven solution would be infinitely better. If you have one, please share it.

Categories : Java

How do I deploy an unpacked maven project to Tomcat?
As Muel commented, you have to compile the files first, once you have all your files compiled, you can put it in any folder inside web apps (even ROOT, but should be empty), the app will use the folder name as context path (Except for ROOT that deploys in "/")

Categories : Java

Upgrade to Postgres 9.2 (incl. Hibernate) & Tomcat 7
Read the release notes for the products in question. The PostgreSQL release notes are here and you should at minimum read the upgrade and compatibility advice for each .0 version (8.3.0, 8.4.0, 9.0.0, 9.1.0 and 9.2.0) to make sure you are prepared for any changes you may need to deal with. See the version policy for guidance on why you need to care about 8.2 to 8.3, etc. In the case of PostgreSQL you absolutely must follow a proper upgrade process. The on-disk format database isn't compatible from 8.2 to 9.2. You must dump and reload, or use a more complex replication-based migration method using a 3rd party replication tool like Slony-I. (PostgreSQL 8.4 and newer can be in-place upgraded using the pg_upgrade tool, but this isn't available for DBs as old as 8.2. A dump and reload is req

Categories : Hibernate

Use webapp classpath using JavaCompiler in Tomcat within Eclipse with Maven
Put example-library.jar somewhere in your file system and pass that location to the code that runs JavaCompiler (the -classpath option). If you use an exploded WAR file to deploy, you can of course point it to the physical location within the WEB-INF/lib folder. The point is that you only need one configurable parameter in your webapp to do this, which can be a properties file entry, -D system property, database row or something else entirely. Sample code (tested in Tomcat 7 and OpenJDK 1.7 on Fedora 18 x64): private File compile(File javaFile, String classpath) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> comp

Categories : Eclipse

Unable to deploy my servlet from a Maven Project on Tomcat
Change <servlet-class>ConfigFileInput</servlet-class> to: <servlet-class>edu.apollogrp.dfe.configuration.masterconfig.ConfigFileInput</servlet-class> This should fix your error. And you should know some words about servlet life-cycle. There is no reqires of any main method in servlets.

Categories : Java

Jersey + Embedded Tomcat Minimal Maven Configuration
I would go for webapp-runner to run the web app. It deploys the maven generated war from /target into a built in tomcat container. This is how java applications gets deployed on Heroku. pom plugin configuration: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactIt

Categories : Maven

Maven - deploy webapp to tomcat before JUnit test
There are a number of schools of thought as to how to handle this type of integration test with Maven. I should point out that when you are deploying an application to an application server, you are not in the realm of unit testing any more. Because the entire application is being deployed within a container, you are testing the integration of those two components. Now there is nothing wrong with using JUnit for running integration tests (though there are some limitations that you may hit, for example unit tests should not care about the sequencing of individual tests - assuming you are writing them correctly - so JUnit enforces this by not guaranteeing any sequence of execution... prior to Java 1.7 the execution order was accidentally implied by the order of test methods within a class,

Categories : Maven

JSP debugging in IntelliJ IDEA using the Tomcat Maven Plugin
It is indeed possible. You need to run the Tomcat plugin with some extra configuration and then connect to it like it was a remote Tomcat instance. Create a Remote Debug Run Configuration Click "Run" then "Edit Configurations" Click "Add New Configuration" (a green plus symbol), then "Tomcat Server", then "Remote". Give the configuration a sensible name e.g. JSP Debug. Untick "After launch". Make sure the remote connection port is correct (8080 should be fine but you may have configured this differently with the plugin). Switch to the "Startup/Connection" tab and select "Debug". Look at the configuration line it gives you and copy this. You will need this in the next step. Create a Maven Tomcat Plugin Run Configuration Click "Add New Configuration" (a green plus symbol), then "Maven

Categories : Debugging

how to deploy multiple wars using the tomcat plugin in maven
I guess you cannot use the tomcat plugin on a pom type project, try instead to configure the plugin into one of the war projects and include the others as webapp dependencies with something like that : <configuration> <webapps> <webapp> <contextPath>/PAYSWeb</contextPath> <groupId>tr.com.provus.pays</groupId> <artifactId>PAYSWeb</artifactId> <version>${project.version}</version> <type>war</type> <asWebapp>true</asWebapp> </webapp> <webapp>...</webapp> </webapps> </configuration> Look also at this post (but unanswered)

Categories : Java

Maven-tomcat plugin - cannot specify location of external jars
I typically set up my companies nexus server as a repository in my global settings.xml thusly: <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> ... <profiles> <profile> <id>repositories</id> <repositories> <repository> <id>my-nexus</id> <name>My Nexus</name> <url>http://my.company.com/nexus/content/groups/public</url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>ne

Categories : Misc

Use Tomcat server with Hibernate and Springsource Tool Suite?
Your requirements as listed below: Spring Tools Suite : http://www.springsource.org/downloads/sts-ggts (Choose the appropriate version) For Tomcat 7 to be used on STS , you will need to download it from this link: http://tomcat.apache.org/download-70.cgi Update to JDK 7. Link: http://www.oracle.com/technetwork/java/javase/downloads/index.html To setup tomcat 7 in Spring Tools Suite (essentially Eclipse configured for Spring) use this link : http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html (Follow the same procedure for STS) You will also need to install a DBMS. Try using MySQL . Download it from : http://dev.mysql.com/downloads/mysql/ Also if you decide to use Eclipse for Spring (I do.. :P ), use this : http://www.eclipse.org/downloads/packages/eclipse-ide-j

Categories : Eclipse

SpringMVC + Hibernate Tomcat 500, json no stack trace
Got it working with a few changes… 1) The main/resources/log4j.xml should be set to debug to see the error: <logger name="org.springframework.context"> <level value="debug" /> </logger> <logger name="org.springframework.web"> <level value="debug" /> </logger> <!-- Root Logger --> <root> <priority value="debug" /> <appender-ref ref="console" /> </root> I was mistakenly editing the test/resources/log4j.xml first. Perhaps you did the same? Otherwise maybe your IDE is getting in the way, because as soon as I set the correct level on the log4j.xml I was seeing the logging in the terminal just fine. Initially I thought the error was because Chrome was asking for a /favicon.ico immediately after the login and

Categories : Java

Tomcat 7/Maven deploy fails, context path not found
The tomcat maven plugin has been moved to the Apache umbrella and been significantly updated since v1.1. I tried reverting to the mojo you're using, above, and could not get it to deploy either. There's a Tomcat7-specific mojo that works just fine. Try using <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> ... </configuration> </plugin> instead. You can find all the documentation at https://tomcat.apache.org/maven-plugin-2.1/index.html

Categories : Eclipse

Eclipse and tomcat but run web application from 'target' directory (created by maven)
I believe you have already installed eclipse m2e WTP support plugin. This plugins allows to configure your maven webapp projects to run with "Run on Server" option. In all cases, you will have to check whether your deployment assembly is collecting the right artifacts or not. With maven, we may need some of dependencies to be available while running the web application. So, you need to include such dependencies as a part of your deployment assembly. In deployment assembly section, make sure you add the maven dependencies also. And yes, with maven you don't have to worry about your .war file as m2e will add the contents of src/main/webapp , src/main/resouces, src/main/classes to the deployment assembly directely.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.