[Persistence, JBoss/CMP, Hibernate, Database] - assigning a column as an id for persisting
by Jihnd
hello all,
i'm trying to create a new record in an oracle xe database using webservices, entity and session beans. i get the error
"Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():" when i try to create the record however.
i have annotated a column with the id value but when i try to create the record, it doesnt seem to recognise that?
here are my classes for clarity:
package domain;
|
| import javax.persistence.*;
| import org.jboss.web.WebService;
| import org.jboss.wsf.spi.*;
| import org.jboss.wsf.spi.annotation.WebContext;
|
| @Entity
| @Table(name="Audiorec")
| @WebContext(contextRoot="/AVmanBean")
| public class Audiorec implements java.io.Serializable{
| private int Barcode_audiorec;
| private String Audiorec_alias;
| private String Serial_audiorec;
| private String Media_audiorec;
| private String Formats_audiorec;
|
| public Audiorec() {
| }
|
|
| public Audiorec(String Alias, Integer Barcode, String Model, String Serial, String Media, String Formats, String Inputs, String Outputs) {
| super();
| this.Audiorec_alias = Alias;
| this.Barcode_audiorec = Barcode;
| this.Serial_audiorec = Serial;
| }
|
| @Id
| @Column(name="Audiorec_alias")
| public String getAudiorec_alias( ) { return Audiorec_alias; }
| public void setAudiorec_alias(String alias) { this.Audiorec_alias = alias; }
|
| @Column(name="Barcode_audiorec")
| public int getBarcode_audiorec( ) { return Barcode_audiorec; }
| public void setBarcode_audiorec(int barcode) { this.Barcode_audiorec = barcode; }
|
| @Column(name="Serial_audiorec")
| public String getSerial_audiorec( ) { return Serial_audiorec; }
| public void setSerial_audiorec(String serial) { this.Serial_audiorec = serial; }
|
| @Column(name="Media_audiorec")
| public String getMedia_audiorec( ) { return Media_audiorec; }
| public void setMedia_audiorec(String media) { this.Media_audiorec = media; }
|
| @Column(name="Formats_audiorec")
| public String getFormats_audiorec( ) { return Formats_audiorec; }
| public void setFormats_audiorec(String formats) { this.Formats_audiorec = formats; }
|
| }
and my session bean:
package Audiorec;
|
| import javax.ejb.Stateless;
| import javax.jws.WebMethod;
| import javax.jws.WebParam;
| import javax.persistence.EntityManager;
|
| import javax.persistence.PersistenceContext;
|
| import domain.Audiorec;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
| import org.jboss.ws.annotation.*;
| import javax.jws.WebService;
| import org.jboss.wsf.spi.annotation.WebContext;
|
| @Stateless
| @WebService(name="AVmanBean", serviceName="AVmanBean")
| //@WebContext(contextRoot="/AVmanBean")
| public class AVmanBean implements AVmanRemote{
| @PersistenceContext
| (unitName="AVmanBean")
| private EntityManager manager;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void createAudiorec(@WebParam(name = "Alias")
| String Alias, @WebParam(name = "barcode")Integer Barcode, @WebParam(name = "serial")String Serial, @WebParam(name = "media")String Media)
| {
| Audiorec audiorec = new Audiorec();
| audiorec.setAudiorec_alias(Alias);
| audiorec.setBarcode_audiorec(Barcode);
| audiorec.setSerial_audiorec(Serial);
| audiorec.setMedia_audiorec(Media);
|
| manager.persist(audiorec);
| }
|
| public String findAudiorec(@WebParam(name = "Audiorec_alias")
| String alias) {
| Audiorec arrr = manager.find(Audiorec.class, alias);
| return arrr.getSerial_audiorec();
| }
|
|
| }
i am able to search records through my webservices so i'm hoping nothing's majorly out of place but i'm a bit stumped on this id thing. i'm reading up on hibernate right now but i thought i'd just throw it out here if anyone could steer me in the right direction
cheers for reading thus far :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120861#4120861
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120861
18 years, 5 months
[Messaging, JMS & JBossMQ] - [JAVA-JMS]+Jboss confiurazione
by erasmo78
I have this problem
Exception in thread "main" javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI class loader disabled)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at erasmo.jms.Sender.main(Sender.java:45)
I have configured this file
/home/erasmo/jboss-4.0.5.GA/server/nodo1/deploy/jms/hajndi-jms-ds.xml
Add this row
queue/order
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
queue/mail
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
I have an application standalone in Java
....................
TextMessage message_topic = null;
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "10.173.174.1");
// properties.put(Context.SECURITY_AUTHENTICATION, "no");
// properties.put(Context., "no");
ctx = new InitialContext(properties);
//Queue Initializzation
cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
destination = (Queue)ctx.lookup("queue/order");
connection = cf.createQueueConnection();
session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
sender = session.createSender(destination);
.............
But when i run my java application the answer is the following:
TextMessage message_topic = null;
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "10.173.174.1");
// properties.put(Context.SECURITY_AUTHENTICATION, "no");
// properties.put(Context., "no");
ctx = new InitialContext(properties);
//Queue Initializzation
cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
destination = (Queue)ctx.lookup("queue/order");
connection = cf.createQueueConnection();
session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
sender = session.createSender(destination);
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120860#4120860
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120860
18 years, 5 months
[JBossWS] - Re: WS-Security Newbie Question...
by lafaserem
Alessio.. yes... I've already read that link. Thanks anyway ;)
Peter.. Also I've already read that post, but I'm still lost (sorry.. these are my first days working with web services and I'm getting a bit crazy hehe)
I'm gonna write everything I'm doing (surely there will be a lot of mistakes, but well.. all the beginnings are tough... :P) and I would appreciate a lot if you could give me a hand in this...
First... SERVER
Hello.java
| package wssec;
|
| import javax.jws.WebMethod;
| import javax.jws.WebParam;
| import javax.jws.WebService;
| import javax.jws.soap.SOAPBinding;
|
| import org.jboss.ws.annotation.EndpointConfig;
|
| @WebService(name = "Hello", targetNamespace = "urn:ws.sec")
| @EndpointConfig(configName = "Standard WSSecurity Endpoint")
| @SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
| public class Hello
| {
| @WebMethod
| public String echo(@WebParam(name = "param1") String param1)
| {
| return param1;
| }
| }
|
I compiled it with
| javac -d . -classpath jboss-jaxws.jar;jboss-client.jar *.java
|
I've made my keystore with the command:
| keytool -genkey -keystore wsse.keystore -storepass jbossws -keyalg RSA -alias wsse -validity 365
|
Then I exported the certificate with:
| keytool -export -file wsse.cer -keystore wsse.keystore -storepass jbossws -alias wsse
|
And created the truststore with
| keytool -import -alias wsse -file wsse.cer -keystore wsse.truststore -storepass jbossws
|
web.xml
| <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
| version="2.4">
| <display-name>Hello</display-name>
| <servlet>
| <servlet-name>Hello</servlet-name>
| <servlet-class>wssec.Hello</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Hello</servlet-name>
| <url-pattern>/Hello</url-pattern>
| </servlet-mapping>
| </web-app>
|
jboss-wsse-server.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_
| 0.xsd">
| <key-store-file>WEB-INF/wsse.keystore</key-store-file>
| <key-store-password>jbossws</key-store-password>
| <trust-store-file>WEB-INF/wsse.truststore</trust-store-file>
| <trust-store-password>jbossws</trust-store-password>
| <config>
| <sign type="x509v3" alias="wsse"/>
| <requires>
| <signature/>
| </requires>
| </config>
| </jboss-ws-security>
|
I create my .war with
| jar cvf Hello.war WEB-INF
|
and the structure of WEB-INF is
WEB-INF
| jboss-wsse-server.xml
| wsse.keystore
| wsse.truststore
| web.xml
| classes
| | Hello.class
Once done this I copy Hello.war into jboss4-2-2GA\server\default\deploy and everything seems to be OK
Once that I have the WS deployed on the server which are the steps I have to follow for build my client? I only want to transmit signed messages, not interested in encryption...
This might seem a stupid topic, but I'm getting lost, 'cause this is new for me and I'm not able to find any "very very very basic" documents...
Thanks ;)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120850#4120850
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120850
18 years, 5 months