I am using Jacorb for corba implementation. I have started the NS on port 900.
When I am trying to start the server I am getting following exception
D:\eclipse_workspace\WorkSpace\corba\bin>jaco hello.MyServer -DORBInitRef.NameService=jacorb::localhost:900
org.jacorb.orb.ORB
Feb 14, 2013 4:00:07 PM org.jacorb.config.JacORBConfiguration <init>
WARNING: no properties found for configuration jacorb
Feb 14, 2013 4:00:07 PM org.jacorb.orb.ORBSingleton <init>
INFO: created ORBSingleton
Exception in thread "main" org.omg.CORBA.ORBPackage.InvalidName: IDL:omg.org/CORBA/ORB/InvalidName:1.0
at org.jacorb.orb.ORB.resolve_initial_references(ORB.java:1371)
at hello.MyServer.main(MyServer.java:15)
Code is as following
public static void main(String[] args) throws Exception{
Properties props = new Properties();
props.setProperty("ORBInitRef","NameService=jacorb::localhost:900");
System.out.println(System.getProperty("org.omg.CORBA.ORBClass"));
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
org.omg.CORBA.Object o = orb.resolve_initial_references("NameService");
NamingContextExt nc = NamingContextExtHelper.narrow( o );
}
Could someone tell whats the problem here?
The NameService reference has to be either a reference to a file containing an IOR, e.g., file://tmp/NS_Ref or an URL, e.g., http://www.testme.not/NS_Ref or just a corbaloc/corbaname URL, e.g., corbaloc:iiop:1.2#host1:3075/NameService
The last one is most common. You can shorten it, for example, to corbaloc::localhost:900/NameService
More information to corbaloc could be found at http://www.ciaranmchale.com/corba-explained-simply/the-corbaloc-and-corbaname-urls.html
Related
I've setup Pubsub.Builder with root url pointed to local PubSub emulator (localhost:8036 at my case). It seems to be working, I see that emulator is receiving my test pushes, but gives me error 400 Bad Request.
Publish code:
auth = GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
.createScoped(PubsubScopes.all());
client = new Pubsub.Builder(HTTP_TRANSPORT, JSON_FACTORY, auth)
.setApplicationName "test"
.setRootUrl("http://localhost:8036/")
.build();
msg = new PubsubMessage().encodeData("{\"a\": 1, \"b\": 2}".getBytes());
req = new PublishRequest().setMessages(Arrays.asList(msg));
client.projects()
.topics()
.publish("projects/GCLOUD-DEFAULT-PROJECT/topics/test-topic", req)
.execute();
In emulator console output I see following (that's for very basic PublishRequest):
[pubsub] jan 27, 2016 9:03:20 PM com.google.cloud.pubsub.testing.v1.FakePubsubGrpcServer$2 operationComplete
[pubsub] INFO: Adding handler(s) to newly registered Channel.
[pubsub] jan 27, 2016 9:03:20 PM com.google.cloud.pubsub.testing.v1.NettyUtil$HttpVersionDecider channelRead
[pubsub] INFO: Detected non-HTTP/2 connection.
[pubsub] jan 27, 2016 9:03:20 PM com.google.cloud.pubsub.testing.v1.NettyUtil$HttpJsonAdapter channelRead
[pubsub] INFO: Invalid input: Expect message object but got: "\u001f�\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000�V�M-.NLO-V���VJI"
[pubsub] com.google.protobuf.InvalidProtocolBufferException: Expect message object but got: "\u001f�\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000�V�M-.NLO-V���VJI"
[pubsub] at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1099)
[pubsub] at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1075)
[pubsub] at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:973)
[pubsub] at com.google.protobuf.util.JsonFormat$Parser.merge(JsonFormat.java:201)
[pubsub] at com.google.cloud.pubsub.testing.v1.PubsubJsonGrpcAdapters$PublisherAdapter.handleRequest(PubsubJsonGrpcAdapters.java:231)
[pubsub] at com.google.cloud.pubsub.testing.v1.NettyUtil$HttpJsonAdapter.channelRead(NettyUtil.java:94)
[pubsub] at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
Seems that default PubSub client uses different protocol, but I don't see any way to configure it.
How can I use com.google.apis:google-api-services-pubsub library with local emulator?
The emulator does not require or handle authentication or authorization; I'm guessing that's where the problem lies. Can you try passing null as the last parameter to the builder?
Also, it appears that Gzip compression must be explicitly disabled. Please set this on the builder:
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
request.setDisableGZipContent(true);
}
})
I am new JMS, I have created sample JMS application.
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:2809");
InitialContext context = new InitialContext(props);
QueueConnectionFactory qcf = (QueueConnectionFactory) context.lookup("jndi/testQF");
QueueConnection conn = qcf.createQueueConnection();
conn.start();
QueueSession session = (QueueSession) conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
Queue t = (Queue) context.lookup("jndi/testQQ");
I have created buses testBus security is disabled , buses members, Queue Connection Factory testQF selected bus testBus. created queue as testQQ selected bus as testBus and selected testPP queue as queue name which was created service ingratiation Bus destination as point to point.
while running my app I am getting this error.
SEVERE: JSAS1480I: Security is not enabled because the ConfigURL property file is not set.
Apr 10, 2015 8:12:21 PM null null
WARNING: WSVR0072W: Ignoring undeclared override of interface, com.ibm.tx.jta.transactionManager, with implementation, com.ibm.ws.tx.jta.TranManagerSet
Apr 10, 2015 8:12:21 PM null null
WARNING: WSVR0072W: Ignoring undeclared override of interface, com.ibm.ws.transaction.TransactionInflowProxy, with implementation, com.ibm.ws.tx.jta.TransactionInflowProxyImpl
Apr 10, 2015 8:12:21 PM null null
WARNING: WSVR0072W: Ignoring undeclared override of interface, com.ibm.ws.transaction.UtxImpl, with implementation, com.ibm.ws.tx.jta.UserTransactionImpl
Apr 10, 2015 8:12:21 PM null null
WARNING: WSVR0072W: Ignoring undeclared override of interface, com.ibm.ws.transaction.XATerminator, with implementation, com.ibm.ws.tx.jta.TxXATerminator
Apr 10, 2015 8:12:21 PM null null
WARNING: WSVR0072W: Ignoring undeclared override of interface, com.ibm.ws.uow.UOWManager, with implementation, com.ibm.ws.uow.UOWManagerImpl
Apr 10, 2015 8:12:21 PM null null
INFO: Client code attempting to load security configuration
javax.naming.NameNotFoundException: Context: ADMINIB-3UJMQ4ENode01Cell/nodes/ADMINIB-3UJMQ4ENode01/servers/server1, name: jndi/testQF: First component in name testQF not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.ibm.ws.naming.jndicos.CNContextImpl.mapNotFoundException(CNContextImpl.java:4564)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1822)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1777)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1434)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:616)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
at MySender.main(MySender.java:31)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:95)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(_NamingContextStub.java:506)
at com.ibm.ws.naming.jndicos.CNContextImpl$2.run(CNContextImpl.java:2958)
at com.ibm.ws.naming.jndicos.CNContextImpl$2.run(CNContextImpl.java:2954)
at com.ibm.ws.naming.util.CommonHelpers.retry(CommonHelpers.java:871)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:2952)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1818)
... 7 more
I am running my app from main method in j2ee project type is that an issue??
Please help me to fix this issue.
Thanks,
CVSR Sarma
I know this is a old question,but it really trap me.
I take the advice of get inputsream using classLoader, code like following:
public static Session getSession() {
if (sessionFactory == null) {
InputStream xmlInputStream =
ResourceUtil.getInputStream(HibernateDBUtil.class, CFG_XML);
Scanner scanner = new Scanner(xmlInputStream);
//just a test I can read the xml file ,print content here
while(scanner.hasNext()) System.out.println(scanner.nextLine());
scanner.close();
//reget the stream
xmlInputStream =
ResourceUtil.getInputStream(HibernateDBUtil.class, CFG_XML);
Configuration cfg = new Configuration();
cfg.addInputStream(xmlInputStream).configure();
// version 4.3 's way to config
StandardServiceRegistryBuilder builder =
new StandardServiceRegistryBuilder().applySettings
(cfg.getProperties());
StandardServiceRegistryImpl registry =
(StandardServiceRegistryImpl) builder.build();
sessionFactory = cfg.buildSessionFactory(registry);
}
return sessionFactory.openSession();
}
private static SessionFactory sessionFactory;
private static final String CFG_XML = "properties/hibernate.cfg.xml";
I confirm ResourceUtil.getInputStream is work fine,since I can print the content of hibernate.cfg.xml,but why still give me the error:
update:
full stack trace:
INFO: HHH000412: Hibernate Core {4.3.0.Final}
Jan 10, 2014 11:33:43 PM org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found Jan 10, 2014 11:33:43
PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist Jan 10, 2014
11:33:44 PM org.hibernate.cfg.Configuration configure INFO: HHH000043:
Configuring from resource: /hibernate.cfg.xml Jan 10, 2014 11:33:44 PM
org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml Exception
in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml
not found at
org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)atorg.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2093)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2074)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
at
cn.edu.gdut.utils.HibernateDBUtil.getSession(HibernateDBUtil.java:49)
at
cn.edu.gdut.utils.HibernateDBUtil.listBasicElement(HibernateDBUtil.java:25)
at cn.edu.gdut.utils.HibernateDBUtil.main(HibernateDBUtil.java:20)
I think, it doesn't really matter where the file is in your IDE. All it matter is where the file will be during execution time, in the final bundle.
So, assuming , your properties/ folder should become the root of the executed bundle.This way, as hibernate.cfg.xml is in properties/, then it should be in the root during execution time. Can you try by using
private static final String CFG_XML = "hibernate.cfg.xml";
Updated
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
below this your code continues. in hibernate.cfg.xml I mentioned <mapping resource="pkg/name/of/mapping/file/file.hbm.xml" />
I'm new to CORBA and JacORB. I'm struggling with my first Hello World app using CORBA with JacORB.
This is the newest error I got:
Nov 04, 2013 9:52:19 AM com.sun.corba.se.impl.transport.SocketOrChannelConnectionIm <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 7070"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
This is my server causes to that error:
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort","7070");
props.put("org.omg.CORBA.ORBInitialHost","localhost");
ORB orb = ORB.init(args, props);
try {
//
POA poa = POAHelper.narrow(orb
.resolve_initial_references("RootPOA"));
poa.the_POAManager().activate();
// Servant
HelloVnImpl hello = new HelloVnImpl();
// get servant reference
Object o = poa.servant_to_reference(hello);
HelloVn hVnRef = HelloVnHelper.narrow(o);
// Get root naming context
Object objRef = orb.resolve_initial_references("NameService");//Error
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
Look around on the internet, the issue is apparently my nameservice, but I think I start it.
C:\Users\Paul>ns -ORBInitRef.NameService=corbaloc::localhost:7070/NameService
Nov 04, 2013 9:38:25 AM org.jacorb.config.JacORBConfiguration <init>
WARNING: no properties found for configuration jacorb
Nov 04, 2013 9:38:25 AM org.jacorb.orb.ORBSingleton <init>
INFO: created ORBSingleton
Nov 04, 2013 9:38:27 AM org.jacorb.orb.giop.CodeSet getTCSDefault
WARNING: Warning - unknown codeset (Cp1252) - defaulting to ISO-8859-1
Nov 04, 2013 9:38:27 AM org.jacorb.naming.NameServer main
INFO: NS up
Nov 04, 2013 9:38:27 AM org.jacorb.orb.ORB run
INFO: ORB run
Now, I have no idea to do next. Please give me an advice. Thank you. :)
UPDATE:
This line code give me a null value:
System.out.println(System.getProperty("org.omg.CORBA.ORBClass"));
What does it mean?. Does it tell me that there is something wrong with my nameserver?.
Hope to see your advice. Thanks
There are a couple of problems with the way that you setup your server and the Naming Service (NS):
1) The two properties (org.omg.CORBA.ORBInitialPort and org.omg.CORBA.ORBInitialHost) that you set in the server code are not JacORB properties. Assuming that you want your server to listen for requests on port 7070,then you want to set the "OAAddress" property like this:
props.put("OAAdress", "iiop://localhost:7070");
2) The option -ORBInitRef.NameService=corbaloc::localhost:XXX/NameService should be for the server to locate the NS and is not the NS. Please note that "XXX" is the listen port of the NS and is should not be "7070".
I would recommend that you take a look at the hello demo which includes both a working server and client and they are much simpler.
How do I turn off the logging in my Console output? I don't want to see the output of my Java program:
Nov 01, 2013 12:01:29 PM org.glassfish.tyrus.server.ServerContainerFactory create
INFO: Provider class loaded: org.glassfish.tyrus.container.grizzly.GrizzlyEngine
Nov 01, 2013 12:01:29 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [0.0.0.0:8029]
Nov 01, 2013 12:01:29 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
Nov 01, 2013 12:01:29 PM org.glassfish.tyrus.server.Server start
INFO: WebSocket Registered apps: URLs all start with ws://localhost:8029
Nov 01, 2013 12:01:29 PM org.glassfish.tyrus.server.Server start
INFO: WebSocket server started.
I am surprised that Java does not have this functionality baked in (or that I couldn't find it which is kind of the same thing nowadays)...
Assign the System.out and System.err to a stream that does not write anything (to log). In .NET there is the the Stream.Null which is a stream with no backing store, i.e. a null stream or a void stream.
In Java, such a Stream is easily built by extending the java.io.OutputStream:
class VoidStream extends OutputStream {
#Override
public void write(int b) throws IOException {
//
// --------------
// | void space |
// --------------
//
}
}
Now, set the VoidStream to the System.out and System.err using System.setOut() and System.Err() resulting in an empty console,
PrintStream ps = new PrintStream(new VoidStream());
System.setOut(ps);
System.setErr(ps);
In theory, one caveat is System.console(), becuase its output stream cannot be set but functions as printf() and format() can be called. Fortunately, the System.console() is only available when the program is run in a terminal (otherwise it returns null) and who is still working with a terminal? ;-)