Search Results

Search found 548 results on 22 pages for 'springframework'.

Page 9/22 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Hibernate/Spring: failed to lazily initialize - no session or session was closed

    - by Niko
    I know something similar has been asked already, but unfortunately I wasn't able to find a reliable answer - even with searching for over 2 days. The basic problem is the same as asked multiple time. I have a simple program with two POJOs Event and User - where a user can have multiple events. @Entity @Table public class Event { private Long id; private String name; private User user; @Column @Id @GeneratedValue public Long getId() {return id;} public void setId(Long id) { this.id = id; } @Column public String getName() {return name;} public void setName(String name) {this.name = name;} @ManyToOne @JoinColumn(name="user_id") public User getUser() {return user;} public void setUser(User user) {this.user = user;} } @Entity @Table public class User { private Long id; private String name; private List events; @Column @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @OneToMany(mappedBy="user", fetch=FetchType.LAZY) public List getEvents() { return events; } public void setEvents(List events) { this.events = events; } } Note: This is a sample project. I really want to use Lazy fetching here. I use spring and hibernate and have a simple basic-db.xml for loading: <?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="thread" <property name="driverClassName" value="com.mysql.jdbc.Driver" / <property name="url" value="jdbc:mysql://192.168.1.34:3306/hibernateTest" / <property name="username" value="root" / <property name="password" value="" / <aop:scoped-proxy/ </bean <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer" <property name="scopes" <map <entry key="thread" <bean class="org.springframework.context.support.SimpleThreadScope" / </entry </map </property </bean <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" scope="thread" <property name="dataSource" ref="myDataSource" / <property name="annotatedClasses" <list <valuedata.model.User</value <valuedata.model.Event</value </list </property <property name="hibernateProperties" <props <prop key="hibernate.dialect"org.hibernate.dialect.MySQLDialect</prop <prop key="hibernate.show_sql"true</prop <prop key="hibernate.hbm2ddl.auto"create</prop </props </property <aop:scoped-proxy/ </bean <bean id="myUserDAO" class="data.dao.impl.UserDaoImpl" <property name="sessionFactory" ref="mySessionFactory" / </bean <bean id="myEventDAO" class="data.dao.impl.EventDaoImpl" <property name="sessionFactory" ref="mySessionFactory" / </bean </beans Note: I played around with the CustomScopeConfigurer and SimpleThreadScope, but that didnt change anything. I have a simple dao-impl (only pasting the userDao - the EventDao is pretty much the same - except with out the "listWith" function: public class UserDaoImpl implements UserDao{ private HibernateTemplate hibernateTemplate; public void setSessionFactory(SessionFactory sessionFactory) { this.hibernateTemplate = new HibernateTemplate(sessionFactory); } @SuppressWarnings("unchecked") @Override public List listUser() { return hibernateTemplate.find("from User"); } @Override public void saveUser(User user) { hibernateTemplate.saveOrUpdate(user); } @Override public List listUserWithEvent() { List users = hibernateTemplate.find("from User"); for (User user : users) { System.out.println("LIST : " + user.getName() + ":"); user.getEvents().size(); } return users; } } I am getting the org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: data.model.User.events, no session or session was closed at the line with user.getEvents().size(); And last but not least here is the Test class I use: public class HibernateTest { public static void main(String[] args) { ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("basic-db.xml"); UserDao udao = (UserDao) ac.getBean("myUserDAO"); EventDao edao = (EventDao) ac.getBean("myEventDAO"); System.out.println("New user..."); User user = new User(); user.setName("test"); Event event1 = new Event(); event1.setName("Birthday1"); event1.setUser(user); Event event2 = new Event(); event2.setName("Birthday2"); event2.setUser(user); udao.saveUser(user); edao.saveEvent(event1); edao.saveEvent(event2); List users = udao.listUserWithEvent(); System.out.println("Events for users"); for (User u : users) { System.out.println(u.getId() + ":" + u.getName() + " --"); for (Event e : u.getEvents()) { System.out.println("\t" + e.getId() + ":" + e.getName()); } } ((ConfigurableApplicationContext)ac).close(); } } and here is the Exception I get: 1621 [main] ERROR org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: data.model.User.events, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: data.model.User.events, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372) at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:119) at org.hibernate.collection.PersistentBag.size(PersistentBag.java:248) at data.dao.impl.UserDaoImpl.listUserWithEvent(UserDaoImpl.java:38) at HibernateTest.main(HibernateTest.java:44) Exception in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: data.model.User.events, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372) at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:119) at org.hibernate.collection.PersistentBag.size(PersistentBag.java:248) at data.dao.impl.UserDaoImpl.listUserWithEvent(UserDaoImpl.java:38) at HibernateTest.main(HibernateTest.java:44) Things I tried but did not work: assign a threadScope and using beanfactory (I used "request" or "thread" - no difference noticed): // scope stuff Scope threadScope = new SimpleThreadScope(); ConfigurableListableBeanFactory beanFactory = ac.getBeanFactory(); beanFactory.registerScope("request", threadScope); ac.refresh(); ... Setting up a transaction by getting the session object from the deo: ... Transaction tx = ((UserDaoImpl)udao).getSession().beginTransaction(); tx.begin(); users = udao.listUserWithEvent(); ... getting a transaction within the listUserWithEvent() public List listUserWithEvent() { SessionFactory sf = hibernateTemplate.getSessionFactory(); Session s = sf.openSession(); Transaction tx = s.beginTransaction(); tx.begin(); List users = hibernateTemplate.find("from User"); for (User user : users) { System.out.println("LIST : " + user.getName() + ":"); user.getEvents().size(); } tx.commit(); return users; } I am really out of ideas by now. Also, using the listUser or listEvent just work fine.

    Read the article

  • Weblogic JMS System Error

    - by Jeune
    We're getting a JMS error which we don't have a lot to go with: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is weblogic.jms.common.JMSException:[JMSClientExceptions:055039] A system error has occurred. The error is java.lang.NullPointerException; nested exception is java.lang.NullPointerException at com.pg.ecom.jms.service.ProducerServices.SendMessageSync(ProducerServices.java:131) at com.pg.ecom.jms.service.ProducerServices.SendMessageSync(ProducerServices.java:115) at com.pg.ecom.jms.producer.FormsCRRProducer.sendMessage(FormsCRRProducer.java:56) at com.pg.ecom.cpgt.processruleagent.managerbean.forms.GenerateFormsManagerBean.useNewGetTemplateData(GenerateFormsManagerBean.java:522) at com.pg.ecom.cpgt.processruleagent.managerbean.forms.GenerateFormsManagerBean.doService(GenerateFormsManagerBean.java:114) at com.pg.ecom.fw.processcontainer.AbstractManagerBean.doServiceWrapper(AbstractManagerBean.java:175) at com.pg.ecom.fw.processcontainer.AbstractManagerBean.doServiceRequest(AbstractManagerBean.java:151) at com.pg.ecom.fw.processcontainer.AbstractServlet.doManagerBeanServiceAndPresentation(AbstractServlet.java:1911) at com.pg.ecom.cpgt.processunit.servlet.CportalParamServlet.doService(CportalParamServlet.java:107) at com.pg.ecom.fw.processcontainer.AbstractServlet.service(AbstractServlet.java:983) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.pg.ecom.cpgt.processunit.filter.UploadMultipartFilter.doFilter(UploadMultipartFilter.java:28) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3229) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) The only lead I have is line 127 in the code which is indicated by this error: Caused by: weblogic.jms.common.JMSException: [JMSClientExceptions:055039]A system error has occurred. The error is java.lang.Nul lPointerException at weblogic.jms.client.JMSSession.handleException(JMSSession.java:2853) at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:629) at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:488) at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:155) at org.springframework.jms.core.JmsTemplate.doReceive(JmsTemplate.java:734) at org.springframework.jms.core.JmsTemplate.doReceive(JmsTemplate.java:706) at org.springframework.jms.core.JmsTemplate$9.doInJms(JmsTemplate.java:681) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:447) at org.springframework.jms.core.JmsTemplate.receiveSelected(JmsTemplate.java:679) at org.springframework.jms.core.JmsTemplate.receiveSelectedAndConvert(JmsTemplate.java:784) at com.pg.ecom.jms.service.ProducerServices.SendMessageSync(ProducerServices.java:127) ... 25 more This is line 127: try { Thread.yield(); //line 127 below status=(StatusMessageBean)getJmsTemplate.receiveSelectedAndConvert(statusDestination, "JMSCorrelationID='"+ producerMsg.getProcessID() +"'"); Thread.yield(); } catch (Exception e) { Thread.yield(); loggingInterface.doErrorLogging(e.fillInStackTrace()); } According to the BEA documentation, we should contact BEA about error 055039 but I would like to try asking here first before bringing this to them? Some more errors: Caused by: java.lang.NullPointerException at weblogic.jms.common.JMSVariableBinder$JMSCorrelationIDVariable.get(JMSVariableBinder.java:127) at weblogic.utils.expressions.Expression.evaluateExpr(Expression.java:271) at weblogic.utils.expressions.Expression.evaluateExpr(Expression.java:298) at weblogic.utils.expressions.Expression.evaluateBoolean(Expression.java:209) at weblogic.utils.expressions.Expression.evaluate(Expression.java:167) at weblogic.jms.common.JMSSQLFilter$Exp.evaluate(JMSSQLFilter.java:304) at weblogic.messaging.common.SQLFilter.match(SQLFilter.java:158) at weblogic.messaging.kernel.internal.MessageList.findNextVisible(MessageList.java:274) at weblogic.messaging.kernel.internal.QueueImpl.nextFromIteratorOrGroup(QueueImpl.java:441) at weblogic.messaging.kernel.internal.QueueImpl.nextMatchFromIteratorOrGroup(QueueImpl.java:350) at weblogic.messaging.kernel.internal.QueueImpl.get(QueueImpl.java:233) at weblogic.messaging.kernel.internal.QueueImpl.addReader(QueueImpl.java:1069) at weblogic.messaging.kernel.internal.ReceiveRequestImpl.start(ReceiveRequestImpl.java:178) at weblogic.messaging.kernel.internal.ReceiveRequestImpl.<init>(ReceiveRequestImpl.java:86) at weblogic.messaging.kernel.internal.QueueImpl.receive(QueueImpl.java:820) at weblogic.jms.backend.BEConsumerImpl.blockingReceiveStart(BEConsumerImpl.java:1172) at weblogic.jms.backend.BEConsumerImpl.receive(BEConsumerImpl.java:1383) at weblogic.jms.backend.BEConsumerImpl.invoke(BEConsumerImpl.java:1088) at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:759) at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsyncInternal(DispatcherImpl.java:129) at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:112) at weblogic.messaging.dispatcher.Request.dispatchAsync(Request.java:1046) at weblogic.jms.dispatcher.Request.dispatchAsync(Request.java:72) at weblogic.jms.frontend.FEConsumer.receive(FEConsumer.java:557) at weblogic.jms.frontend.FEConsumer.invoke(FEConsumer.java:806) at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:759) at weblogic.messaging.dispatcher.DispatcherServerRef.invoke(DispatcherServerRef.java:276) at weblogic.messaging.dispatcher.DispatcherServerRef.handleRequest(DispatcherServerRef.java:141) at weblogic.messaging.dispatcher.DispatcherServerRef.access$000(DispatcherServerRef.java:36) at weblogic.messaging.dispatcher.DispatcherServerRef$2.run(DispatcherServerRef.java:112) ... 2 more Any ideas?

    Read the article

  • Loading Properties with Spring (via System Properties)

    - by gabe
    My problem is as follows: I have server.properties for different environments. The path to those properties is provided trough a system property called propertyPath. How can I instruct my applicationContext.xml to load the properties with the given propertyPath system property without some ugly MethodInvokingBean which calls System.getProperty(''); My applicationContext.xml <bean id="systemPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/> <property name="placeholderPrefix" value="sys{"/> <property name="properties"> <props> <prop key="propertyPath">/default/path/to/server.properties</prop> </props> </property> </bean> <bean id="propertyResource" class="org.springframework.core.io.FileSystemResource" dependency-check="all" depends-on="systemPropertyConfigurer"> <constructor-arg value="sys{propertyPath}"/> </bean> <bean id="serviceProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" ref="propertyResource"/> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" ref="propertyResource"/> <property name="placeholderPrefix" value="prop{"/> <property name="ignoreUnresolvablePlaceholders" value="true"/> <property name="ignoreResourceNotFound" value="false"/> </bean> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="prop{datasource.name}"/> </bean> with this configuration the propertyResource alsways complains about java.io.FileNotFoundException: sys{propertyPath} (The system cannot find the file specified) Any suggestions? ;-) Thanks gabe

    Read the article

  • NoPrimaryKeyException from DBUnit when loading a dataset into a databse

    - by Omar Kooheji
    I'm getting NoPrimaryKeyException when I try to run one of my unit tests which uses DBUnit. The datatable is created using Hibernate and is a join table between two classes mapping a many to many relationship. The annotations that define the relationship are as follows: @Override @ManyToMany @JoinTable(name="offset_file_offset_entries", joinColumns={@JoinColumn(name="offset_entry_id")},inverseJoinColumns={@JoinColumn(name="file_description_id")}) public List<OffsetEntry> getOffsets() { The other entries in in the XML file I'm using to define the dataset seem to work fine but not the join table. I get the following exception: org.dbunit.dataset.NoPrimaryKeyException: offset_file_offset_entries at org.dbunit.operation.UpdateOperation.getOperationData(UpdateOperation.java:72) at org.dbunit.operation.RefreshOperation$UpdateRowOperation.<init>(RefreshOperation.java:266) at org.dbunit.operation.RefreshOperation.createUpdateOperation(RefreshOperation.java:142) at org.dbunit.operation.RefreshOperation.execute(RefreshOperation.java:100) at org.dbunit.ext.mssql.InsertIdentityOperation.execute(InsertIdentityOperation.java:217) at uk.co.sabio.obscheduler.application.dao.AbstractBaseDatabaseTest.setUp(AbstractBaseDatabaseTest.java:57) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.runManaged(AbstractJUnit38SpringContextTests.java:332) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.access$0(AbstractJUnit38SpringContextTests.java:326) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests$1.run(AbstractJUnit38SpringContextTests.java:216) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.runTest(AbstractJUnit38SpringContextTests.java:296) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.runTestTimed(AbstractJUnit38SpringContextTests.java:253) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.runBare(AbstractJUnit38SpringContextTests.java:213) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) the Dataset entry in question looks like this: <offset_file_offset_entries offset_entry_id="1" file_description_id="1" /> And matches up with the database which has both fields as primary keys (The Databse is MS SQL Server if that helps) There are corresponding entries in the two tables being Joined defined in the following xml: <dataset> <file_description file_path="src/test/resources/" file_pattern=".txt" file_description_id="1"/> <offset_file_description file_description_id="1"/> <offset_entries offset_entry_id="1" field_name="Field1" field_length="10" start_index="0"/> <offset_file_offset_entries offset_entry_id="1" file_description_id="1" /> </dataset> Do I have to define the primary keys in the hibernate annotations? If so How do I do so? do I have to change the way I define my dataset to imply that the two columns are a joint primary key? I'm not very proficient with hibernate or DBUnit for that matter and I'm at my wits end so any assistance would be really appreciated.

    Read the article

  • How to unit test a Spring MVC controller using @PathVariable?

    - by Martiner
    I have a simple annotated controller similar to this one: @Controller public class MyController { @RequestMapping("/{id}.html") public String doSomething(@PathVariable String id, Model model) { // do something return "view"; } } and I want to test it with an unit test like this: public class MyControllerTest { @Test public void test() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRequestURI("/test.html"); new AnnotationMethodHandlerAdapter() .handle(request, new MockHttpServletResponse(), new MyController()); // assert something } } The problem is that AnnotationMethodHandlerAdapter.handler() method throws an exception: java.lang.IllegalStateException: Could not find @PathVariable [id] in @RequestMapping at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.resolvePathVariable(AnnotationMethodHandlerAdapter.java:642) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolvePathVariable(HandlerMethodInvoker.java:514) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:262) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:146)

    Read the article

  • FileNotFoundException, altough the XML file should be deployed

    - by Bernhard V
    Hi, I've got problems starting my WAR application on a local JBoss. After two other EARs are deployed and the TomcatDeployer begins deploying the WAR, I'm getting the following error message: 2010-04-28 10:01:56,605 ERROR [org.jboss.ejb.plugins.LogInterceptor] [] [main] EJBException in method: public abstract at.sozvers.stp.zpv.ejb.lea.rwsuc.EJBLeaRegelwerkSuchenRemote at.sozvers.stp.zpv.ejb.lea.rwsuc.EJBLeaRegelwerkSuchenHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy: javax.ejb.EJBException: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:applicationContext.xml], factory key [contextService]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextService' defined in URL [jar:file:/C:/ta30/nutzb/jboss-4.2.3.GA.ZPV/server/default/deploy/deploy.last/zpv-app-web-frontend-1.0-SNAPSHOT.war/WEB-INF/lib/zpv-comp-ejb-modules-1.0-SNAPSHOT-client.jar!/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [at/sozvers/stp/zpv/dao/ContextBasic.xml]; nested exception is java.io.FileNotFoundException: class path resource [at/sozvers/stp/zpv/dao/ContextBasic.xml] cannot be opened because it does not exist The sad thing is that the resource at/sozvers/stp/zpv/dao/ContextBasic.xml actually is placed in a JAR in one of my EAR files which should be deployed before the WAR. And at least I get a message that the deployment of the EAR has been successful. I also looked into the JAR with my file archiver and the ContextBasic.xml is indeed there at the right place. Is there a way for me to get sure that the JAR, not the EAR as a whole, is really deployed to the JBoss? I'm already starting to lose my head about this issue. Thank you. Bernhard

    Read the article

  • Spring security - Reach users ID without passing it through every controller

    - by nilsi
    I have a design issue that I don't know how to solve. I'm using Spring 3.2.4 and Spring security 3.1.4. I have a Account table in my database that looks like this: create table Account (id identity, username varchar unique, password varchar not null, firstName varchar not null, lastName varchar not null, university varchar not null, primary key (id)); Until recently my username was just only a username but I changed it to be the email address instead since many users want to login with that instead. I have a header that I include on all my pages which got a link to the users profile like this: <a href="/project/users/<%= request.getUserPrincipal().getName()%>" class="navbar-link"><strong><%= request.getUserPrincipal().getName()%></strong></a> The problem is that <%= request.getUserPrincipal().getName()%> returns the email now, I don't want to link the user's with thier emails. Instead I want to use the id every user have to link to the profile. How do I reach the users id's from every page? I have been thinking of two solutions but I'm not sure: Change the principal to contain the id as well, don't know how to do this and having problem finding good information on the topic. Add a model attribute to all my controllers that contain the whole user but this would be really ugly, like this. Account account = entityManager.find(Account.class, email); model.addAttribute("account", account); There are more way's as well and I have no clue which one is to prefer. I hope it's clear enough and thank you for any help on this. ====== Edit according to answer ======= I edited Account to implement UserDetails, it now looks like this (will fix the auto generated stuff later): @Entity @Table(name="Account") public class Account implements UserDetails { @Id private int id; private String username; private String password; private String firstName; private String lastName; @ManyToOne private University university; public Account() { } public Account(String username, String password, String firstName, String lastName, University university) { this.username = username; this.password = password; this.firstName = firstName; this.lastName = lastName; this.university = university; } public String getUsername() { return username; } public String getPassword() { return password; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setUsername(String username) { this.username = username; } public void setPassword(String password) { this.password = password; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public University getUniversity() { return university; } public void setUniversity(University university) { this.university = university; } public int getId() { return id; } public void setId(int id) { this.id = id; } @Override public Collection<? extends GrantedAuthority> getAuthorities() { // TODO Auto-generated method stub return null; } @Override public boolean isAccountNonExpired() { // TODO Auto-generated method stub return false; } @Override public boolean isAccountNonLocked() { // TODO Auto-generated method stub return false; } @Override public boolean isCredentialsNonExpired() { // TODO Auto-generated method stub return false; } @Override public boolean isEnabled() { // TODO Auto-generated method stub return true; } } I also added <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> To my jsp files and trying to reach the id by <sec:authentication property="principal.id" /> This gives me the following org.springframework.beans.NotReadablePropertyException: Invalid property 'principal.id' of bean class [org.springframework.security.authentication.UsernamePasswordAuthenticationToken]: Bean property 'principal.id' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? ====== Edit 2 according to answer ======= I based my application on spring social samples and I never had to change anything until now. This are the files I think are relevant, please tell me if theres something you need to see besides this. AccountRepository.java public interface AccountRepository { void createAccount(Account account) throws UsernameAlreadyInUseException; Account findAccountByUsername(String username); } JdbcAccountRepository.java @Repository public class JdbcAccountRepository implements AccountRepository { private final JdbcTemplate jdbcTemplate; private final PasswordEncoder passwordEncoder; @Inject public JdbcAccountRepository(JdbcTemplate jdbcTemplate, PasswordEncoder passwordEncoder) { this.jdbcTemplate = jdbcTemplate; this.passwordEncoder = passwordEncoder; } @Transactional public void createAccount(Account user) throws UsernameAlreadyInUseException { try { jdbcTemplate.update( "insert into Account (firstName, lastName, username, university, password) values (?, ?, ?, ?, ?)", user.getFirstName(), user.getLastName(), user.getUsername(), user.getUniversity(), passwordEncoder.encode(user.getPassword())); } catch (DuplicateKeyException e) { throw new UsernameAlreadyInUseException(user.getUsername()); } } public Account findAccountByUsername(String username) { return jdbcTemplate.queryForObject("select username, firstName, lastName, university from Account where username = ?", new RowMapper<Account>() { public Account mapRow(ResultSet rs, int rowNum) throws SQLException { return new Account(rs.getString("username"), null, rs.getString("firstName"), rs.getString("lastName"), new University("test")); } }, username); } } security.xml <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <http pattern="/resources/**" security="none" /> <http pattern="/project/" security="none" /> <http use-expressions="true"> <!-- Authentication policy --> <form-login login-page="/signin" login-processing-url="/signin/authenticate" authentication-failure-url="/signin?error=bad_credentials" /> <logout logout-url="/signout" delete-cookies="JSESSIONID" /> <intercept-url pattern="/addcourse" access="isAuthenticated()" /> <intercept-url pattern="/courses/**/**/edit" access="isAuthenticated()" /> <intercept-url pattern="/users/**/edit" access="isAuthenticated()" /> </http> <authentication-manager alias="authenticationManager"> <authentication-provider> <password-encoder ref="passwordEncoder" /> <jdbc-user-service data-source-ref="dataSource" users-by-username-query="select username, password, true from Account where username = ?" authorities-by-username-query="select username, 'ROLE_USER' from Account where username = ?"/> </authentication-provider> <authentication-provider> <user-service> <user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" /> </user-service> </authentication-provider> </authentication-manager> </beans:beans> And this is my try of implementing a UserDetailsService public class RepositoryUserDetailsService implements UserDetailsService { private final AccountRepository accountRepository; @Autowired public RepositoryUserDetailsService(AccountRepository repository) { this.accountRepository = repository; } @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Account user = accountRepository.findAccountByUsername(username); if (user == null) { throw new UsernameNotFoundException("No user found with username: " + username); } return user; } } Still gives me the same error, do I need to add the UserDetailsService somewhere? This is starting to be something else compared to my initial question, I should maybe start another question. Sorry for my lack of experience in this. I have to read up.

    Read the article

  • using quartz with out the quartz plugin in grails

    - by user511875
    i'm trying to use quartz to schedule jobs in grails with out using the plugin. this is the code: RunMeTask.java package tt; public class RunMeTask { public void printMe() { System.out.println("Run Me ~"); }} resources.groovy (under conf/spring) import org.springframework.scheduling.quartz.JobDetailFactoryBean; import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.scheduling.quartz.SimpleTriggerBean; import tt.RunMeTask beans = { runMeTask(RunMeTask){ } runMeJob(JobDetailFactoryBean){ targetObject = ref('runMeTask') targetMethod = "printMe" } simpleTrigger(SimpleTriggerBean){ jobDetail = ref('runMeJob') repeatInterval = "5000" startpDelay = "1000" } schedulerFactoryBean(SchedulerFactoryBean){ jobDetails = [ref('runMeJob')] triggers = [ref('simpleTrigger')] } } i get the following exception: Error Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.SimpleTriggerBean has interface org.quartz.SimpleTrigger as super class (Use --stacktrace to see the full trace) can anyone help?

    Read the article

  • JPA thinks I'm deleting a detached object

    - by Steve
    So, I've got a DAO that I used to load and save my domain objects using JPA. I finally managed to get the transaction stuff working (with a bunch of help from the folks here...), now I've got another issue. In my test case, I call my DAO to load a domain object with a given id, check that it got loaded and then call the same DAO to delete the object I just loaded. When I do that I get the following: java.lang.IllegalArgumentException: Removing a detached instance mil.navy.ndms.conops.common.model.impl.jpa.Group#10 at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:45) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:108) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74) at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:794) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:772) at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:253) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:600) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:180) at $Proxy27.remove(Unknown Source) at mil.navy.ndms.conops.common.dao.impl.jpa.GroupDao.delete(GroupDao.java:499) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:600) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy28.delete(Unknown Source) at mil.navy.ndms.conops.common.dao.impl.jpa.GroupDaoTest.testGroupDaoSave(GroupDaoTest.java:89) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:600) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Now given that I'm using the same DAO instance, and I've not changed EntityManagers (unless Spring does so without letting me know), how can this be a detached object? My DAO code looks like this: public class GenericJPADao implements IWebDao, IDao, IDaoUtil { private static Logger logger = Logger.getLogger (GenericJPADao.class); protected Class voClass; @PersistenceContext(unitName = "CONOPS_PU") protected EntityManagerFactory emf; @PersistenceContext(unitName = "CONOPS_PU") protected EntityManager em; public GenericJPADao() { super ( ); ParameterizedType genericSuperclass = (ParameterizedType) getClass ( ).getGenericSuperclass ( ); this.voClass = (Class) genericSuperclass.getActualTypeArguments ( )[1]; } ... public void delete (INTFC modelObj, EntityManager em) { em.remove (modelObj); } @SuppressWarnings("unchecked") public INTFC findById (Long id) { return ((INTFC) em.find (voClass, id)); } } The test case code looks like: IGroup loadedGroup = dao.findById (group.getId ( )); assertNotNull (loadedGroup); assertEquals (group.getId ( ), loadedGroup.getId ( )); dao.delete (loadedGroup); // - This generates the above exception loadedGroup = dao.findById (group.getId ( )); assertNull(loadedGroup); Can anyone tell me what I'm doing wrong here? Thanks

    Read the article

  • sermyadmin 2.01

    - by lepricon123
    I am able to install sermyadmin 2.0.1 and got everything working. Only user registration is not working. When I register a user the entry goe sin DB etc find but the email is not send to the user. We are using our own smtp server with no authentication. And I am sure there is nothing wrong with the smtp server. I can see that it has received a request from sermyadmin but in the logs Is ee that the FROM adddress is missing. So it is throwing 553 5.1.8 Domain of sender address does not exist. The domain does exist. Here is my resources.xml with all the valid entries. Since I don;t need the smtp authentication which the server is not using, i removed that. <beans xmlns="www.springframework.org/schema/beans" xmlns:xsi="www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" www.springframework.org/schema/beans www.springframework.org/schema/beans/spr...ns-2.0.xsd"> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="10.100.22.365" /> </bean> <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from" value="[email protected]" /> </bean> </beans>

    Read the article

  • What is the correct way to configure a spring TextEncryptor for use on Heroku

    - by Ollie Edwards
    I have a spring TextEncryptor defined like this <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" factory-method="text"> <constructor-arg value="${security.encryptPassword}" /> <constructor-arg value="${security.encryptSalt}" /> </bean> Which is fed these properties security.encryptPassword=47582920264f212c566d5e5a6d security.encryptSalt=39783e315e6a207e733d6f4141 Which works fine on my local environment. When I deploy to Heroku I get java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:110) at org.springframework.security.crypto.encrypt.AesBytesEncryptor.encrypt(AesBytesEncryptor.java:65) at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.encrypt(HexEncodingTextEncryptor.java:36) ... Caused by: java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:972) at javax.crypto.Cipher.implInit(Cipher.java:738) at javax.crypto.Cipher.chooseProvider(Cipher.java:797) at javax.crypto.Cipher.init(Cipher.java:1276) at javax.crypto.Cipher.init(Cipher.java:1215) at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:105) ... 53 more So I tried some smaller keys but I always get the same problem. What is the correct key size to use on Heroku?

    Read the article

  • FileNotFoundException, although the XML file should be deployed

    - by Bernhard V
    Hi, I've got problems starting my WAR application on a local JBoss. After two other EARs are deployed and the TomcatDeployer begins deploying the WAR, I'm getting the following error message: 2010-04-28 10:01:56,605 ERROR [org.jboss.ejb.plugins.LogInterceptor] [] [main] EJBException in method: public abstract at.sozvers.stp.zpv.ejb.lea.rwsuc.EJBLeaRegelwerkSuchenRemote at.sozvers.stp.zpv.ejb.lea.rwsuc.EJBLeaRegelwerkSuchenHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy: javax.ejb.EJBException: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:applicationContext.xml], factory key [contextService]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextService' defined in URL [jar:file:/C:/ta30/nutzb/jboss-4.2.3.GA.ZPV/server/default/deploy/deploy.last/zpv-app-web-frontend-1.0-SNAPSHOT.war/WEB-INF/lib/zpv-comp-ejb-modules-1.0-SNAPSHOT-client.jar!/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [at/sozvers/stp/zpv/dao/ContextBasic.xml]; nested exception is java.io.FileNotFoundException: class path resource [at/sozvers/stp/zpv/dao/ContextBasic.xml] cannot be opened because it does not exist The sad thing is that the resource at/sozvers/stp/zpv/dao/ContextBasic.xml actually is placed in a JAR in one of my EAR files which should be deployed before the WAR. And at least I get a message that the deployment of the EAR has been successful. I also looked into the JAR with my file archiver and the ContextBasic.xml is indeed there at the right place. Is there a way for me to get sure that the JAR, not the EAR as a whole, is really deployed to the JBoss? I'm already starting to lose my head about this issue. Thank you. Bernhard

    Read the article

  • java.lang.ClassCastException: java.lang.Integer cannot be cast

    - by theJava
    When i click on login, it checks the DB if there is a value matching then i get this error, else it does print me null. public Login authenticate(Login login) { String query = "SELECT 1 FROM Login AS l WHERE l.email=? AND l.password=?"; Object[] parameters = { login.getEmail(), login.getPassword() }; List resultsList = getHibernateTemplate().find(query,parameters); if (resultsList.isEmpty()) { } else if (resultsList.size() > 1) { } else { Login login1 = (Login) resultsList.get(0); System.out.println("Hello" + login1); return login1; } return null; } Error below Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to com.intermedix.domain.Login at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1154) at com.vaadin.ui.Button.fireClick(Button.java:371) at com.vaadin.ui.Button.changeVariables(Button.java:193) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590) at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266) at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to com.intermedix.domain.Login at com.intermedix.services.LoginService.authenticate(LoginService.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy32.authenticate(Unknown Source) at com.intermedix.ui.LoginDailog.checkLogin(LoginDailog.java:106) at com.intermedix.ui.LoginDailog.access$0(LoginDailog.java:102) at com.intermedix.ui.LoginDailog$1.buttonClick(LoginDailog.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487) ... 26 more

    Read the article

  • Spring MVC Project's .war file not able to deploy using JRE in jetty server

    - by PDKumar
    IDE: STS(Eclipse) Server: Jetty-distribution-8.1.15.v20140411 I have created a SpringsMVC Project using Template available in STS tool(New-Springs Project- Springs MVC Project). I generated a war file(SpringsMVC.war) and placed it in /webapps folder of Jetty server. Now I started Jetty using JRE's 'java' , D:\jetty-distribution-8.1.15.v20140411"C:\Program Files (x86)\Java\jre7\bin\java" -jar start.jar Now when I tried to access my application in browser, it shows the below error; HTTP ERROR 500 Problem accessing /SpringMVCProject1/. Reason: Server Error Caused by: org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:119) at org.apache.jasper.compiler.Jsr199JavaCompiler.compile(Jsr199JavaCompiler.java:208) at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:384) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:276) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Unknown Source) But if I use JDK's java, war file gets deployed and output displayed perfectly. D:\jetty-distribution-8.1.15.v20140411"C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java" -jar start.jar Hello world! The time on the server is August 20, 2014 3:42:53 PM IST. Please tell is it not possible to use JRE to execute a "SpringsMVCProject"?

    Read the article

  • HQL : LEFT OUTER JOIN

    - by Parama
    Hi all, I have two tables and respective classes in java.The mapping in the HBM.xml is as follows : The query in the HBM.xml is as follows : from Reports as rep left join rep.parts as parts I am getting the following exception while executing the code : May 19, 2010 10:47:04 AM org.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 904, SQLState: 42000 May 19, 2010 10:47:04 AM org.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: ORA-00904: "REPORTS0_"."PARTNO": invalid identifier org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2223) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at com.hcl.spring.db.sample.dao.ItemDAOImpl.loadItems(ItemDAOImpl.java:43) at com.hcl.spring.db.sample.service.ItemServiceImpl.loadItems(ItemServiceImpl.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy3.loadItems(Unknown Source) at com.hcl.spring.db.sample.Main.loadItems(Main.java:40) at com.hcl.spring.db.sample.Main.main(Main.java:19) Caused by: java.sql.SQLException: ORA-00904: "REPORTS0_"."PARTNO": invalid identifier at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) at org.hibernate.loader.Loader.getResultSet(Loader.java:1787) at org.hibernate.loader.Loader.doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) ... 22 more Do request your help on the same.

    Read the article

  • UndeclaredThrowableException due to SQLException in Spring + iBatis?

    - by jr
    Hello, I am getting the following exception when I typo the SQL driver name or the database server is offline, basically any SQLException. I can't determine where the UndeclaredThrowableException is coming from. Line 194 in SqlMapClientTemplate is this: logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation"); Here is the trace: java.lang.reflect.UndeclaredThrowableException $Proxy59.toString(Unknown Source) java.lang.String.valueOf(Unknown Source) java.lang.StringBuffer.append(Unknown Source) org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194) org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249) org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296) org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290) some of my reading points to some type of class loading problem? I can't figure out where the $Proxy is getting introduced?

    Read the article

  • Spring webflow 1.0 - Downloading a file

    - by Dave
    I am using spring webflow 1.0. I am uploading a csv file, parsing it, and displying results before proceeding. The user has an option to download a csv file that contains the records that did not pass validation. When I click the link in a JSP to download this file, webflow invokes a form Action. The form action writes out a file via getting the output stream off the response: HttpServletResponse response = ((ServletExternalContext) context.getExternalContext()).getResponse(); I do not want to leave the jsp I'm currently on. I just want to download the file. In other words, I do not want to transition to another state. I just want to serve the dynamically rendered file. Everything works (I don't leave the page, and I download the file), but I'm getting the following error in my console: _pEncydKfggPHJo8=org.springframework.webflow.engine.NoMatchingTransitionException: No transition was matched on the event(s) signaled by the [1] action(s) that executed in this action state 'downloadErrorReportAction' of flow 'myFlow'; transitions must be defined to handle action result outcomes -- possible flow configuration error? Note: the eventIds signaled were: 'array<String>[[null]]', while the supported set of transitional criteria for this action state is 'array<TransitionCriteria>[[empty]]' at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:187) at org.springframework.webflow.engine.State.enter(State.java:191) at org.springframework.webflow.engine.Transition.execute(Transition.java:212) at org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107) at org.springframework.webflow.engine.Flow.onEvent(Flow.java:534) Truncated. see log file for complete stacktrace Here is the relevant portion of my webflow config. <view-state id="showUploadResults" view="UploadResults3.0"> <render-actions> <action bean="UploadResultsAction" method="transitionToWebflow"/> <action bean="UploadResultsAction" method="setupData"/> </render-actions> <transition on="submit" to="proceed"/> <transition on="downloadErrorReport" to="downloadErrorReportAction"/> </view-state> <action-state id="downloadErrorReportAction"> <action bean="UploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/> </action-state>

    Read the article

  • Spring/Hibernate: InvocationTargetException when deleting entity

    - by niklassaers
    I'm sorry if this question is a bit vague, but I'm quite confused. I've got a controller that calls a service to delete an entity and then create an entity in its place. In the service, I've got my DAO, and my entity, and I want to delete my entity, so I call DAO.delete(entity); Then, seemingly out of nowhere, I get an InvocationTargetException. The parameters here are: method: public org.springframework.web.servlet.ModelAndView tld.myproject.view.web.controller.MyController.replaceEntity(org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest) target: tld.myproject.view.web.controller.MyController@185918e args: [org.springframework.web.multipart.commons.CommonsMultipartFile@14812a6, org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest@c08a64] ex: java.lang.reflect.InvocationTargetException private Object doInvokeMethod(Method method, Object target, Object[] args) throws Exception { ReflectionUtils.makeAccessible(method); try { return method.invoke(target, args); } catch (InvocationTargetException ex) { ReflectionUtils.rethrowException(ex.getTargetException()); } throw new IllegalStateException("Should never get here"); } Does anyone have a suggestion to what's going on? Anything I can use in my debugging? Cheers Nik

    Read the article

  • Spring-MVC Problem using @Controller on controller implementing an interface

    - by layne
    I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works. For example, @Controller @RequestMapping("url-mapping-here") public class Foo { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } works fine. When the context starts up, the urls this handler deals with are discovered, and everything works great. This however does not: @Controller @RequestMapping("url-mapping-here") public class Foo implements Bar { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } When I try to pull up the url, I get the following nasty stack trace: javax.servlet.ServletException: No adapter for handler [com.shaneleopard.web.controller.RegistrationController@e973e3]: Does your handler implement a supported interface like Controller? org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1091) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) javax.servlet.http.HttpServlet.service(HttpServlet.java:627) However, if I change Bar to be an abstract superclass and have Foo extend it, then it works again. @Controller @RequestMapping("url-mapping-here") public class Foo extends Bar { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } This seems like a bug. The @Controller annotation should be sufficient to mark this as a controller, and I should be able to implement one or more interfaces in my controller without having to do anything else. Any ideas?

    Read the article

  • Naming convention for utility classes in Java

    - by Zarjay
    When writing utility classes in Java, what are some good guidelines to follow? Should packges be "util" or "utils"? Is it ClassUtil or ClassUtils? When is a class a "Helper" or a "Utility"? Utility or Utilities? Or do you use a mixture of them? The standard Java library uses both Utils and Utilities: javax.swing.Utilities javax.print.attribute.AttributeSetUtilities javax.swing.plaf.basic.BasicGraphicsUtils Apache uses a variety of Util and Utils, although mostly Utils: org.apache.commons.modeler.util.DomUtil org.apache.commons.modeler.util.IntrospectionUtils org.apache.commons.io.FileSystemUtils org.apache.lucene.wordnet.AnalyzerUtil org.apache.lucene.util.ArrayUtil org.apache.lucene.xmlparser.DOMUtils Spring uses a lot of Helper and Utils classes: org.springframework.web.util.UrlPathHelper org.springframework.core.ReflectiveVisitorHelper org.springframework.core.NestedExceptionUtils org.springframework.util.NumberUtils So, how do you name your utility classes?

    Read the article

  • Wicket and Spring Intergation

    - by Vinothbabu
    I have a wicket contact form, and i receive the form object. Now i need to pass this object to Spring Service. package com.mysticcoders.mysticpaste.web.pages; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.FeedbackPanel; import com.mysticcoders.mysticpaste.model.Contact; import org.apache.wicket.model.CompoundPropertyModel; import com.mysticcoders.mysticpaste.services.IContact; public class FormPage extends WebPage { private Contact contact; private IContact icontact; public FormPage() { // Add a FeedbackPanel for displaying our messages FeedbackPanel feedbackPanel = new FeedbackPanel("feedback"); add(feedbackPanel); Form<Object> form = new Form<Object>("contactForm", new CompoundPropertyModel<Object>(contact)) { private static final long serialVersionUID = 1L; protected void onSubmit(Contact contact) { icontact.saveContact(contact); } }; form.add(new TextField<Object>("name")); form.add(new TextField<Object>("email")); form.add(new TextField<Object>("country")); form.add(new TextField<Object>("age")); add(form); // add a simple text field that uses Input's 'text' property. Nothing // can go wrong here } } I am pretty much sure that we need to do something with application-context xml where i may need to wire out. My Application-context.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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="WicketApplication" class="com.mysticcoders.mysticpaste.web.pages.WicketApplication" /> </beans> My Question is simple. What should i do which can make my onSubmit method call the Spring Service? Could someone let me know what needs to modified in my Application-context.xml so that once the form gets submitted, it contacts the Spring Service class.

    Read the article

  • Does Hibernate create tables in the database automatically.

    - by theJava
    http://www.vaannila.com/spring/spring-hibernate-integration-1.html Upon reading this tutorial, they have not mentioned anything over creating tables in the DB. Does the Hibernate handle it automatically by creating tables and fields once i specify them. Here is my beans configuration. <?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://127.0.0.1:3306/spring"/> <property name="username" value="monwwty"/> <property name="password" value="www"/> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="myDataSource" /> <property name="annotatedClasses"> <list> <value>uk.co.vinoth.spring.domain.User</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> </bean> <bean id="myUserDAO" class="uk.co.vinoth.spring.dao.UserDAOImpl"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> <bean name="/user/*.htm" class="uk.co.vinoth.spring.web.UserController" > <property name="userDAO" ref="myUserDAO" /> </bean> </beans>

    Read the article

  • Using Spring as a JPA Container

    - by sdoca
    Hi, I found this article which talks about using Spring as a JPA container: http://java.sys-con.com/node/366275 I have never used Spring before this and am trying to make this work and hope someone can help me. In the article it states that you need to annotate a Spring bean with @Transactional and methods/fields with @PersistenceContext in order to provide transaction support and to inject an entity manager. Is there something the defines a bean as a "Spring Bean"? I have a bean class which implements CRUD operations on entities using generics: @Transactional public class GenericCrudServiceBean implements GenericCrudService { @PersistenceContext(unitName="MyData") private EntityManager em; @Override @PersistenceContext public <T> T create(T t) { em.persist(t); return t; } @Override @PersistenceContext public <T> void delete(T t) { t = em.merge(t); em.remove(t); } ... ... ... @Override @PersistenceContext public List<?> findWithNamedQuery(String queryName) { return em.createNamedQuery(queryName).getResultList(); } } Originally I only had this peristence context annotation: @PersistenceContext(unitName="MyData") private EntityManager em; but had a null em when findWithNamedQuery was invoked. Then I annotated the methods as well, but em is still null (no injection?). I was wondering if this had something to do with my bean not being recognized as "Spring". I have done configuration as best I could following the directions in the article including setting the following in my context.xml file: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:tx="http://www.springframework.org/schema/tx" tx:schemaLocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="MyData" /> <property name="dataSource" ref="dataSource" /> <property name="loadTimeWeaver" class="org.springframework.classloading.ReflectiveLoadTimeWeaver" /> <property name="jpaVendorAdapter" ref="jpaAdapter" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@localhost:1521:MySID" /> <property name="username" value="user" /> <property name="password" value="password" /> <property name="initialSize" value="3" /> <property name="maxActive" value="10" /> </bean> <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> <property name="databasePlatform" value="org.eclipse.persistence.platform.database.OraclePlatform" /> <property name="showSql" value="true" /> </bean> <bean class="org.springframework.ormmjpa.support.PersistenceAnnotationBeanPostProcessor" /> <tx:annotation-driven /> </beans> I guessed that these belonged in the context.xml file because the article never specifically said which file is the "application context" file. If this is wrong, please let me know.

    Read the article

  • Error: java.lang.ClassCastException

    - by theJava
    Updating the entire post. public Login authenticate(Login login) { String query = "SELECT email, id FROM Login WHERE email=? AND password=?"; Object[] parameters = { login.getEmail(), login.getPassword() }; List resultsList = getHibernateTemplate().find(query,parameters); if ( resultsList.size() == 1 ) { results = (Login)resultsList.get(0); System.out.println(results); } else { System.out.println("Error dude.... "); // error no entity or mutiple entities } return results; } I now return Login Objects. private void checkLogin() { form.commit(); Login newUser = new Login(); newUser = ilogin.authenticate(loginbean); System.out.println("Its Null Value" + newUser); if (newUser == null) { getWindow().showNotification("Login failed", LOGIN_ERROR_MSG, Notification.TYPE_WARNING_MESSAGE); } else { System.out.println(newUser); getApplication().setUser(newUser); } } When there is no matching email, i get there is no such user and also this statement does get printed out. System.out.println("Its Null Value" + newUser); But when there is a email and password matching. I get weird error. Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.intermedix.domain.Login at com.intermedix.services.LoginService.authenticate(LoginService.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy32.authenticate(Unknown Source) at com.intermedix.ui.LoginDailog.checkLogin(LoginDailog.java:106) at com.intermedix.ui.LoginDailog.access$0(LoginDailog.java:102) at com.intermedix.ui.LoginDailog$1.buttonClick(LoginDailog.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487) ... 26 more

    Read the article

  • 404 with spring 3

    - by markjason72
    hi I am going through my first lessons with spring 3.I created a dynamic web app in eclipse with the following structure. spring3mvc \src\my.spring.HelloWorldController.java \WebContent | |-----WEB-INF\jsp\hello.jsp |-----index.jsp |-----web.xml |-----WEB-INF\spring-servlet.xml |-----WEB-INF\lib\...*.jar files I created the spring-servlet.xml as below <context:component-scan base-package="my.spring" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> and coded the controller package my.spring; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloWorldController { @RequestMapping("/hello") public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; return new ModelAndView("hello", "message", message); } } index.jsp has a link to hello view <html> <body> <a href="hello.html">Say Hello</a> </body> </html> finally in hello.jsp I have put <html> <body> ${message} </body> </html> My web.xml has <display-name>Spring3MVC</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <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> When I run the app on Tomcat6 server( thru eclipse),I can see the index page at http://localhost:8080/Spring3MVC/ .It displays the link to hello page.When I click on it(http://localhost:8080/Spring3MVC/hello.html),I get a 404 error. message /Spring3MVC/hello.html description The requested resource (/Spring3MVC/hello.html) is not available. Any idea how I can solve this? thanks mark.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >