-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem on Jboss 4.0.2 . works outside JBoss
PostPosted: Tue Sep 13, 2005 9:23 am 
Newbie

Joined: Tue May 18, 2004 8:55 am
Posts: 3
Hibernate version: 3.02

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.playlogix.traventure.ContentType" table="CONTENTTYPE">
        <id name="id" column="uid" type="long">
            <generator class="increment"/>
        </id>
        <property name="description" type="string" unique="true" not-null="true"/>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
The error occurs when I execute :
Code:
<%
InitialContext ctx = new InitialContext();


SessionFactory factory  = (SessionFactory)ctx.lookup("java:/hibernate/SessionFactory");

Session hsession = factory.openSession();
try {       
    ContentType contentType = new ContentType();
   contentType.setDescription("Article");
   
   hsession.save(contentType);
   contentType = new ContentType();
   contentType.setDescription("News");
   hsession.save(contentType);
   contentType = new ContentType();
   contentType.setDescription("Advert");
   hsession.save(contentType);
}catch (Exception e){
   e.printStackTrace();
} finally {
    hsession.close();
}   %>

inside a jsp file.

If I execute the following outside of JBoss, it works and the rows are inserted :
Code:
ContentType contentType = new ContentType();
      contentType.setDescription("Article14");
      session.save(contentType);
      contentType = new ContentType();
      contentType.setDescription("News14");
      session.save(contentType);
      contentType = new ContentType();
      contentType.setDescription("Advert14");
      session.save(contentType);




Full stack trace of any exception that occurs:

14:59:57,645 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: com.playlogix.traventure.ContentType, setter method of property: id
14:59:57,645 ERROR [BasicPropertyAccessor] expected type: java.lang.Long, actual value: java.lang.Long
14:59:57,672 INFO [STDOUT] org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.playlogix.traventure.ContentType.id
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:70)
at org.hibernate.tuple.AbstractTuplizer.setIdentifier(AbstractTuplizer.java:130)
at org.hibernate.persister.entity.BasicEntityPersister.setIdentifier(BasicEntityPersister.java:2930)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:146)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:467)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:462)
at org.apache.jsp.comment_jsp._jspService(org.apache.jsp.comment_jsp:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
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:585)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:40)
... 37 more


Name and version of the database you are using:
PostgreSQL 8.0

The generated SQL (show_sql=true):
No SQL generated . it fails before.

The java code for ContentType :

Code:
package com.playlogix.traventure;

import java.util.HashSet;
import java.util.Set;

import com.playlogix.util.XMLBuilder;


package com.playlogix.traventure;

import java.util.HashSet;
import java.util.Set;

public class ContentType {
   private Set<Template> template = new HashSet<Template>();
   private String description = "";
   private Content content;
   private Long id ;
   public ContentType() {
   }
   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      System.out.println("the id was " + id);
      this.id = id;
   }

   public ContentType(Content content, String description) {
      super();
      this.content = content;
      this.description = description;
   }

   public Set<Template> getTemplate() {
      return template;
   }

   public void setTemplate(Set<Template> template) {
      this.template = template;
   }

   public String getDescription() {
      return description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public Content getContent() {
      return content;
   }

   public void setContent(Content content) {
      this.content = content;
   }

}


Top
 Profile  
 
 Post subject: SOLVED
PostPosted: Tue Sep 13, 2005 10:11 am 
Newbie

Joined: Tue May 18, 2004 8:55 am
Posts: 3
Ok .. Solved my own problem ..


DONT have ANY unenhanced ( duplicate) classes on your classpath...:)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.