Intellij generating jpa modelgen classes empty - intellij-idea

I have a complicated project imported in intellij
Parent project and submodules (all submodules are also git submodules)
One of jar submodule A(wicket aopplication) is using another jar module B as a lib> In B we are using jpa modelgen form hibernate to generate static model for criteria builder. When launching all maven build in terminal, all is ok.
But when i try launch test in A or launching server for running A it will create in projet A -> target-> generated-classes-annotation the sames classes as in project B but empty, so it crashes on compilation.
class generated in project B:
#Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor", date = "2022-10-21T11:57:01.199+0400")
#SuppressWarnings({ "deprecation", "rawtypes" })
#StaticMetamodel(ClientInvoice.class)
public abstract class ClientInvoice_ extends com.seanergie.intranet.entities.companies.accounting.InvoiceBase_ {
public static volatile SingularAttribute<ClientInvoice, BankAccount> bankAccount;
public static volatile SingularAttribute<ClientInvoice, Boolean> includeTimeSheet;
public static volatile SingularAttribute<ClientInvoice, LocalDate> timeSheetStartDate;
public static volatile ListAttribute<ClientInvoice, ClientInvoiceLine> invoiceLines;
public static volatile ListAttribute<ClientInvoice, PaymentAllocation> paymentAllocations;
public static volatile SingularAttribute<ClientInvoice, LocalDate> timeSheetEndDate;
public static volatile SingularAttribute<ClientInvoice, Client> client;
public static volatile SingularAttribute<ClientInvoice, Project> project;
public static volatile SingularAttribute<ClientInvoice, String> currencyCode;
public static volatile SingularAttribute<ClientInvoice, String> additionalInformationHtml;
public static final String BANK_ACCOUNT = "bankAccount";
public static final String INCLUDE_TIME_SHEET = "includeTimeSheet";
public static final String TIME_SHEET_START_DATE = "timeSheetStartDate";
public static final String INVOICE_LINES = "invoiceLines";
public static final String PAYMENT_ALLOCATIONS = "paymentAllocations";
public static final String TIME_SHEET_END_DATE = "timeSheetEndDate";
public static final String CLIENT = "client";
public static final String PROJECT = "project";
public static final String CURRENCY_CODE = "currencyCode";
public static final String ADDITIONAL_INFORMATION_HTML = "additionalInformationHtml";
}
class generated in project A only from intellij maven launcher even in test class:
#Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor", date = "2022-10-21T11:57:01.199+0400")
#SuppressWarnings({ "deprecation", "rawtypes" })
#StaticMetamodel(ClientInvoice.class)
public abstract class ClientInvoice_ extends com.seanergie.intranet.entities.companies.accounting.InvoiceBase_ {
}
annotation processor is activated in settings
parent pom file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>utf-8</encoding>
<optimize>true</optimize>
<debug>true</debug>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<fork>true</fork>
<compilerArgs>
<arg>-AaddGeneratedAnnotation=true</arg><!-- http://docs.jboss.org/hibernate/orm/4.3/topical/html/metamodelgen/MetamodelGenerator.html -->
<arg>-AaddGenerationDate=true</arg>
<arg>-AaddSuppressWarningsAnnotation=true</arg>
</compilerArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.35</version> <!--Make sure it is same as bom version -->
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
and in project A i have to put is in the pom or i cant use the play button in test class:
<dependency><!-- For launch tests directly from intellij play button-->
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<exclusions>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
</dependencies>
any idea?

Related

#Cacheable annotation cannot work as expected when deserialize beans with LocalDateTime type property

