Web application server overload

1

Greetings.
I have created a web application to manage a veterinary clinic with Spring Roo and Gvnix tools, I have created the database with veterinary tables, owners, pets, appointments, all these tables are related to 1 to many among them, except the table treatments and drugs that relate to many to many, between these 2 tables mentioned above there is an intermediate table called treatment_med which serves to relate to each other, as a base manager of data use MySQL workbench and as server MYSQL Server everything works well for me, from the forms of the web application I can create , update and delete owners, pets, veterinarians, appointments, medicines, but when I try to create more than 2 records on the table treatments making a multiple selection in the medicines that have a relation with the table average treatments Get a jspx tag

<field:select field="Med"  id="c_com_clinicaveterinaria_dam_domain_Tratamiento_Med" itemValue="id" items="${medicamentoses}" multiple="true" path="/medicamentoses" z="+hr+pOBWxfr2whYp+joa+OMxAHk="/>

The application gives me an error without detail of why and it falls completely.

  • I look at the processes and see that when creating new records in the intermediate table treatment_med , the process of the Windows Task Manager with the name < strong> Java (TM) Plataform SE Binary (java.exe) triggers more than + 1,800KB (private workspace), which causes the web application to crash.

I know that the problem lies in this part of the AspectJ class of persistence of the Gvnix with the name

privileged aspect TratamientoBatchService_Roo_GvNIXJpaBatch {

Exactly in this part of the code:

@Transactional
public void TratamientoBatchService.create(List<Tratamiento> tratamientoes) {
    for( Tratamiento tratamiento : tratamientoes) {
        tratamiento.persist();
    }
}

The error that shows me by IntelliJ IDE console is this:

Stacktrace:] with root cause
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
at java.lang.StringBuffer.append(StringBuffer.java:272)
at org.apache.commons.lang3.builder.ToStringStyle.appendFieldSeparator(ToStringStyle.java:1503)
at org.apache.commons.lang3.builder.ToStringStyle.appendFieldEnd(ToStringStyle.java:1526)
at org.apache.commons.lang3.builder.ToStringStyle.append(ToStringStyle.java:439)
at org.apache.commons.lang3.builder.ToStringBuilder.append(ToStringBuilder.java:848)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:522)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:683)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:282) at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:145) at com.clinicaveterinaria.dam.domain.Citas_Roo_ToString.ajc$interMethod$com_clinicaveterinaria_dam_domain_Citas_Roo_ToString$com_clinicaveterinaria_dam_domain_Citas$toString(Citas_Roo_ToString.aj:13)
at com.clinicaveterinaria.dam.domain.Citas.toString(Citas.java:1)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuffer.append(StringBuffer.java:265)
at org.apache.commons.lang3.builder.ToStringStyle.appendDetail(ToStringStyle.java:586)
at org.apache.commons.lang3.builder.ToStringStyle.appendInternal(ToStringStyle.java:550)
at org.apache.commons.lang3.builder.ToStringStyle.append(ToStringStyle.java:436)
at org.apache.commons.lang3.builder.ToStringBuilder.append(ToStringBuilder.java:848)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:522)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:683)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:282)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:145)
at com.clinicaveterinaria.dam.domain.Tratamiento_Roo_ToString.ajc$interMethod$com_clinicaveterinaria_dam_domain_Tratamiento_Roo_ToString$com_clinicaveterinaria_dam_domain_Tratamiento$toString(Tratamiento_Roo_ToString.aj:13)
at com.clinicaveterinaria.dam.domain.Tratamiento.toString(Tratamiento.java:1)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:317)
at java.lang.String.valueOf(String.java:2994)

I have tried to configure the Maven server from the IDE IntelliJ IDEA to increase the amount of memory it can support using "- Xmx512m -XX: MaxPermSize = 128m" , I have installed JDK 6, 7, 8 and many other things, nothing works, I need to know because it is for the end of grade project.

I'm not sure but I think the solution would be to create a kind of BufferBuilder that will gradually load the objects in the virtual machine of java, but I have no idea how to do that or something similar.

Thank you for your attention.

    
asked by Sin Nombre 05.06.2016 в 00:59
source

2 answers

0

Modifying the variables to increase the heap size of your IDE would not imply any change.

Reviewing your error:

  

java.lang.OutOfMemoryError: Java heap space at   java.util.Arrays.copyOf (Arrays.java:3332)

Somewhere you are using a bufferedReader.readLine() reading an empty file.

Another common problem is to create multiple arrays, I have commonly seen that in a loop they make a copy of or create arrays.

Actually the problem is that you are allocating more memory than allowed, for that reason the OutOfMemoryError .

    
answered by 05.06.2016 в 01:42
0

Greetings.
The solution is what Luiggi Mendoza gave me. I had to overwrite the toString method of the class

package com.clinicaveterinaria.dam.domain;

import com.clinicaveterinaria.dam.domain.Tratamiento;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

privileged aspect Tratamiento_Roo_ToString {
public String Tratamiento.toString() {
    return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
   }    
}

And define the method in this way.

package com.clinicaveterinaria.dam.domain;

import com.clinicaveterinaria.dam.domain.Tratamiento;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

privileged aspect Tratamiento_Roo_ToString {

public String Tratamiento.toString() {
    return "";
      }
   }

Thank you very much for the solution. I can continue with the project.

    
answered by 05.06.2016 в 13:44