I found that the annotation #Cacheable cannot work when the method returns a Java Bean type, this is the complete description:
I annotated #Cacheable on a method to use spring cache:
#Cacheable(cacheNames="userCache", key="#userId")
public User getUser(long userId){
return userRepository.getUserById(userId);
}
And the User class like this:
public class User{
Long userId;
String username;
#JsonSerialize(using = LocalDateTimeSerializer.class)
#JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime birthDateTime;
}
As you can see, I annotated the relating Jackson annotations to make Jackson deserialization for LocalDateTime types work, and this is the related dependency in pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.12.5</version>
</dependency>
After that, I call the #Cacheable method getUser like this:
User user = userCache.getUser(1L);
and there throws an exception:
org.redisson.client.RedisException: Unexpected exception while processing command
at org.redisson.command.CommandAsyncService.convertException(CommandAsyncService.java:326)
at org.redisson.command.CommandAsyncService.get(CommandAsyncService.java:123)
at org.redisson.RedissonObject.get(RedissonObject.java:82)
...blabla
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 101] (through reference chain: com.stackoverflow.domain.User["birthDateTime"]) at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1764)
at com.fasterxml.jackson.databind.deser.impl.UnsupportedTypeDeserializer.deserialize(UnsupportedTypeDeserializer.java:36)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
3.Before I use the #Cacheable, there is no problem if I get the User from database straightly. But when I begin to use #Cacheable, it always throws the exception above, no matter if I configured those Jackson deserialization for LocalDateTime. Is #Cacheable cannot work well with Java Bean with LocalDateTime property, or just my configuration of Jackson is wrong?
I had the same problem. Spring Cache doesn't use the implicit ObjectMapper used by other Spring components.
Include the module, you already did that.
Create a configuration which will override the default Spring Cache Configuration:
#Configuration
#EnableCaching
public class CacheConfiguration {
#Bean
public RedisSerializationContext.SerializationPair<Object> serializationPair() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule())
.activateDefaultTyping(
objectMapper.getPolymorphicTypeValidator(),
ObjectMapper.DefaultTyping.EVERYTHING,
JsonTypeInfo.As.PROPERTY
);
return RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapper));
}
#Bean
public RedisCacheConfiguration redisCacheConfiguration(
#Value("${cache.default-ttl-in-seconds}") Integer ttl,
RedisSerializationContext.SerializationPair<Object> serializationPair
) {
return RedisCacheConfiguration.defaultCacheConfig()
.disableCachingNullValues()
.entryTtl(Duration.ofSeconds(ttl))
.serializeValuesWith(serializationPair);
}
}

Deserializing guava optional<long> is failing

I am serializing a guava optional using jackson(version:2.9.4).
When i am deserializing, i am getting below exception:
Cannot deserialize instance of 'java.lang.Long' out START_OBJECT token.
When i debug the value during deserialization, i noticed that the value is coming as "Optional(present=true)" rather than the value present inside Optional.
I looked at the object mapper, and "GuavaModule()" is already being registered with the object mapper.
Please let me know if i am missing anything.
With registering the GuavaModule of
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-guava</artifactId>
</dependency>
…and the following bean…
import com.google.common.base.Optional;
import lombok.Data;
import lombok.NoArgsConstructor;
#Data
#NoArgsConstructor
public class GuavaBean {
private Optional<Long> abc;
}
…this gives me a green test…
import static org.assertj.core.api.Assertions.assertThat;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
[…]
#Test
public void guava() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new GuavaModule());
GuavaBean bean = new GuavaBean(Optional.of(9l));
String beanSerialized = objectMapper.writeValueAsString(bean);
assertThat(beanSerialized).isEqualTo("{\"abc\":9}");
GuavaBean optLong = objectMapper.readValue(beanSerialized, GuavaBean.class);
assertThat(optLong.getAbc().get()).isEqualTo(9);
}
However, if I accidentally use java.util.Optional instead of com.google.common.base.Optional, then the beahviour is exactly like you wrote.

Component objects instead of page objects in selenium

One of the most popular patterns in testing based on selenium is page object. Unfortunately, we often need to duplicate code if we use it as is. Consider the following situation:
We use UI framework, with common component, say some fancy table
Table is quite complicated, has filtering, sorting, searching
The table is used on several pages in the app
Is there any existing infrastructure to create more granular component objects instead of page objects either in selenium or in a thrid party lbirary?. I mean, annotations, and related infrastructure?
Appium which is the mobile implementation of selenium webdriver has a concept of widgets which is an extension of pageobjects. There is a Widget class which allows one to search relative to an element including in a web browser. You can check this out in the appium source test section. Have a look in the package io.appium.java_client.pagefactory_tests.widgets. This supports the FindBy annotation and WebElement construct and the PageFactory initialization.
So instead of using
#FindBy(.......)
private WebElement myTable;
you can use
#FindBy(container of the table....)
private Table myTable;
Table class can now have all the relevant variables and methods.
Part of POM.xml
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
Test Class --
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
public class WidgetBrowTest {
#Test
public void test() {
System.setProperty("webdriver.chrome.driver", "E:/Software Testing/Selenium/Jars/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://stackoverflow.com/");
SOHome soHome = new SOHome(driver);
PageFactory.initElements(new AppiumFieldDecorator(driver), soHome);
//Below two are from widget - First question in stackoverflow homepage
System.out.println(soHome.getFirstQues().getQuesTitle());
System.out.println(soHome.getFirstQues().getQuesTags());
//Below two are from home page
System.out.println(soHome.getLogoText());
System.out.println(soHome.getMenuText());
}
}
StackOverflow Home -
import java.util.List;
import java.util.stream.Collectors;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class SOHome {
#FindBy(css="div[id='hlogo'] > a")
private WebElement logo;
#FindBy(xpath="//div[#id='hmenus']//li/a")
private List<WebElement> menuOpt;
#FindBy(css="div[class='summary']")
private SOQuesWidget firstQues;
private WebDriver driver;
public SOHome(WebDriver driver) {
this.driver = driver;
}
public String getLogoText() {
return logo.getText();
}
public List<String> getMenuText() {
return menuOpt.stream().map(t -> t.getText()).collect(Collectors.toList());
}
public SOQuesWidget getFirstQues() {
return firstQues;
}
}
Question Widget - First Question
import java.util.List;
import java.util.stream.Collectors;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.pagefactory.Widget;
public class SOQuesWidget extends Widget {
#FindBy(css="a[class='question-hyperlink']")
private WebElement quesTitle;
#FindBy(xpath=".//div[starts-with(#class,'tags')]/a")
private List<WebElement> quesTags;
protected SOQuesWidget(WebElement element) {
super(element);
}
public String getQuesTitle() {
return quesTitle.getText();
}
public List<String> getQuesTags() {
return quesTags.stream().map(t -> t.getText()).collect(Collectors.toList());
}
}
Page objects is kind of a misnomer. They don't have to be specifically full pages to follow the page object model. I would create a Table class (page object) that contains all of the locators and methods for the Table object and then include it in the pages/page objects where it appears.
For example, if the home page contains a table object, then the HomePage class would reference the Table class.

Failed to marshal EJB parameters --- IllegalArgumentException: Can not set org.apache.commons.collections.FastHashMap field

I'm getting the below error while trying to save a search results using the Remote interface for SearchFacade.java
"Failed to marshal EJB parameters"
Can not set org.apache.commons.collections.FastHashMap field
org.apache.commons.validator.Field.hMsgs to
org.apache.commons.collections.FastHashMap at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at
I'm Using struts 1.1, EJB 2.1 using xdoclet 1.2.3 jars for generating the dependency files.(which is inevitable to use), Where my Local,Home interfaces are being generated using Xdoclet..
I'm also using Java 6, Jboss EAP 6.1 Alpha in my project.
Note: The same code works fine when running in Jboss 4.0
So wonder is my remote calling is correct.
Any help is welcome.
Error Logs
java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:270) at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:259) at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:170) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) at org.jboss.ejb.client.EJBHomeCreateInterceptor.handleInvocation(EJBHomeCreateInterceptor.java:79) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:177) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:161) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:124) at $Proxy25.saveSearch(Unknown Source) at com.web.history.SearchFormDelegate.saveSearch(SearchFormDelegate.java:177) at com.history.SaveSearchAction.createNewSavedSearch(SaveSearchAction.java:109) at com.history.SaveSearchAction.executeSynchronized(SaveSearchAction.java:296) at com.dispatch.SynchronizedAction.execute(SynchronizedAction.java:206) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.security.AuthenticationFilter.doFilter(AuthenticationFilter.java:672) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.IllegalArgumentException: Can not set org.apache.commons.collections.FastHashMap field org.apache.commons.validator.Field.hMsgs to org.apache.commons.collections.FastHashMap at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) at java.lang.reflect.Field.set(Field.java:657) at org.jboss.marshalling.cloner.SerializingCloner.storeFields(SerializingCloner.java:368) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:313) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner$StepObjectInput.doReadObject(SerializingCloner.java:836) at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:57) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:344) at java.util.HashMap.readObject(HashMap.java:1030) at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:218) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:302) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:285) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:268) ... 42 more
Code:
saveAction.java
protected void newSavedSearch(final SrchFrmDelegate sfd,
final String userId, final HttpServletRequest request,
final SaveSearchForm form) throws RemoteException,
UsrNotFoundException {
BseSrchValue srchValue = SrchResultsAction.retrieveSrchCriteria(request);
FrmLayout frmLayout = (FrmLayout) request.getSession().getAttribute(
FrmBuilderAction.FRM_LAYOUT_KEY);
Integer resultCount = null;
SrchResultValue srchResult = SearchResultsAction.retrieveSearchResults(request);
if (srchResult != null) {
resultCount = new Integer(srchResult.getTotal());
}
sfd.saveSearch(userGuid,
form.getTitle(),
form.getDesc(),
form.getNewTtle(),
srchValue,
frmLayout,
resultCount,
form.getSearches());
}
SrchFrmDelegate.java
/**
* Reference to the remote interface.
*/
private SrhFrmFacadeRemote srhFacadeRemote;
public String saveSearch(final String userId, final String srchTtle,
final String srchDesc, final Boolean newTtle,
final BsSearchValue srchValue, final FrmLay frmLay,
final Integer resultCount, final List alerts)
throws UsrNotFoundException,
RemoteException {
return srhFacadeRemote.saveSearch(userId, srchTtle,
srchDesc, newTtle, srchValue, frmLay,
resultCount, alerts);
}
SrchFrmFacadeRemote.java
/**
* Remote interface for SrchFrmFacade.
*/
public java.lang.String saveSearch( java.lang.String userId,java.lang.String srchTtle,java.lang.String srchDesc,java.lang.Boolean newTtle,com.common.search.BsSearchValue srchValue,com.common.search.advanced.FrmLay frmLay,java.lang.Integer resultCount,java.util.List alerts ) throws com.common.admin.UserNotFoundException, java.rmi.RemoteException;
Objects that passed as parameters or as response on remote calls must be Serializable.
example:-
public class APIGetVerificationProofs implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String fileName;
private String mimeType;
private String itemId;
private String type;
.
.
.
.
}
After adding the below jars in Jboss 7 modules & altering the standalone.xml file accordingly, Issue is fixed.
jboss-eap-6.1.0.Alpha\modules\system\layers\base\org\apache\commons\validator
commons-validator-1.1.0.jar
jboss-eap-6.1.0.Alpha\modules\system\layers\base\org\apache\commons\collections commons-collections-3.2.1.jar
In Standalone.xml
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
<global-modules>
<module name="org.apache.commons.collections" slot="main"/>
<module name="org.apache.commons.validator" slot="main"/>
</global-modules>
</subsystem>
In EJB3 this error can also occur when invoking an EJB Session Bean across a #Remote view of the EJB. Depending on the design and usage scenario, you may be able to invoke the EJB over a #Local interface. Using the #Local interface will eliminate the requirement for the parameters to be Serializable but this can markedly change your design. If using the #Local view is an option for you, you can simply add the #Local to the EJB without removing the #Remote.
public class MySessionBeanImpl implements MySessionBean {
...
}
#Local
#Remote
public interface MySessionBean {
...
}
The JEE App Server will make the right decision to use the local view if the client of the invocation is in-container. According to the API docs, the Local annotation can appear on either the class or the interface. If on the class, the value attribute must be specified.
remember to add serialVersionUID to let class to be serialized and restored (generate it as getter or setter)
For this problem first, you have to implement Serializable interface in your POJO class (java beans) as:
package com.test;
import java.io.Serializable;
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private int empID;
private String empName;
private int empSalary;
public int getEmpID() {
return empID;
}
//alt_shift_s_r-getter and setter method
//alt_shift_s_s override toString()
public void setEmpID(int empID) {
this.empID = empID;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public int getEmpSalary() {
return empSalary;
}
public void setEmpSalary(int empSalary) {
this.empSalary = empSalary;
}
#Override
public String toString() {
return "Employee [empID=" + empID + ", empName=" + empName + ", empSalary=" + empSalary + "]";
}
}
Note: if you are adding some external jars into your project then follow the below procedure to add jars.
Right Click on your EJB project and go to properties.
Then Select Deployment assembly then clicks on add.
From the appears option select appropriate source (As Archive from File System) then go to next.
Now Add jars from your desired location and finish the procedure.
enter code here

When Serializing A VB.Net Class to XML how do you alter the hierarchy?

I have created a class from and xsd using xsd.exe. The VB.Net class is fine. I have to use this class to create a file which contains multiple versions of the class.
So if my code generated class is called "Profile" I want a file which is structured as follows:
<Profiles>
<FILEFROM>ID1</FILEFROM>
<Profile>
.
.
</Profile>
<Profile>
.
.
</Profile>
I have created a class (ProfilesClass) and included a property (Profile) which is an array of the Profile Class, but I get an extra level in my XML when serialized. Here's the class definition:
System.Xml.Serialization.XmlRootAttribute("Profiles", [Namespace]:="http/webaddress/TravelProfile", IsNullable:=False)> _
Partial Public Class ProfilesClass
Private _Profiles() As ProfileType
<System.Xml.Serialization.XmlArrayItemAttribute("Profile", IsNullable:=False), _
System.Xml.Serialization.XmlArrayAttribute("Profiles", Isnullable:=False)> _
Public Property Profiles() As ProfileType()
Get
Return _Profiles
End Get
Set(ByVal value As ProfileType())
_Profiles = value
End Set
End Property
End Class
This means that the XML, when serialised is this:
<Profiles>
<Profiles>
<Profile>
</Profile>
</Profiles>
</Profiles>
How can I remove one of the levels of "Profiles"